java.lang.NoSuchFieldError: IS_SECURITY_ENABLED

雨燕双飞 提交于 2019-12-12 10:44:32

问题


I want to deploy a service to 2 servers. I succeed on one server, but failed on the other one. In fact, I try my best to make their environments same. The error log is as following:

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)

Thanks for any kind of help.


回答1:


java.lang.NoSuchFieldError: IS_SECURITY_ENABLED

This is part of one of Jasper JSP compiler's internal classes. This error suggests that you (or Maven) have for some reason included the Jasper JSP compiler JAR files in webapp's /WEB-INF/lib folder while those JAR files are supposed to be already provided by the target container (which is Jetty in your case).

This way it would only work if your webapp contains Jasper JAR files of exactly the same version as the target container has. But, after all, this is not the right approach. Those Jasper JAR files do not belong in the webapp's /WEB-INF/lib. They are supposed to be already provided by the target container. You need to get rid of them in the webapp's /WEB-INF/lib.

I'm no Maven hero, but, to the point, you need to tell it to not include the Jasper JAR files in the /WEB-INF/lib folder of the built WAR. You can do that by setting their dependency scope to provided.



来源:https://stackoverflow.com/questions/14440909/java-lang-nosuchfielderror-is-security-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!