struts2约定插件在EAR中不起作用,但在WAR中工作正常

时间:2014-03-17 23:06:54

标签: java struts2 struts2-convention-plugin

当我部署WAR文件时,约定插件能够使用注释找到操作类,但它无法在EAR中找到操作。

  • glassfish- v2.1.1
  • struts2的-公约-插件-2.3.15.3

struts.xml文件的内容:

<struts>
    <constant name="struts.devMode" value="true" />
    <constant name="struts.convention.action.mapAllMatches" value="true"/>
    <constant name="struts.convention.package.locators" value="webservice"/>
    <constant name="struts.convention.action.suffix" value="Controller"/>
    <constant name="struts.convention.default.parent.package" value="rest-default"/>

    <constant name="struts.convention.exclude.parentClassLoader" value="true" />
    <constant name="struts.convention.action.fileProtocols" value="jar,zip" />

    <constant name="struts.convention.action.includeJars" value=".*?/*.*?jar(!/)?"/>    

堆栈跟踪:

There is no Action mapped for namespace / and action name orders. - [unknown location]
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:70)
    org.apache.struts2.rest.RestActionProxyFactory.createActionProxy(RestActionProxyFactory.java:53)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:382)
    com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

动作类:

package com.kw.service.webservice;

import java.util.Collection;

import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;
import org.apache.struts2.convention.annotation.Namespace;

@Results({
    @Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
})
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>,  Validateable{

private Order model = new Order();
private String id;
private Collection<Order> list;
private OrdersService ordersService = new OrdersService();

// GET /orders/1
public HttpHeaders show() {
    return new DefaultHttpHeaders("show");
}

// GET /orders
public HttpHeaders index() {
    list = ordersService.getAll();
    return new DefaultHttpHeaders("index")
        .disableCaching();
}
}

0 个答案:

没有答案