【发布时间】:2015-07-08 15:47:21
【问题描述】:
我目前正在将使用 Wink 1.1.1 和 Spring 3.1.2 的 Java 应用程序从 WAS 7 迁移到 WAS 8.5.5。我正在尝试使用 WAS 8.5 中提供的本机 Wink 集成,而不是使用我们目前在 WAS 7 中使用的单独的 Wink jar。
我在服务器启动时遇到如下错误:
引起:java.lang.ClassNotFoundException: org.apache.wink.server.internal.registry.ResourceRegistry 在 java.net.URLClassLoader.findClass(URLClassLoader.java:434)
我对此有点困惑,因为据我所知,上面引用的类确实包含在Apache version of the wink jar 中。
然后我想我的问题围绕着 IBM 的 Wink 1.1.1 实现,该实现集成到 WAS 8.5.5 中。这个类不应该在 IBM 的实现中也可用吗?我在这里错过了什么?
这是我的 web.xml 的 sn-p,以防万一:
<servlet>
<servlet-name>IBM Rest Servlet</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
</servlet>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/server/wink-core-context.xml
/WEB-INF/spring/applicationContext-configuration.xml</param-value>
</context-param>
另外,在我的战争中,我的 lib 文件夹中只有 wink-spring-support-1.1.1-incubating.jar。没有其他的眨眼罐。
这是我的 applicationContext-configuration.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">
<context:annotation-config />
<bean class="org.apache.wink.spring.Registrar">
<property name="classes">
<set value-type="java.lang.Class">
</set>
</property>
<property name="instances">
<set>
<ref local="someResource" />
<!-- ... -->
</set>
</property>
</bean>
<!-- Providers -->
<bean id="jaxbProvider" class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" >
<property name="mapper" ref="jacksonObjectMapper"/>
</bean>
<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" >
<property name="annotationIntrospector" ref="jacksonAnnotationIntrospector"></property>
</bean>
<bean id="jacksonAnnotationIntrospector" class="org.codehaus.jackson.map.AnnotationIntrospector$Pair" >
<constructor-arg ref="primaryAnnotationIntrospector" />
<constructor-arg ref="secondaryAnnotationIntrospector" />
</bean>
<bean id="primaryAnnotationIntrospector" class="org.codehaus.jackson.xc.JaxbAnnotationIntrospector" />
<bean id="secondaryAnnotationIntrospector" class="org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector" />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="properties" ref="allProperties"/>
</bean>
<bean id="allProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath*:/META-INF/${Environment}-environment.properties</value>
</list>
</property>
</bean>
<import resource="applicationContext-otherFile.xml"/>
</beans>
类路径上的 Spring jars:
spring-jdbc-3.1.1.RELEASE.jar
spring-test-3.1.2.RELEASE.jar
spring-context-3.1.2.RELEASE.jar
spring-beans-3.1.2.RELEASE.jar
spring-core-3.1.2.RELEASE.jar
spring-tx-3.1.1.RELEASE.jar
spring-web-3.1.2.RELEASE.jar
spring-asm-3.1.2.RELEASE.jar
spring-aop-3.1.2.RELEASE.jar
spring-expression-3.1.2.RELEASE.jar
我已尝试在 EnterpriseApplications > WebAppName >> 类加载器中找到的两个类加载器设置(类加载器顺序和 WAR 类加载器策略)的所有 4 种可能组合,但结果相同。
感谢您的帮助!
【问题讨论】:
-
你的 RestfulResource 类和 Application 子类是否被打包在了战争中?即在
/ 里面/WEB-INF/classes/ -
是的。正如预期的那样,一切都在 WEB-INF/classes 中。
-
你能分享一下“applicationContext-configuration.xml”吗?
-
出于测试目的,从 WAS_HOME/plugins 文件夹中复制 com.ibm.ws.prereq.jaxrs.jar 和 com.ibm.ws.prereq.jackson.jar 并将其共享库引用到您的应用程序,然后重新启动服务器。
-
我在上面的问题中添加了 applicationContext-configuration.xml。另外,我确实有一个指向 WAS_HOME/plugins 文件夹的共享库引用。作为附加说明,我将 MyEclipse 设置为不在我的 war 文件中的 WEB-INF/lib 中包含这些 jar。你想让我在我的 WEB-INF/lib 中包含这 2 个罐子吗?
标签: java spring web.xml websphere-8 apache-wink