struts2 排错

以前项目用过webwork2,感觉这两个差不多,今天用struts2开发一个helloworld程序没想到出了很多错,看来自己真实眼高手低呀。

首先是:
严重: Exception starting filter struts
javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl could not be instantiated: java.lang.NullPointerException
	at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
	at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<clinit>(DomHelper.java:167)
	at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
	at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
	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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-3-11 11:23:38 org.apache.catalina.core.StandardContext start


最后在网上查到,有人建议移除$TOMCAT_HOME/common/endorsed/下的Jar包,说是很JDK的有冲突,后来,果然可以了。得感谢这些前辈们。


接着程序到时候能运行了,但日志里面出了很多错。
Caught Exception while registering Interceptor class org.apache.struts2.interceptor.debugging.DebuggingInterceptor - interceptor - jar:file:/E:/DevelopWorkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/struts2/WEB-INF/lib/struts2-core-2.0.11.jar!/struts-default.xml:98:115
	at org.apache.struts2.impl.StrutsObjectFactory.buildInterceptor(StrutsObjectFactory.java:78)
	at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:57)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.lookupInterceptorReference(XmlConfigurationProvider.java:905)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptorStack(XmlConfigurationProvider.java:743)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptorStacks(XmlConfigurationProvider.java:756)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptors(XmlConfigurationProvider.java:777)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:410)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
	at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
	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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=org.apache.struts2.views.freemarker.FreemarkerManager, name='default'] in public void org.apache.struts2.interceptor.debugging.DebuggingInterceptor.setFreemarkerManager(org.apache.struts2.views.freemarker.FreemarkerManager).
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:157)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:126)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:103)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:84)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:82)
	at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:155)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:81)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:121)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:452)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:492)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:491)
	at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:542)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:490)
	at com.opensymphony.xwork2.ObjectFactory.injectInternalBeans(ObjectFactory.java:131)
	at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:156)
	at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143)
	at org.apache.struts2.impl.StrutsObjectFactory.buildInterceptor(StrutsObjectFactory.java:53)
	... 31 more
Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=org.apache.struts2.views.freemarker.FreemarkerManager, name='default'] in public void org.apache.struts2.interceptor.debugging.DebuggingInterceptor.setFreemarkerManager(org.apache.struts2.views.freemarker.FreemarkerManager).
	at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:239)
	at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:229)
	at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:282)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:130)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:128)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:154)
	... 49 more


后来看了看,应该是缺少freemarker的Jar文件,放进去,果然可以了,看来以后还的多学习学习。

以后在也不能想当然了,但为什么struts2不像spring那样,不用freemarker做视图,为什么还得需要那些Jar文件呢,请高人指点?

你可能感兴趣的:(java,apache,freemarker,struts,sun)