4 Replies Latest reply on Oct 28, 2004 5:59 AM by guowenrui

    startup error in Tomcat 5.0.19

    guowenrui

      Today I want to run jboss cache's test cases under tomcat 5.0.19. I wrote a servlet and in it's doGet() method, I new an instance of the Test, and call it's test methods directly. Unfortunately, I got the following error messages:
      java.lang.NoClassDefFoundError: org/dom4j/Element
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
      at java.lang.Class.getConstructor0(Class.java:1762)
      at java.lang.Class.newInstance0(Class.java:276)
      at java.lang.Class.newInstance(Class.java:259)
      at org.jboss.mx.modelmbean.RequiredModelMBeanInstantiator.instantiate(RequiredModelMBeanInstantiator.java:37)
      at org.jboss.mx.server.MBeanServerImpl.(MBeanServerImpl.java:205)
      at org.jboss.mx.server.MBeanServerBuilderImpl.newMBeanServer(MBeanServerBuilderImpl.java:56)
      at javax.management.MBeanServerFactory$2.run(MBeanServerFactory.java:226)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:221)
      at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:153)
      at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:147)
      at org.apache.commons.modeler.Registry.getMBeanServer(Registry.java:665)
      at org.apache.catalina.mbeans.MBeanUtils.createServer(MBeanUtils.java:1700)
      at org.apache.catalina.mbeans.MBeanUtils.(MBeanUtils.java:160)
      at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.(GlobalResourcesLifecycleListener.java:112)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:274)

      It is so strange because I can run these test as a standard application, but fails in tomcat. Why?

        • 1. Re: startup error in Tomcat 5.0.19

          Can you try to post your sample code? Someone may be aboe to spot what's wrong.

          -Ben

          • 2. Re: startup error in Tomcat 5.0.19
            guowenrui

            The following is my example Servlet Code, the only thing I want to do is config treecache to let it run on tomcat 5.0.19. Is it wrong?

            public class CacheServlet extends HttpServlet {

            private TreeCache cache;

            protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
            perform(request, response);
            }

            private void perform(HttpServletRequest request,
            HttpServletResponse response) {
            try {
            cache.put(Fqn.fromString("/a/b/c/d"), "key", "value");
            } catch (Exception e) {
            e.printStackTrace();
            }
            }

            protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
            perform(request, response);
            }
            public void destroy() {
            cache.stopService();
            cache = null;
            super.destroy();
            }
            public void init(ServletConfig config) throws ServletException {
            try {
            cache = new TreeCache();
            cache.createService();
            cache.startService();
            } catch (Exception e) {
            e.printStackTrace();
            }

            }
            }

            • 3. Re: startup error in Tomcat 5.0.19
              belaban

              No, the code looks okay. I'd suggest however to run it inside JBoss.TC5, and make the TreeCache an *MBean*. This way, all servlets can access it, and it can be independently redeployed.

              Regarding the dom4j: make sure you have the dom4j.jar in the lib dir of TC.

              Bela

              • 4. Re: startup error in Tomcat 5.0.19
                guowenrui

                bela, I have solved the problem. After analysised the error log, it seems failed because of MBean. But I have no time to implement a MBean inside tomcat, so I try to deploy the web application in tomcat 4.1.29, then everything is ok. A strange error, Isn't it?