使用javax.crypto包的WSO2应用服务器5.0.1 jsp无法编译

时间:2014-01-20 11:59:53

标签: jsp compiler-errors wso2 javax.crypto

我们正在使用WSO2应用程序服务器版本5.0.1。 如果我在JSP页面中使用javax.crypto包,则在访问时无法编译。为了验证这一点,我将jce.jar文件复制到Web应用程序的WEB-INF / lib文件夹中。如果jsp.jar文件存在于WEB-INF / lib文件夹中,则jsp编译正常,但如果从那里删除jce.jar,则编译失败并出现以下错误:

Generated servlet error:
The type javax.activation.DataHandler cannot be resolved. It is indirectly referenced from required .class files

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
PBEKeySpec cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
SecretKeyFactory cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
SecretKeyFactory cannot be resolved

] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
The type javax.activation.DataHandler cannot be resolved. It is indirectly referenced from required .class files

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
PBEKeySpec cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
SecretKeyFactory cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /processPassword.jsp
Generated servlet error:
SecretKeyFactory cannot be resolved


    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:260)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:172)
    at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)

想知道可能导致这些编译错误的原因以及如何避免它们而不必将jce.jar放在WEB-INF / lib中

如果我在servlet中使用javax.crypto包,它编译并运行正常。这让我相信在WSO2应用服务器版本5.0.1上有jsp编译存在类路径问题。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

这可能是应用服务器中的类加载问题,但我们已将其修复为5.1.0版本。我们引入了一个名为webapp-classloading.xml的新xml文件,以避免类加载问题。

请参阅http://docs.wso2.org/display/AS510/Webapp+ClassLoading

答案 1 :(得分:0)

由于jce.jar是jre的一部分,因此应该在jsp编译类路径上可用。因此,它不需要额外的web应用程序特定的类加载,例如通过webapp-classloading.xml。下面是一个无法编译的jsp页面的开头。在5.0.1上运行:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="org.apache.axiom.om.util.Base64"%>
<%@ page language="java" import="java.security.SecureRandom"%>
<%@ page language="java" import="java.security.spec.KeySpec"%>
<%@ page language="java" import="javax.crypto.SecretKeyFactory"%>
<%@ page language="java" import="javax.crypto.spec.PBEKeySpec"%>

您是否可以确认这在5.1.0中有效,而无需设置特定于Web应用程序的类路径?