gpt4 book ai didi

java - RESTEasy UnavailableException HttpServletDispatcher

转载 作者:行者123 更新时间:2023-11-30 09:44:25 25 4
gpt4 key购买 nike

我搜索并尝试了几个小时来解决这个问题,不幸的是没有成功。

我正在使用 Java 1.6、RESTEasy 2.2.1.GA 和 Jetty 嵌入式服务器来设置网络服务。最初我复制了一个现有的工作项目来设置这个。原来的项目以某种方式起作用,我调整后的副本不起作用。

启动嵌入式服务器后出现以下异常:

这是控制台的内容:

2011-10-27 09:22:51.113::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2011-10-27 09:22:51.141::INFO: jetty-6.0.2
2011-10-27 09:22:51.352::WARN: failed Resteasy
javax.servlet.UnavailableException: org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:78)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:229)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:574)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:128)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:421)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:119)
at org.mortbay.jetty.Server.doStart(Server.java:228)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at com.xtag.locationadapter.webui.EmbeddedServer.main(EmbeddedServer.java:41)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
2011-10-27 09:22:51.398::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@1c5d9084{/admin,file:/Users/workspace/LocationAdapter/webui/target/classes/com/company/locationadapter/webui/webapp/}
javax.servlet.UnavailableException: org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:78)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:229)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:574)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:128)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:421)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:119)
at org.mortbay.jetty.Server.doStart(Server.java:228)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at com.xtag.locationadapter.webui.EmbeddedServer.main(EmbeddedServer.java:41)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
2011-10-27 09:22:51.400::INFO: Started SocketConnector @ 0.0.0.0:8088

这是我的项目结构。请忽略名称 webui 不适合此文件夹的内容。:

   LocationAdapter
- .idea
- .settings
- bin
- webui
|- src
|- main
|- java
|- com.company.locationadapter.communication.rest
|- ResteasyApplication.java
|- com.company.locationadapter.communication.restservices
|- LocationResource.java
|- LocationResourceImpl.java
|- com.company.locationadapter.service
|- LocationService.java
|- LocationServiceImpl.java
|- com.company.locationadapter.webui
|- EmbeddedServer.java
|- resources
|- com.company.locationadapter.webui.webapp
|- dummy.html
|- com.company.locationadapter.webui.webapp.WEB-INF
|- web.xml

我的 ResteasyApplication 类:

public class ResteasyApplication extends Application {

@Override
public Set<Object> getSingletons() {
Set<Object> set = new HashSet<Object>();
set.add(new LocationResourceImpl());
return set;
}

@Override
public Set<Class<?>> getClasses() {
return super.getClasses();
}
}

我的嵌入式服务器类:

public class EmbeddedServer {

private static final String WEBAPP = "com/company/locationadapter/webui/webapp";
private static final String CONTEXT_PATH = "/admin";

public static void main(String[] args) throws Exception {

addSystemProperties();
final Server server = new Server(8088);
final URL warUrl = EmbeddedServer.class.getClassLoader().getResource(WEBAPP);
final String warUrlString = warUrl.toExternalForm();
server.setHandler(new WebAppContext(warUrlString, CONTEXT_PATH));
server.start();
}

protected static void addSystemProperties() {
try {
Properties properties = new Properties(System.getProperties());
String path = System.getProperty("user.properties");
properties.load(new FileInputStream(new File(path)));
System.setProperties(properties);
} catch (IOException e) {
e.printStackTrace();
}
}
}

RESTEasy配置的web.xml:

<web-app>

<display-name>LocationAdapter</display-name>
<description>Company</description>

<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/locationadapter</param-value>
</context-param>

<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.company.locationadapter.communication.rest.ResteasyApplication</param-value>
</init-param>
</servlet>

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

<session-config>
<session-timeout>30</session-timeout>
</session-config>

</web-app>

如果有人对此异常有想法或解决方案,我将不胜感激。如果您需要更多信息,请告诉我。

提前致谢!

最佳答案

问题已解决,异常是由 POM.xml 中的条目引起的,其中工件“resteasy-jaxb-provider”的范围设置为提供

关于java - RESTEasy UnavailableException HttpServletDispatcher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7913295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com