java - Using Ghost4j with MaxProcessCount on a tomcat causes jna error -
i'm trying develop web-service (based on jersey) converting pdf document jpeg images. choosed ghostscript because have experiences , it's results (especially embedet fonts). searched way use ghostscript java , found ghost4j.
so put ghost4j jars applications lib folder (also jna.jar). in first tests encountered problem executing task more once, because jna throws error when it's launched more 1 time. put jna.jar tomcat lib folder. worked littlebit better, executed 1 task @ time. if started 1 @ same time, nothing happened. didn't seem execute other task.
so tried setmaxprocesscount(2);
allow application execute more 1 task @ time. here code:
private static void generateimages(string inputfile, string outputpath) throws ioexception, rendererexception, org.ghost4j.document.documentexception { pdfdocument document = new pdfdocument(); document.load(new file(inputfile)); simplerenderer renderer = new simplerenderer(); renderer.setmaxprocesscount(2); renderer.setresolution(150); renderer.setantialiasing(4); system.setproperty("jna.library.path", "c:\\program files\\gs\\gs9.09\\bin\\"); list<image> images = renderer.render(document); (int = 0; < images.size(); i++) { imageio.write((renderedimage) images.get(i), "jpeg", new file(outputpath + file.separatorchar + (i + 1) + ".jpeg")); } }
but if i'm trying execute task, ghost4j throws error:
org.ghost4j.renderer.rendererexception: java.lang.exception: java.lang.noclassdeffounderror: com/sun/jna/structure @ org.ghost4j.renderer.abstractremoterenderer.render(abstractremoterenderer.java:133) @ pdfresource.conversiontask.generateimages(conversiontask.java:218) @ pdfresource.conversiontask.exec(conversiontask.java:58) @ pdfresource.task.run(task.java:86) @ java.lang.thread.run(thread.java:724) caused by: java.lang.exception: java.lang.noclassdeffounderror: com/sun/jna/structure @ gnu.cajo.invoke.remote.invoke(remote.java:594) @ gnu.cajo.invoke.remote.invoke(remote.java:722) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ sun.rmi.server.unicastserverref.dispatch(unicastserverref.java:322) @ sun.rmi.transport.transport$1.run(transport.java:177) @ sun.rmi.transport.transport$1.run(transport.java:174) @ java.security.accesscontroller.doprivileged(native method) @ sun.rmi.transport.transport.servicecall(transport.java:173) @ sun.rmi.transport.tcp.tcptransport.handlemessages(tcptransport.java:553) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run0(tcptransport.java:808) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run(tcptransport.java:667) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:724) @ sun.rmi.transport.streamremotecall.exceptionreceivedfromserver(streamremotecall.java:273) @ sun.rmi.transport.streamremotecall.executecall(streamremotecall.java:251) @ sun.rmi.server.unicastref.invoke(unicastref.java:160) @ java.rmi.server.remoteobjectinvocationhandler.invokeremotemethod(remoteobjectinvocationhandler.java:194) @ java.rmi.server.remoteobjectinvocationhandler.invoke(remoteobjectinvocationhandler.java:148) @ com.sun.proxy.$proxy165.invoke(unknown source) @ gnu.cajo.invoke.remote.invoke(remote.java:565) @ org.ghost4j.renderer.abstractremoterenderer.render(abstractremoterenderer.java:126) ... 4 more caused by: java.lang.noclassdeffounderror: com/sun/jna/structure @ org.ghost4j.renderer.simplerenderer.run(simplerenderer.java:68) @ org.ghost4j.renderer.abstractremoterenderer.remoterender(abstractremoterenderer.java:64) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ gnu.cajo.invoke.remote.invoke(remote.java:582) @ gnu.cajo.invoke.remote.invoke(remote.java:722) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ sun.rmi.server.unicastserverref.dispatch(unicastserverref.java:322) @ sun.rmi.transport.transport$1.run(transport.java:177) @ sun.rmi.transport.transport$1.run(transport.java:174) @ java.security.accesscontroller.doprivileged(native method) @ sun.rmi.transport.transport.servicecall(transport.java:173) @ sun.rmi.transport.tcp.tcptransport.handlemessages(tcptransport.java:553) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run0(tcptransport.java:808) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run(tcptransport.java:667) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) ... 1 more caused by: java.lang.classnotfoundexception: com.sun.jna.structure @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) ... 23 more
i guess has todo additional jvm ghost4j launching , doesn't seem use same classpath tomcat uses, i'm not java expert , have no idea how solve problem.
Comments
Post a Comment