Hi.
I am having a class problem I thought I might share in the hopes someone has a suggestion for resolving. (I’m at a loss).
I am trying to use the following code to load a class :
Class actionClass = Class.forName("com.abc.actions.message.EditXMLPrologAction");
In total, there are 3 classes from the net/socialchange/doctype package that the EditXMLPrologAction class imports.
import net.socialchange.doctype.Doctype;
import net.socialchange.doctype.DoctypeChangerStream;
import net.socialchange.doctype.DoctypeGenerator;
The above line of code throws the following exception
2012-01-16 15:20:13,899 (15 ) [Thread-2] WARN com.abc.channels.tools.ChannelToolsSchedulingServlet - Exception while creating action class
java.lang.NoClassDefFoundError: net/socialchange/doctype/DoctypeGenerator
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.abc.channels.tools.ChannelToolsSchedulingServlet.runClassCheck(ChannelToolsSchedulingServlet.java:175)
at com.abc.channels.tools.ChannelToolsSchedulingServlet.init(ChannelToolsSchedulingServlet.java:82)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1208)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1108)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3628)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3851)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:294)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:476)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670)
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
at $Proxy41.start(Unknown Source)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:53)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:41)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379)
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:301)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083)
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654)
at org.jboss.system.ServiceController.doChange(ServiceController.java:671)
at org.jboss.system.ServiceController.start(ServiceController.java:443)
at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:189)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:102)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:49)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:63)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083)
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654)
at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679)
at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106)
at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143)
at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151)
at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083)
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654)
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190)
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87)
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215)
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159)
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112)
at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87)
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91)
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132)
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56)
at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827)
at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: net.socialchange.doctype.DoctypeGenerator from BaseClassLoader@15db93c{vfs:///E:/jboss-6.1.0.Final/server/server2/AbcApps/Channels.ear}
at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:480)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 91 more
If I comment out the use of DoctypeGenerator within the EditXMLprolog class, then I get the same error as above, but with the net/socialchange/doctype/DoctypeChangerStream
When I comment out all 3 classes, EditXMLProlog loads successfully.
Sounds like a classpath problem RIGHT??
I thought so too.
I checked classpaths etc and all looks ok.
So I did the following :
In the same class that I try to load up the EditXMLProlog, I try instantiating the DoctypeChangerStream class.
And it works just fine.
Here is the code (with liberal logging statements) -
And here is the output (with the socialchange packages commented out of the EditXMLProlog class) :
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - net.socialchange.doctype.DoctypeGenerator
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 1
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 2
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 3
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - com.abc.actions.message.EditXMLPrologAction
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - Finished finding dodgy Class
And here is the output (with the socialchange packages NOT commented out of the EditXMLProlog class) :
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - net.socialchange.doctype.DoctypeGenerator
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 1
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 2
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - 3
DEBUG com.abc.channels.tools.ChannelToolsSchedulingServlet - JH - finding dodgy Class - com.abc.actions.message.EditXMLPrologAction
WARN com.abc.channels.tools.ChannelToolsSchedulingServlet - Exception while creating action class
java.lang.NoClassDefFoundError: net/socialchange/doctype/DoctypeGenerator
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.abc.channels.tools.ChannelToolsSchedulingServlet.runClassCheck(ChannelToolsSchedulingServlet.java:175)
at com.abc.channels.tools.ChannelToolsSchedulingServlet.init(ChannelToolsSchedulingServlet.java:82)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1208)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1108)
....rest of stack trace as above
So the code is happy to instantiate the DoctypeChangerStream class, and do a forName() on the DoctypeGenerator class.
BUT
Not happy to do a forName on the EditXMLPrologAction when it IMPORTS (and uses) the socialchange package classes.
I would have thought that if it was an issue with not being able to find the net/socialchange/doctype package, then the code would error when trying to instatiate these classes.
Does anyone have any suggestions as to what the issue might be, or some further
testing I could do to narrow down the problem.
Thanks