NoClassDefFoundException on new InitialContext

Discussions

EJB programming & troubleshooting: NoClassDefFoundException on new InitialContext

  1. NoClassDefFoundException on new InitialContext (4 messages)

    Hi, there is NoClassDefFoundException on new InitialContext when I attempt to call an ejb from an applet using weblogic 8.1, but I'm sure that the Stub.class is included in the jar file. Here is my code:

    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL,"t3://localhost:7001"); // provider url is right
    h.put(Context.SECURITY_PRINCIPAL,"system");
    h.put(Context.SECURITY_CREDENTIALS,"password");
    Context namingContext = new InitialContext(h); // where exception is thrown

    Here is the exception:
    java.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stub
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:431)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:169)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at weblogic.utils.classfile.utils.CodeGenerator.generateClass(CodeGenerator.java:71)
    at weblogic.rmi.internal.StubGenerator.getStubClass(StubGenerator.java:672)
    at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:712)
    at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:699)
    at weblogic.rmi.extensions.StubFactory.getStub(StubFactory.java:76)
    at weblogic.jndi.WLInitialContextFactoryDelegate.newRootNamingNodeStub(WLInitialContextFactoryDelegate.java:486)
    at weblogic.jndi.WLInitialContextFactoryDelegate.newRemoteContext(WLInitialContextFactoryDelegate.java:449)
    at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:345)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:308)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:234)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:135)
  2. You need more than Stub to call EJB. Some of the class in weblogic.jar are required, but I think it's impractical to include it in your applet. Are you using Plugin or default webbrowser JVM like the one in IE? If you need to use applet, access EJB via Servlet or JSP, which in turn access your EJB, get the data and return it to the applet with HTML,XML or Text format.
  3. I think the weblogic8.1 seems to have some NEW bug now. We have a .ear fiel which works just PERFECT in WLS6.1. And we are also geetting the similar Exception like ....read inline:
    we have an .ear file and when we try to deploy it on WLS8.1.......this is what we get ...All i know is that WLS 8.1 has introduced something like : "single J2EEC - EAR compiler, replacing the separate compilers in previous releases" ........is it may be because of this ????

    Read inline:

    ----------------------
    <Jul 16, 2003 11:15:14 AM EDT> <Warning> <HTTP> <BEA-101248> <[ServletContext(id=4316640,name=ABL,context-path=/ABL)]: Deployment descriptor "/WEB-INF/ups-html.tld" is malformed. Check against the DTD: Element type "info" must be declared. (line 334, column 9).>
    <Jul 16, 2003 11:15:14 AM EDT> <Warning> <HTTP> <BEA-101248> <[ServletContext(id=4316640,name=ABL,context-path=/ABL)]: Deployment descriptor "/WEB-INF/ups-html.tld" is malformed. Check against the DTD: The content of element type "tag" must match "(name,tag-class,tei-class?,body-content?,display-name?,small-icon?,large-icon?,description?,variable*,attribute*,example?)". (line 335, column 8).>
    MessageResourcesFactory.createFactory
    java.lang.NoClassDefFoundError: org/apache/struts/util/MessageResourcesFactory
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
            at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:431)
            at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:169)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
            at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:41)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:140)
            at org.apache.struts.util.MessageResourcesFactory.createFactory(MessageResourcesFactory.java:161)
            at org.apache.struts.action.ActionServlet.initApplication(ActionServlet.java:1029)
            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
            at javax.servlet.GenericServlet.init(GenericServlet.java:258)
            at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1070)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
            at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:893)
            at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:842)
            at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:782)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3191)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3136)
            at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3109)
            at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:5559)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:853)
            at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2012)
            at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2053)
            at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2558)
            at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2483)
            at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2308)
            at weblogic.management.deploy.slave.SlaveDeployer.commitUpdate(SlaveDeployer.java:639)
            at weblogic.drs.internal.SlaveCallbackHandler$2.execute(SlaveCallbackHandler.java:35)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    <Jul 16, 2003 11:15:14 AM EDT> <Error> <HTTP> <BEA-101046> <[ServletContext(id=4316640,name=ABL,context-path=/ABL)] service: Cannot load application resources bundle com.ups.dfd.abl.prop.Constants
    java.lang.NullPointerException
            at org.apache.struts.action.ActionServlet.initApplication(ActionServlet.java:1031)
            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
            at javax.servlet.GenericServlet.init(GenericServlet.java:258)
            at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1070)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
            at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:893)
            at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:842)
            at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:782)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3191)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3136)
            at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3109)
            at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:5559)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:853)
            at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2012)
            at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2053)
            at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2558)
            at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2483)
            at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2308)
            at weblogic.management.deploy.slave.SlaveDeployer.commitUpdate(SlaveDeployer.java:639)
            at weblogic.drs.internal.SlaveCallbackHandler$2.execute(SlaveCallbackHandler.java:35)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    >
    <Jul 16, 2003 11:15:14 AM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "service" failed to preload on startup in Web application: "ABL".
    javax.servlet.UnavailableException: Cannot load application resources bundle com.ups.dfd.abl.prop.Constants
            at org.apache.struts.action.ActionServlet.initApplication(ActionServlet.java:1043)
            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
            at javax.servlet.GenericServlet.init(GenericServlet.java:258)
            at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1070)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
            at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:893)
            at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:842)
            at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:782)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3191)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3136)
            at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3109)
            at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:5559)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:853)
            at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2012)
            at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2053)
            at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2558)
            at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2483)
            at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2308)
            at weblogic.management.deploy.slave.SlaveDeployer.commitUpdate(SlaveDeployer.java:639)
            at weblogic.drs.internal.SlaveCallbackHandler$2.execute(SlaveCallbackHandler.java:35)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
    ------------------------------


    thx, sangita
  4. Be aware that when moving up a version, you have to rebuild your ear not only with the new weblogic.jar but also some of the weblogic specific deployment xml files need to be modified to point to the verisn 8 DTD at the top. I had similar problems when moving from 6 to 7. Look at the examples in WebLogic 8 and try to compare deployment descriptor.
  5. Brian wrote: you have to rebuild your ear not only with the new weblogic.jar

    Sangita: what does this mean .....do i need to package the weblogic.jar file in my application.ear file ???

    Brian wrote: but also some of the weblogic specific deployment xml files need to be modified to point to the verisn 8 DTD at the top

    Sangita: agreed !