我正在尝试加载一个包含图像的pdf文件(更具体地说,我的java代码通过打印一些文本和图像来生成pdf文件。图像是一个qr代码图像,它是由我的Web应用程序中的代码的其他部分生成)。当我在Eclipse中运行我的程序"在服务器上运行"时,没有错误,我可以使用chrome在我的localhost上看到pdf。但是,当我从我的项目中创建一个WAR文件以在本地部署我的项目并尝试在chrome中浏览pdf页面时,我在com.itextpdf.text.pdf.PdfGraphics2D.drawImage&#中得到了#java; java.lang.IllegalArgumentException。 34;错误。 我注释掉了在我的java代码中在pdf文件上打印图像的部分,并重新生成了WAR文件。现在我能够看到pdf文件,但当然没有图像。我应该说我浏览我的应用程序的其他页面没有问题。 有谁可以帮助我如何解决这个问题。非常感谢任何信息。
更新1:
这是完整的堆栈跟踪
SEVERE: Exception or error caught in server resource
org.restlet.resource.ResourceException: Internal Server Error (500) - The server
encountered an unexpected condition which prevented it from fulfilling the requ
est
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:539)
at org.restlet.resource.ServerResource.get(ServerResource.java:742)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:617)
at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource
.java:678)
at org.restlet.resource.ServerResource.doConditionalHandle(ServerResourc
e.java:356)
at org.restlet.resource.ServerResource.handle(ServerResource.java:1043)
at org.restlet.resource.Finder.handle(Finder.java:236)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Router.doHandle(Router.java:422)
at org.restlet.routing.Router.handle(Router.java:639)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.jav
a:140)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHe
lper.java:77)
at org.restlet.Application.handle(Application.java:385)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Router.doHandle(Router.java:422)
at org.restlet.routing.Router.handle(Router.java:639)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.routing.Router.doHandle(Router.java:422)
at org.restlet.routing.Router.handle(Router.java:639)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.routing.Filter.handle(Filter.java:197)
at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
at org.restlet.Component.handle(Component.java:408)
at org.restlet.Server.handle(Server.java:507)
at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63
)
at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.j
ava:143)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1117
)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52
)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpo
int.java:2517)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:2506)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskTh
read.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException
at com.itextpdf.text.pdf.PdfGraphics2D.drawImage(PdfGraphics2D.java:1606
)
at com.itextpdf.text.pdf.PdfGraphics2D.drawImage(PdfGraphics2D.java:1340
)
at com.itextpdf.text.pdf.PdfGraphics2D.drawImage(PdfGraphics2D.java:1327
)
at com.itextpdf.text.pdf.PdfGraphics2D.drawImage(PdfGraphics2D.java:1310
)
at com.itextpdf.text.Image.getInstance(Image.java:838)
at org.safetycode.msc3.resources.PocketCardServerResource.addCodeImage(P
ocketCardServerResource.java:159)
at org.safetycode.msc3.resources.PocketCardServerResource.printCodeImage
(PocketCardServerResource.java:155)
at org.safetycode.msc3.resources.PocketCardServerResource.getPdf(PocketC
ardServerResource.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:523)
... 60 more
答案 0 :(得分:0)
我找到了解决问题的方法:
我认为当我使用Eclipse运行我的程序时,这样的临时文件正在某处生成而没有任何问题。但是使用WAR文件时tomcat没有权限创建“temp”文件。