appfuse下webwork无法正常调用spring定义Action原因

我们在appfuse中看到xwork直接可以调用spring配置文件action-servlet.xml中的类,那么他们是通过什么方法实现的呢?为什么同样的配置我们的就不可以,原来一切都是因为一个过滤器。

对于上次所遇到关于userAction无法找到的问题经查证如下:

在默认情况下xwork是无法之际在spring中所声明的action类的,如果需要调用则需要在web.xml中添加一个过滤器,代码如下:

   
        securityFilter
        net.sf.acegisecurity.util.FilterChainProxy
   

  
        securityFilter
        /*
   

但是一定要记得,文件net.sf.acegisecurity.util.FilterChainProxy是在acegi-security-x.x.x.jar包里面的,调用前一定要记得放在应用的WEB-INF/lib/目录下才能正常使用。

当系统启动时会自动加载spring配置文件中所声明的类,在appfuse中这一声明是放在action-servlet.xml中的,因此必须将这个文件同其他的applicationContext.xml一起在web.xml中声明为contextConfigLocation的内容,如下:

   
        contextConfigLocation
        /WEB-INF/applicationContext-datasource.xml,/WEB-INF/applicationContext-hibernate.xml,/WEB-INF/applicationContext-service.xml,/WEB-INF/action-servlet.xml
   

在action-servlet.xml中定义如下(这个文件必须符合spring-beans.dtd的规范):

   
   
   
       
   

   
   

然后在xwork.xml中可以如下调用(这个文件需要符合xwork-1.0.dtd的标准):

  
            /
            /listUser.jsp
  

不过配置完成以后新的问题又出现了:

在启动服务的时候出现如下异常,错误的等级为严重,正在解决中……

[mywap] ERROR [main] [/].log(662) | Exception starting filter securityFilter
javax.servlet.ServletException: Bean context must contain at least one bean of t
ype net.sf.acegisecurity.util.FilterChainProxy
        at net.sf.acegisecurity.util.FilterToBeanProxy.doInit(FilterToBeanProxy.
java:200)
        at net.sf.acegisecurity.util.FilterToBeanProxy.init(FilterToBeanProxy.ja
va:137)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:225)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:308)
        at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFi
lterConfig.java:79)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:3502)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
071)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:755)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:73
9)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:886)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:849)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1079)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:437
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:201
0)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
[mywap] ERROR [main] [/].log(662) | Exception starting filter sitemesh
com.opensymphony.module.sitemesh.factory.FactoryException: Cannot construct Fact
ory : com.opensymphony.module.sitemesh.factory.DefaultFactory: java.lang.reflect
.InvocationTargetException
        at com.opensymphony.module.sitemesh.Factory.report(Factory.java:87)
        at com.opensymphony.module.sitemesh.Factory.getInstance(Factory.java:56)

        at com.opensymphony.module.sitemesh.filter.PageFilter.init(PageFilter.ja
va:86)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:225)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:308)
        at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFi
lterConfig.java:79)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:3502)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
071)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:755)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:73
9)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:886)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:849)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1079)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:437
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:201
0)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)

Root cause:
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at com.opensymphony.module.sitemesh.Factory.getInstance(Factory.java:52)

        at com.opensymphony.module.sitemesh.filter.PageFilter.init(PageFilter.ja
va:86)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:225)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:308)
        at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFi
lterConfig.java:79)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:3502)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
071)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:755)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:73
9)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:886)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:849)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1079)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:437
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:201
0)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by: java.lang.IllegalStateException: Cannot load excludes configuration f
ile from jar
        at com.opensymphony.module.sitemesh.factory.DefaultFactory.loadExcludes(
DefaultFactory.java:192)
        at com.opensymphony.module.sitemesh.factory.DefaultFactory.loadConfig(De
faultFactory.java:121)
        at com.opensymphony.module.sitemesh.factory.DefaultFactory.(Defaul
tFactory.java:57)
        ... 33 more

你可能感兴趣的:(appfuse,spring,action,webwork,exception,java,WebWork2,Appfuse)