zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 38 forks source link

Ghost4J multithreading on Jboss eap6.3 #41

Closed pavanlapr closed 8 years ago

pavanlapr commented 8 years ago

I am trying to use ghost4j in multithread mode. As suggested, I set processCount on PDFConverter to number 3, as I want max 3 threads.

When I test on JBoss 6.3, I end up getting below error:

Exception in thread "Thread-203" java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader

2015-11-18 10:45:38,533 ERROR stderr at org.ghost4j.util.JavaFork.getCurrentClasspath(JavaFork.java:172)

2015-11-18 10:45:38,545 ERROR stderr at org.ghost4j.util.JavaFork.run(JavaFork.java:122)

2015-11-18 10:45:38,558 ERROR stderr at java.lang.Thread.run(Thread.java:724)

It seems Ghost4j is using URLClassLoader, is there a way to get around this problem

zippy1978 commented 8 years ago

The problem seems to come from a class cast in the JavaFork utility class (used to spawn a new JVM with same parameters as the current one) : when running in JBoss this line does not work :

URL[] urls = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();

Here is the problem you have : http://lists.jboss.org/pipermail/jboss-dev-forums/2012-July/046538.html

Here there seems to be a solution : http://markmail.org/message/ohcanda7ait7i3gl (use ClassLoader.getResources("/"))

But you will have to hack Ghost4J code to make it work.

Hope this will help you.

Regards, Gilles

HighTechBull commented 8 years ago

I have a fix for this JBoss issue that does not involve any JBoss API dependencies. The fix is in JavaFork.java, and I can add it as a pull request.

zippy1978 commented 8 years ago

The PR is merged, everything seems ok. Will be available in the next release. Thanks again !

omasseau commented 7 years ago

Any date for the next release ?