我在我的春季项目中使用 Ghost4J 0.5.1。
在本地一切正常(32 位),但是当我部署到 EC2(64 位)时,java.lang.IllegalStateException 引发。
final Ghostscript ghostScript = Ghostscript.getInstance();
synchronized(ghostScript)
{
try
{
ghostScript.initialize(optimicePdfArguments); //here raises the exception
}
catch (GhostscriptException e)
{
LOGGER.error("Error");
}
}
我指出 32/64 位,因为我认为这是两个系统之间的主要区别,并且发现了其他相关问题表明它。
如何让 Ghost4j 在我的 64 位机器上工作?
编辑 我正在使用 Spring Integration 服务捕获异常。当我不这样做时,会出现内部错误:
这是重要的部分:
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'gs': libgs.so: cannot open shared object file: No such file or directory
这是完整的堆栈跟踪:
2014-07-16 20:16:15,159 DEBUG [userId = 1] [transformPdfToHpubChannelExecutor-1] o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'errorChannel'
2014-07-16 20:16:15,160 DEBUG [userId = 1] [transformPdfToHpubChannelExecutor-1] o.s.i.c.DirectChannel - preSend on channel 'v1.manageIssueChange.channel.error', message: [Payload MessageHandlingException content=org.springframework.messaging.MessageHandlingException: java.lang.IllegalStateException: Cannot process message][Headers={id=12dbbf58-eda5-14b7-0ad9-8058225b6353, timestamp=1405541775160}]
2014-07-16 20:16:15,160 WARN [userId = 1] [transformPdfToHpubChannelExecutor-1] o.s.i.c.MessagePublishingErrorHandler - Error message was not delivered.
org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:/MagmaServer.v1.manageIssueChange.channel.error'.
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:81) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:255) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.channel.MessagePublishingErrorHandler.handleError(MessagePublishingErrorHandler.java:83) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55) [spring-integration-core-4.0.2.RELEASE.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:107) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
... 6 common frames omitted
2014-07-16 20:16:15,162 ERROR [userId = 1] [transformPdfToHpubChannelExecutor-1] o.s.i.c.MessagePublishingErrorHandler - failure occurred in messaging task with message: [Payload UpdateIssueRequestDTO content=com.proyecti.magma.web.issues.UpdateIssueRequestDTO@b31a250][Headers={errorChannel=v1.manageIssueChange.channel.error, operationType=createFromPdf, id=bd35e61d-7492-fb61-0d7f-49eea3b5c3f7, timestamp=1405541773441}]
org.springframework.messaging.MessageHandlingException: java.lang.IllegalStateException: Cannot process message
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:78) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:71) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:150) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:114) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:44) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:93) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:260) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:241) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:205) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:199) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:177) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:150) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:114) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:44) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:93) ~[spring-messaging-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:260) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:241) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:205) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:199) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:177) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:131) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.dispatcher.UnicastingDispatcher.access$000(UnicastingDispatcher.java:48) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.dispatcher.UnicastingDispatcher$1.run(UnicastingDispatcher.java:92) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
Caused by: java.lang.IllegalStateException: Cannot process message
at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:284) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:142) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:75) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
... 33 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'gs': libgs.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166) ~[jna-3.3.0.jar:3.3.0 (b0)]
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239) ~[jna-3.3.0.jar:3.3.0 (b0)]
at com.sun.jna.Library$Handler.<init>(Library.java:140) ~[jna-3.3.0.jar:3.3.0 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:393) ~[jna-3.3.0.jar:3.3.0 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:378) ~[jna-3.3.0.jar:3.3.0 (b0)]
at org.ghost4j.GhostscriptLibraryLoader.loadLibrary(GhostscriptLibraryLoader.java:39) ~[ghost4j-0.5.1.jar:na]
at org.ghost4j.GhostscriptLibrary.<clinit>(GhostscriptLibrary.java:34) ~[ghost4j-0.5.1.jar:na]
at org.ghost4j.Ghostscript.initialize(Ghostscript.java:323) ~[ghost4j-0.5.1.jar:na]
at com.proyecti.magma.services.v1.issue.transformpdf.TransformPdfToHpubServiceImpl.optimizePdf(TransformPdfToHpubServiceImpl.java:217) ~[TransformPdfToHpubServiceImpl.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_60]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_60]
at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:63) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:122) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:44) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:258) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:111) ~[spring-expression-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:159) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:268) ~[spring-integration-core-4.0.2.RELEASE.jar:na]
... 35 common frames omitted