I'm currently migrating a Java app using Wink 1.1.1 and Spring 3.1.2 from WAS 7 to WAS 8.5.5. I'm trying to use the native Wink-integration that is available in WAS 8.5 instead of using the separate Wink jars we currently have now with WAS 7.
I'm getting an error on server startup that looks like this:
Caused by: java.lang.ClassNotFoundException: org.apache.wink.server.internal.registry.ResourceRegistry at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
I'm a little confused by this because the class referenced above is indeed included in the Apache version of the wink jar from what I can tell.
I suppose my question then surrounds IBM's implementation of Wink 1.1.1 that is integrated into WAS 8.5.5. Shouldn't this class be available in IBM's implementation as well? What am I missing here?
Here's a snippet of my web.xml in case it helps:
<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>
Also, I only have the wink-spring-support-1.1.1-incubating.jar in my lib folder in my war. No other wink jars are there.
And here's my 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 on classpath:
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
I have tried all 4 possible combinations of the two classloader settings (Class loader order & WAR class loader policy) found at EnterpriseApplications > WebAppName >> Class loader, but the same error results.
Thanks for your help!
答案 0 :(得分:1)
我在使用websphere的过程中与许多ClassNotFoundExceptions作斗争,根据我的经验,通过将websphere类加载器更改为PARENT_LAST可以解决其中许多问题。这允许您的应用程序在websphere尝试加载websphere JRE中包含的jar之前加载您随应用程序打包的所有jar。
答案 1 :(得分:1)
我能想到的问题是&#34; ResourceRegistry
&#34;从EAR内部的类而不是WAR中访问类。 Wink Classes的范围仅限于WAR,我的猜测是应用程序试图从WAR外部访问它,这就是为什么你为所提到的类获取ClassNotFoundException的原因。