0

我是初学者。我对resteasy和tomcat有疑问。我的resteasy应用程序在码头上运行正常,但部署在tomcat响应错误代码400上,无法运行服务。这是我的代码: web.xml :

<context-param>
    <param-name>
        org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
    </param-name>
    <param-value>
        /WEB-INF/tiles.xml
    </param-value>
</context-param>

<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml
    </param-value>
</context-param>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>

<listener>
    <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
</listener>

<context-param>
    <param-name>resteasy.server.cache.maxsize</param-name>
    <param-value>10000000</param-value>
</context-param>

<context-param>
    <param-name>resteasy.server.cache.eviction.wakeup.interval</param-name>
    <param-value>60000</param-value>
</context-param>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.cache.server.ServletServerCache</listener-class>
</listener>

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

<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>/web/*</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

应用程序上下文.xml

<import resource="classpath:/com/asus/db/HibernateContext.xml"/>

<!-- Rest -->
<bean id="userRest" class="com.asus.restimpl.UserRestImpl"/>

<!-- Service -->
<!-- DAO -->
<import resource="classpath:/com/asus/dao/DAOFactoryContext.xml"/>

爪哇代码:

@Path("/api/user")
public interface UserRest {

@POST
@Path("/save_user")
public void saveUser(@Suspend(10000) final AsynchronousResponse response, 
        @FormParam("fb_user_id") String userId);
}

public class UserRestImpl extends GenericRest implements UserRest{

public void saveUser(final AsynchronousResponse response, final String userId) {
    cachedExecute(new ResponseRunnable(response) {

        @Override
        protected String execute() {
            return  "hello";
        }

    });
}
   }

我的应用程序并行运行 Struts2 和 resteasy。在码头上运行正常但tomcat只有Struts2,resteasy响应错误代码400

请帮我!!

4

1 回答 1

1

我已修复问题更改

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher</servlet-class>
</servlet>
into
<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>

谢谢大家

于 2013-06-10T03:39:04.500 回答