UTFDataFormatException и ClassNotFoundException при добавлении изображения в портлет Liferay - PullRequest
0 голосов
/ 11 июля 2011

Я использую Liferay 5.2.3 на Tomcat 5.5. Я добавил тег

<img alt="G.png" src="<%= request.getContextPath() %>/images/G.png">

одному из JSP, на который я отправляю свой портлет, и я получил:

ERROR [http-8080-Processor22] (StandardWrapperValve.java:253) Servlet.service() for servlet jsp threw exception
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
        at org.apache.jasper.xmlparser.UTF8Reader.invalidByte(UTF8Reader.java:621)
        at org.apache.jasper.xmlparser.UTF8Reader.read(UTF8Reader.java:492)
        at org.apache.jasper.xmlparser.XMLEncodingDetector.load(XMLEncodingDetector.java:1000)
        at org.apache.jasper.xmlparser.XMLEncodingDetector.skipString(XMLEncodingDetector.java:951)
        at org.apache.jasper.xmlparser.XMLEncodingDetector.scanXMLDecl(XMLEncodingDetector.java:1209)
        at org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:121)
        at org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:109)
        at org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:305)
        at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:170)
        at org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
        at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
        at com.liferay.portal.servlet.filters.header.HeaderFilter.processFilter(HeaderFilter.java:109)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at com.liferay.portal.kernel.servlet.PortalClassLoaderFilter.doFilter(PortalClassLoaderFilter.java:78)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:662)

ERROR [http-8080-Processor20] (StandardWrapperValve.java:253) Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: org.apache.jsp.images.G_png
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
        at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
        at org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)
        at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
        at com.liferay.portal.servlet.filters.header.HeaderFilter.processFilter(HeaderFilter.java:109)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at com.liferay.portal.kernel.servlet.PortalClassLoaderFilter.doFilter(PortalClassLoaderFilter.java:78)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:662)

Некоторые изображения загружены хорошо, а некоторые нет.

Что может быть не так?

1 Ответ

0 голосов
/ 12 июля 2011

Мы ссылаемся на изображения в нашем jsp, создавая тег

с использованием следующего синтаксиса

<%@ tag isELIgnored="false" body-content="empty" %>${pageContext.request.contextPath}/images/

Хранится в файле с именем imagesPath в / WEB-INF / tags / html затем используйте это в JSP

<%@ taglib prefix="html" tagdir="/WEB-INF/tags/html" %>




<img src="<html:imagesPath />intro.jpg"  alt="Introduction"/>

Полагаю, важная часть этого, которую вам не хватает, это pageContext?

...