IBM支持上的多个页面似乎在JAX-RS是否内置于WebSphere 8.5中有所不同.
http://www.ibm.com/developerworks/websphere/techjournal/1305_gunderson/1305_gunderson.html
最新版本的IBM WebSphere Application Server提供对JAX-RS的支持.WebSphere Application Server V8.5支持内置的JAX-RS; 无需额外安装.
要开发JAX-RS应用程序,必须将JAX-RS库添加到类路径定义中.请参阅组装工具的信息,以了解如何在JAX-RS应用程序的类路径中包含库.
在WebSphere 8.5上运行JAX-RS需要做些什么.是否需要web.xml映射?是否需要其他库文件?
我已经在 WAS 8.5 服务器上部署了 JAX-WS Web 服务。启动此应用程序时出现以下错误:-
com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: null
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:432)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
Caused by: java.lang.NullPointerException
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.mappingExists(JerseyServletContainerInitializer.java:331)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithApplication(JerseyServletContainerInitializer.java:272)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartupImpl(JerseyServletContainerInitializer.java:176)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:143)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:613)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:409)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
... 101 more
Run Code Online (Sandbox Code Playgroud)
以下是 web.xml:-
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>My Event</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml
WEB-INF/classes/configs/*.xml
</param-value>
</context-param>
<!--<context-param>
<param-name>contextClass</param-name>
<param-value>com.javaetmoi.core.spring.JBoss5XmlWebApplicationContext</param-value>
</context-param>-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>jerseyServlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.myapp.event.ws.JerseyConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping> …Run Code Online (Sandbox Code Playgroud) 我使用Jersey 2在IBM WebSphere 8.5环境中实现JAR-RS 2.0.
在阅读了这篇文章后,我在Websphere 8中获得了JAX-RS Jersey 2.10支持,我设法让这个工作.
但是,是否可以在WAR中捆绑JAX-RS Jars并部署应用程序而无需创建隔离的共享库?如果这是不可能的,有人可以解释为什么会这样吗?
我理解在库中使用Jars的部署时间优势,但我更愿意将整个应用程序(包括依赖项)构建到单个WAR中.
- 编辑 -
如果更改类加载顺序,您似乎可以从WAR中加载JAX-RS jar.您需要更改顺序以最后加载父类.这可以如下完成;
在管理控制台中:
Applications - > WebSphere enterprise applications - > {your.application} - > Manage Modules - > {your.module}
将类加载器顺序下拉列表更改为:"首先使用本地类加载器加载的类(父类最后一个)".
但是,这表明附加的Stackoverflow文章中缺少某些JVM属性.
任何人都可以对这种情况有所了解吗?