1

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!

risingTide
  • 1,754
  • 7
  • 31
  • 60
  • Are your RestfulResource classes and Application subclass packaged inside the war? i.e inside //WEB-INF/classes/ – Prerak Tiwari Jul 08 '15 at 16:16
  • Yes. Everything is in the WEB-INF/classes as expected. – risingTide Jul 08 '15 at 16:22
  • can you share "applicationContext-configuration.xml" ? – Prerak Tiwari Jul 08 '15 at 18:50
  • For testing purpose, copy com.ibm.ws.prereq.jaxrs.jar and com.ibm.ws.prereq.jackson.jar from WAS_HOME/plugins folder and make a shared library reference of it into your application and then restart the server. – Prerak Tiwari Jul 08 '15 at 19:03
  • I added the applicationContext-configuration.xml to my question above. Also, I do indeed have a shared library reference that points to the WAS_HOME/plugins folder already. As an additional note, I have MyEclipse set to NOT include those jars in the WEB-INF/lib in my war file. Do you want me to INCLUDE those 2 jars in my WEB-INF/lib? – risingTide Jul 08 '15 at 19:30
  • I tried including the com.ibm.ws.prereq.jaxrs.jar and com.ibm.ws.prereq.jackson.jar specifically in my WEB-INF/lib folder just to see what happens and I get a different error on startup: _Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.apache.wink.server.internal.registry.ResourceRegistry] to required type [org.apache.wink.server.internal.registry.ResourceRegistry] for property 'resourceRegistry': no matching editors or conversion strategy found_ – risingTide Jul 09 '15 at 14:14
  • can you try adding it to shared library and then try again? also remove those 2 jars from web-inf/lib folder. – Prerak Tiwari Jul 09 '15 at 14:27
  • I had those two in a shared library before and they weren't being added to the WEB-INF/lib at that time. I have the entire WAS_HOME/plugins folder as a shared library actually. – risingTide Jul 09 '15 at 14:31
  • No, I mean with try only with just those two jars in your shared library. – Prerak Tiwari Jul 09 '15 at 14:35
  • Ok, I tried it with just the two jars in the shared library, having removed them from the bigger "plugins" library. I receive the same error about the "_no matching editors or conversion strategy found_" I posted a few comments up. – risingTide Jul 09 '15 at 15:08
  • by any change are you able to resolve it? – Prerak Tiwari Jul 14 '15 at 14:29

2 Answers2

1

I have battled many ClassNotFoundExceptions in my time with websphere, and from my experience many of them can be solved by changing websphere classloaders to PARENT_LAST. This allows your application to load all of the jars that you packaged with the application before websphere tries to load the jars contained in the websphere JRE.

  • Hmm...I tried that, but then I get this error on server startup instead: com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: _[Servlet Error]-[Failed to load listener: org.springframework.web.context.request.RequestContextListener]: java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener at java.beans.Beans.instantiate(Beans.java:195)_ Not sure if that really moved me forward or not.. – risingTide Jul 08 '15 at 16:44
  • Are you using maven to manage your dependencies or are you manually adding the jars to the project? – William Eddy Jul 08 '15 at 18:44
  • Unfortunately, (_sigh_) my company does not allow Maven at this time so I have manage the jars manually. – risingTide Jul 08 '15 at 18:56
  • Have you tried using a newer version of the wink-spring-support? Also, verify that you have all of the transitive dependencies required for that jar as well. – William Eddy Jul 08 '15 at 19:26
  • Since the IBM wink-integrated version is using Wink 1.1.1 I included the wink-spring-support 1.1.1. Would it matter negatively if I used a different version? Also, on a related note, I will add the Spring jars included on my classpath in my post above for completeness. But yes, I have verified all the transitive dependencies are there to the best of my knowledge. – risingTide Jul 08 '15 at 19:36
  • I tried using the wing-spring-support-1.4.jar but it didn't make a difference. – risingTide Jul 09 '15 at 13:37
1

The problem which I can think of is the "ResourceRegistry" class is getting accessed from the class which is inside EAR instead of WAR. The scope of Wink Classes is restricted to WAR and my guess is the application is trying to access it from outside the WAR that's why you are getting ClassNotFoundException for mentioned class.

Prerak Tiwari
  • 3,436
  • 4
  • 34
  • 64
  • And there is no way around this? I can't switch to PARENT_LAST so I tried a bunch of different stuff (fat war and skinny war with wink-spring-support and spring-web still in the war) but to no avail. Any ideas? – pjanssen Sep 09 '15 at 14:36
  • You can try adding the required jar as a shared reference library – Prerak Tiwari Sep 09 '15 at 15:01