SEVERE: Dispatcher initialization failed Unable to

2020-03-04 07:42发布

I am developing Struts 2 application and after all I am getting following error.

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/home/sachith/SourceCodeGroupCW/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PcArcade/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:69:87
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: Unable to load bean: type: class:org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader - bean - jar:file:/home/sachith/SourceCodeGroupCW/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PcArcade/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:69:87
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 17 more
Caused by: java.lang.NoClassDefFoundError: freemarker/cache/TemplateLoader
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:788)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:144)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: freemarker.cache.TemplateLoader
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    ... 29 more

Dec 11, 2013 1:25:28 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/home/sachith/SourceCodeGroupCW/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PcArcade/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:69:87
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: Unable to load configuration. - bean - jar:file:/home/sachith/SourceCodeGroupCW/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PcArcade/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:69:87
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
    ... 15 more
Caused by: Unable to load bean: type: class:org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader - bean - jar:file:/home/sachith/SourceCodeGroupCW/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PcArcade/WEB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:69:87
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 17 more
Caused by: java.lang.NoClassDefFoundError: freemarker/cache/TemplateLoader
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:788)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:144)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: freemarker.cache.TemplateLoader
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    ... 29 more

Dec 11, 2013 1:25:28 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Dec 11, 2013 1:25:28 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/PcArcade] startup failed due to previous errors
Dec 11, 2013 1:25:28 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 11, 2013 1:25:28 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 11, 2013 1:25:28 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4877 ms

I can not even think why is that? And my other files are like below,

Action file

public class PcArcadeAction {

    public String execute()
     {
      String success="success";
      return success;
     }
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

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

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

 <welcome-file-list>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>
</web-app>

I am getting error in struts.xml and it says The public identifier must begin with either a single or double quote character

enter image description here

Here is my folder structure :

enter image description here

标签: java struts2
3条回答
放荡不羁爱自由
2楼-- · 2020-03-04 08:08

Looks like freemarker jar is missing. This should rectify current issue. If other dependent JARs are missing then you will some other exceptions after this.

查看更多
▲ chillily
3楼-- · 2020-03-04 08:15

As the exception clearly states,

Caused by: java.lang.ClassNotFoundException: freemarker.cache.TemplateLoader

It is just a simple case of some missing jars ( freemarker in this case ).

If this is the first time you are making a struts application, I suggest you start with the blank struts war. It is a simple deployabe war file that contains all the basic jars and resources/files that are required to deploy and run a struts2 project successfully.

Here is the direct link to the war file.

查看更多
爷、活的狠高调
4楼-- · 2020-03-04 08:23

You just have to check that did you added all the required .jar files. these are below jar which you have to add: Maintain following version of jars in you lib. I think you won't face any problem

antlr-2.7.6.jar

commons-beanutils-1.7.0.jar

commons-collections-3.2.jar

commons-digester.jar

commons-fileupload-1.2.2.jar

commons-io-2.4.jar

commons-lang-1.2.jar

commons-logging-1.1.jar

freemarker-2.3.16.jar

javassist-3.7.ga.jar

ognl-3.0.jar

struts2-core-2.2.3.jar

xwork-core-2.2.1.jar

查看更多
登录 后发表回答