7 Replies Latest reply on Jun 24, 2002 5:48 AM by Mart van Ineveld

    Classloader issue: java.lang.ObjectMissing no-arg constructo

    Ken Jennings Newbie

      I'm getting an error in JBoss 3.0 when my servlet tries to get a reference to the home interface of my session bean. I do this in the typical way:
      Object ref = ic.lookup("java:comp/env/ejb/CourseAccessHome");

      This worked fine in JBoss2.4.4. Porting it over to JBoss3.0 beta, however, I removed the EJB classes from the WEB-INF directory of my servlet's .war file in order to take advantage of the new UnifiedClassLoader in 3.0. However, the context lookup above now gives me the following:

      2002-04-16 14:26:51,813 ERROR [Default] javax.naming.CommunicationException. Root exception is
      2002-04-16 14:26:51,814 ERROR [Default] java.io.InvalidClassException: java.lang.ObjectMissing no-arg constructor for class
      2002-04-16 14:26:51,814 ERROR [Default] at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1350)
      2002-04-16 14:26:51,815 ERROR [Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
      2002-04-16 14:26:51,816 ERROR [Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
      2002-04-16 14:26:51,816 ERROR [Default] at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
      2002-04-16 14:26:51,817 ERROR [Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:369)
      2002-04-16 14:26:51,817 ERROR [Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      2002-04-16 14:26:51,818 ERROR [Default] at javax.naming.InitialContext.lookup(InitialContext.java:350)
      2002-04-16 14:26:51,819 ERROR [Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:437)
      2002-04-16 14:26:51,819 ERROR [Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:473)
      2002-04-16 14:26:51,820 ERROR [Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      2002-04-16 14:26:51,820 ERROR [Default] at javax.naming.InitialContext.lookup(InitialContext.java:350)
      2002-04-16 14:26:51,821 ERROR [Default] at com.comphealth.training.CourseServlet.createCourseAccess(CourseServlet.java:97)

      Looks like a marshalling problem with Serializable, I guess, except I don't know what the problem might be. Repeated attempts to hit the servlet result in a different error:

      2002-04-16 14:28:13,977 ERROR [org.jboss.web.catalina.EmbeddedCatalinaServiceSX] ----- Root Cause -----
      at java.io.ObjectInputStream.allocateNewObject(Native Method)
      at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1347)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:369)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:437)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:473)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at com.comphealth.training.CourseServlet.createCourseAccess(CourseServlet.java:97)

      This is similar to a problem reported in the forums here:
      that as far as I can tell was never solved.

      I can't think of anything weird in my configuration...this is JBoss 3.0 beta straight off the site. This is also EJB code that worked flawlessly before I ported it over from JBoss 2.4.4.


        • 1. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
          Adrian Brock Master


          There was a post on jboss-user today saying this works
          with jboss-3.0.0RC1-tomcat-4.0.3. I haven't had time
          to try this myself.

          If that doesn't work perhaps you can give some more
          information about the packaging, e.g. ear or jar/war,
          the java:comp/env config from web.xml and the ejb-jar.xml
          for the CourseAccess bean.


          • 2. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
            Adrian Brock Master


            I've seen some follow ups of some reported problems.
            I noticed from looking in the dev forum
            that a test has been added for accessing an entity
            bean from a servlet. So maybe there are still problems?


            • 3. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
              Adrian Brock Master

              Another follow up.

              Apparently the accessing an Entity works from a servlet.

              You could try comparing your application with the one
              from the testsuite. You can find a link to the
              testsuite in the where can get an example thread in the
              FAQ forum.

              I wish I had more time to verify this myself.


              • 4. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
                Ken Jennings Newbie

                I haven't dug into CVS yet, but I have reproduced my error with a simple, HelloWorld-type servlet/session bean combination. The "Missing no-arg constructor" error recurs whether I deploy a war or a jar/ear.

                My servlet is just
                public class TestServlet extends HttpServlet

                public void doGet(HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException
                InitialContext ic = new InitialContext();
                Object ref = ic.lookup("java:comp/env/ejb/SessionHome");
                catch (Exception ex)
                System.out.println("Servlet exception.");
                and the bean lookup line returns the naming exception.

                My web.xml:
                <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

                Training WAR file



                My jboss-web.xml:
                <ejb-ref> <ejb-ref-name>ejb/SessionHome</ejb-ref-name>

                My ejb-jar.xml:
                Session bean



                and my bean's jboss.xml:




                Hopefully that will give some background. Next stop, the testsuite. Thanks for the pointers, Adrian.


                • 5. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
                  Ken Jennings Newbie

                  One more note: this error still occurs in JBoss3.0.0_RC1. I can only assume that more people haven't reported it because they package their EJB classes in WEB-INF, as was acceptable in JBoss 2.4, and which doesn't cause this lookup problem?

                  Adrian, if you're reading--any idea which specific test in the testsuite is the one that "proves" that bean access from a servlet works?


                  • 6. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
                    Ken Jennings Newbie

                    Solved this after a few days of frustration: I had unnecessary jars in my .ear's lib directory that were stymieing the class loader ("servlet.jar" and "jboss-j2ee.ear," I think). Oops. Accidentally deploying these jars in the .ear file worked in JBoss 2.4, funnily enough, but no longer.


                    • 7. Re: Classloader issue: java.lang.ObjectMissing no-arg constr
                      Mart van Ineveld Newbie

                      I am running into exactly the same serialization problem with version jboss 2.4.4. Changing the contents of the .ear file or the classpath (in manifest.mf or wherever) did not help me. I can deploy and run the same application under JBoss 2.4.1-Tomcat without any problems. As soon as I try the same deployed .ear (with session beans and war files) on JBoss2.4.4-Tomcat4.0.1 i get the mentioned error. Trying to create the session bean for a second time generates another error (as mentioned in this thread):
                      at java.io.ObjectInputStream.allocateNewObject(Native Method)

                      A very frustrating bug somewhere. If anybody has a clue?????!