sree
sree

Reputation: 543

NoClassDefFoundError on class present in jar

I searched a lot, but could not find a solution for my issue. I generated stubs from a wsdl using wsimport, and added to my project. Following is the error I get when I try to initialize a class MyServiceEp from the stub. I identify this as probably a j-boss 7 issue. But I am new to the server and do not know the workaround for this. I tried adding

            <property name="org.jboss.osgi.system.modules.extra">
                javax.xml.ws
            </property>

to my standalone.xml as I read in another forum that this is the workaround for this, but could not get the issue solved..

10:49:23,351 ERROR [org.springframework.web.portlet.DispatcherPortlet] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory
.BeanCreationException: Error creating bean with name 'MyServiceImpl': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/abc/bcd/MyServiceEp
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
:288) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120) [spring-beans
-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) [spring-beans-
3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at 
].................................
..............................
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
            at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
    Caused by: java.lang.NoClassDefFoundError: org/abc/bcd/MyServiceEp
            at org.xx.portal.ws.client.MyServiceImpl.setMyClient(MyServiceImpl.java:37) [classes:]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_25]
            at 


      ... 53 more

I am using Liferay 6.2 - jboss 7.1.1 final bundled version and use spring MVC. The NoClassDefFound error occurs for an auto generated class in the stub. I will post more details if required.

Update

I run the server with verbose:class and got the following error as well..

12:31:00,501 WARN  [org.jboss.modules] (MSC service thread 1-4) Failed to define class gov.or.hix.wsdl.ee.individualcaseservice.IndividualCaseServiceEp in Modul
e "deployment.My-Portlet-1.0.0.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/abc/bcd/MyServiceEp (Module "deployment.My-Portlet-1.0.0.war:main" from Service Module Loader)
        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.Module.loadModuleClass(Module.java:517) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
        at 
..................................
................................
com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54) [portal-service.jar:]
        at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116) [portal-service.jar:]
        at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
        at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
Caused by: java.lang.NoClassDefFoundError: javax/xml/ws/Service
        at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_25]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:792) [rt.jar:1.7.0_25]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_25]
        at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391) [jboss-modules.jar:1.1.1.GA]
        ... 70 more
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.Service from [Module "deployment.My-Portlet-1.0.0.war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
        ... 75 more

Upvotes: 0

Views: 5106

Answers (2)

sree
sree

Reputation: 543

I was able to get this solved. It was an issue due to jboss 7. Jboss 7 doesnot have the files for javax.xml.ws.Service and hence the error. I got this resolved by adding the following dependencies to my project.

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.8</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.1.4</version>
    </dependency>

Adding this resolved the java.lang.NoClassDefFoundError: javax/xml/ws/Service error and hence the issue was resolved.

Upvotes: 1

Varun Jain
Varun Jain

Reputation: 1421

You might be using Eclipse IDE. Upon this assumption, try the following steps:

  1. You've got your stubs regarding your web service say in the directory webservices. Now Link the source of these file in your project.

Right click you project > Properties > Java Build Path > Locate Source Tab > Click Link Source > Locate webservices's path from the directory structure

  1. Click OK and OK again.

  2. Now try to import the classes regarding your studs.

This will definitely work for you as it worked in my case.

Upvotes: 1

Related Questions