java.lang.NoSuchFieldError:IS_SECURITY_ENABLED

时间:2013-01-21 14:36:35

标签: java eclipse jsp jetty maven-jetty-plugin

我想将服务部署到2台服务器。我在一台服务器上成功,但在另一台服务器上失败了。事实上,我尽力使他们的环境相同。错误日志如下:

2013-01-21 22:08:18.178:WARN:oejuc.AbstractLifeCycle:FAILED jsp: java.lang.NoSuchFieldError: IS_SECURITY_ENABLED
java.lang.NoSuchFieldError: IS_SECURITY_ENABLED
    at org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:197)
    at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:150)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:492)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:312)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:776)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:258)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1213)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:699)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:491)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:138)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:142)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:53)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:604)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:535)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:398)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:332)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:118)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:552)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:227)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:58)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:53)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:91)
    at org.eclipse.jetty.server.Server.doStart(Server.java:263)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:457)
    at org.eclipse.jetty.start.Main.start(Main.java:602)
    at org.eclipse.jetty.start.Main.main(Main.java:82)

感谢您提供任何帮助。

1 个答案:

答案 0 :(得分:8)

java.lang.NoSuchFieldError: IS_SECURITY_ENABLED

这是Jasper JSP编译器内部类的一部分。此错误表明您(或Maven)由于某种原因在webapp的/WEB-INF/lib文件夹中包含Jasper JSP编译器JAR文件,而这些JAR文件应该已由目标容器(在您的情况下为Jetty)提供。

这样,只有当您的webapp包含完全与目标容器具有相同版本的Jasper JAR文件时,它才有效。但是,毕竟,这不是正确的方法。那些Jasper JAR文件不属于webapp的/WEB-INF/lib。它们应该是目标容器已经提供的。你需要在webapp的/WEB-INF/lib中删除它们。

我不是Maven的英雄,但是,到目前为止,您需要告诉它不要在构建的WAR的/WEB-INF/lib文件夹中包含Jasper JAR文件。您可以将dependency scope设置为provided