2013-06-17 3 views
-1

У меня возникает следующая ошибка, когда я пытаюсь запустить примеры комплектования отдельно из песочницы.Я использую приложение struts2, но он задает конфигурацию пружины

Ошибка следующим образом:

You might need to add the following to web.xml: 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

Jun 17, 2013 7:17:39 AM org.apache.catalina.core.StandardContext filterStart 
SEVERE: Exception starting filter struts2 
java.lang.NullPointerException 
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:188) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:479) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:450) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:407) 
    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:295) 
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) 
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115) 
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072) 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) 
    at org.apache.catalina.core.StandardService.start(StandardService.java:525) 
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 

web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
    <filter> 
     <filter-name>struts2</filter-name> 
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
     <init-param> 
      <param-name>actionPackages</param-name> 
      <param-value>manning</param-value> 
     </init-param> 
    </filter> 
    <filter-mapping> 
     <filter-name>struts2</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
    <servlet> 
     <servlet-name>anotherServlet</servlet-name> 
     <servlet-class>manning.servlet.AnotherServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>anotherServlet</servlet-name> 
     <url-pattern>/anotherServlet</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
    </welcome-file-list> 
</web-app> 

struts.xml

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
    "http://struts.apache.org/dtds/struts-2.0.dtd"> 

<struts> 

    <!-- 
      For the purposes of the book, we will leave devMode set to true. This 
      allows several things to occur including provision of debugging level information 
      on error pages as well as reloading of various resources with each request. 
    --> 
    <constant name="struts.devMode" value="true" /> 
     <!-- 
      You can define packages directly in this file, but its probably best 
      to modularize the configuration files with separate xml files for each 
      package. Ulitmately its all the same because the include element, seen 
      below, pulls the included configuration document directly in to the 
      primary document. The only thing to consider is that a referenced 
      element must have been declared above the referring element.   
     --> 

     <!-- 
       This is the menu action that will allow the reader to see the different 
       samples actions from the different chapters in a menu format. We declare 
       it here, in the root namespace, because its not really related to any of the 
       specific examples or chapters, its just a kind of utility for the whole 
       application. 
     --> 
     <package name="default" namespace="/" extends="struts-default"> 
      <action name="Menu"> 
       <result>/menu/Menu.jsp</result> 
      </action> 
     </package> 

    <include file="manning/chapterTwo/chapterTwo.xml"/> 
    <include file="manning/chapterThree/chapterThree.xml"/> 
    <include file="manning/chapterThree/objectBacked/chapterThree.xml"/> 
    <include file="manning/chapterThree/modelDriven/chapterThree.xml"/> 
    <include file="manning/chapterFour/chapterFour.xml"/> 
    <include file="manning/chapterFive/chapterFive.xml"/> 
    <include file="manning/chapterSix/chapterSix.xml"/> 
    <include file="manning/chapterSeven/chapterSeven.xml"/> 
    <include file="manning/chapterEight/chapterEight.xml"/> 
    <include file="manning/chapterNine/chapterNine.xml"/> 
    <include file="manning/chapterTen/chapterTen.xml"/> 
    <include file="manning/chapterEleven/chapterEleven.xml"/> 


</struts> 

Почему я получаю сообщение об ошибке. Я удалил некоторые конфигурации относительно пружины в web.xml

+0

вы должны прочитать файл readme.txt, поставляемый вместе с кодом. –

+0

Вы получаете ошибку, потому что вы удалили некоторую конфигурацию Spring в 'web.xml', но приложение все еще пытается использовать Spring. Кроме того, этот фильтр устарел. –

ответ

0

Изменить ваш фильтр ниже

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

И удалить Struts2-весна-плагин. - * баночку из пути к классам, если у вас есть этот сосуд в вашем пути к классам и Донта хотите использовать Spring интеграции с Struts2

Пожалуйста, дайте мне знать, если вы по-прежнему сталкиваются вопрос

Смежные вопросы