Search code examples
javastruts2fedora

struts 2 NoSuchFieldError PROTOTYPE in TomCat on Fedora


A team is working on a struts application. Team members are using many different operating systems.

We are using Java 8. At the moment, I am using 1.8.0_152-b16, but I have tested using multiple versions of java 8 including 131 and 144.

I am currently using TomCat 8.5.23, but have also tried 8.0.20 and 9.0.1.

I install TomCat by unpacking the tar.gz version in place, and then modifying the tomcat-users.xml file.

Deployment is made by dropping the WAR file in place.

On Fedora 22 and Fedora 26, I see the following error in the localhost log file:

17-Oct-2017 17:06:13.077 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [struts2]
 java.lang.NoSuchFieldError: PROTOTYPE
    at org.apache.struts2.config.DefaultBeanSelectionProvider.register(DefaultBeanSelectionProvider.java:389)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:897)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:437)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:478)
    at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75)
    at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

The web.xml file is as follows:

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Struts 2 Web Application</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

I see this error on an older Fedora 22 computer. I then tested on a new install of Fedora 26. The odd thing is that I can drop the WAR file onto a CENTOS, Ubuntu, and Windows 7 with no problem. I only see this error on the Fedora machines.

I do not know much about struts, but I have used Java for a long time.

I understand the implications of the NoSuchFieldError, and it makes me suspect that an incorrect version of some jar file is being used, but it seems very odd to me that on Fedora I see the error, but not on some other operating system.

Any help in diagnosing this problem is appreciated.


Solution

  • It seems /com/opensymphony/xwork2/inject/Scope.class has been overridden by an older one than Jun 18, 2015. At this date DEFAULT is changed to PROTOTYPE according to this commit but it seems an older one class is loaded.