4 Replies Latest reply on Apr 15, 2010 10:38 PM by Wang Alex

    ClassCastException when deploy EJB2 in JBoss5.0.1 but works well when in Jboss4

    Wang Alex Newbie


         We have a product base on EJB2, and deployed in Jboss 4.0.2 before. All things go well.

         After I change my JBoss to 5.0.1.GA, I got the strange exception: ClassCastException

      The Exception Stack
      10:20:59,782 INFO  [NativeServerConfig] JBoss Web Services - Stack Native Core
      "server.out" 487L, 46297C
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              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:264)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
              at com.nokia.warlock.utils.deployer.AppDeployer.deployModule(AppDeployer.java:324)
              at com.nokia.warlock.utils.deployer.AppDeployer.startService(AppDeployer.java:292)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:376)
              at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:269)
              at com.nokia.warlock.utils.jmx.StandardMBeanSupport.start(StandardMBeanSupport.java:67)
              ... 62 more
      Caused by: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

      *** DEPLOYMENTS IN ERROR: Name -> Error

      vfszip:/usr/nbg/system/modules/Configuration.jar/ -> org.jboss.deployers.spi.DeploymentException: Error during deploy: vfszip:/usr/nbg/system/modules/Configuration.jar/

        Deployment "vfszip:/usr/nbg/system/modules/Configuration.jar/" is in error due to the following reason(s): java.lang.ClassCastException: org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData cannot be cast to org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData

              at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
              at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
              at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
              at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:862)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:833)
              ... 77 more

      And here is the piece of ejb-jar.xml:

      in ejb-jar.xml

      And here is the code shows how "AppDeployer"  deploy jar files:

      code pieces

      * Created on 02.03.2005
      package com.nokia.warlock.utils.deployer;
      import ......;
      public final class AppDeployer
          extends StandardMBeanSupport
          implements AppDeployerMBean

          final static String DEPLOY_METHOD_NAME = "deploy";
          final static String[] DEPLOY_METHOD_SIGNATURE = {"java.lang.String"};
          private String m_modulesUrl = "";
          private final List<String> m_modules = new LinkedList<String>();
          public void setModules(String modules)
              StringTokenizer st = new StringTokenizer(modules, ",");
              while (st.hasMoreTokens())

          public void setMainDeployer(ObjectName md)
              m_mainDeployer = md;

          protected void startService()
              throws Exception
              // initializing

              // starting application components
                  if (m_mainDeployer == null)
                      throw new Exception("MainDeployer is not set!");
                  for (String m : m_modules)
                  m_logger.log(Level.INFO, "Application started");
              catch (Exception ex)

          private void deployModule(String module)        throws Exception
              log.info("Deploying application module " + module);
              m_logger.log(m_deploymentLogLevel, "Deploying application module {0}", module);
                  server.invoke(m_mainDeployer, DEPLOY_METHOD_NAME,
                                new Object[]{m_modulesUrl + module},
                  log.debug("Deployed application module " + module);
                  m_logger.log(m_deploymentLogLevel, "Deployed application module {0}",
              catch (MBeanException mbex)

      The parameters and Jboss.service:MainDeployer can got correctly, but I always got the classCastException for EntityBean. I serached in google and do not found any likely issues.

      Anybody can give a hand? Thanks a lot!

        • 1. Re: ClassCastException when deploy EJB2 in JBoss5.0.1 but works well when in Jboss4
          Wang Alex Newbie

          (I don't know why the pasted part of ejb-jar.xml was lost after I click 'post')

          Here is part of content in ejb-jar.xml which in the jar file which we deployed:

          <?xml version="1.0"?>

          <!DOCTYPE ejb-jar PUBLIC
              "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"


                  <!-- Configuration Entity: BMP version -->
                  <!-- Configuration Version Entity: BMP version -->
                  <entity ........

          • 3. Re: ClassCastException when deploy EJB2 in JBoss5.0.1 but works well when in Jboss4
            Baiqing Wang Newbie

            Hi Alex,


            I have the same problem. Can you share with us how did you fix the problem?



            • 4. Re: ClassCastException when deploy EJB2 in JBoss5.0.1 but works well when in Jboss4
              Wang Alex Newbie

              For my case, it's like this:

                 First, you have a "ejb-jar.xml" in your *AR file, and, for JBoss, you should have a "jboss.xml" also for application server.

                 And , according to the EJB specs, the file "ejb-jar.xml" is for description of program, "jboss.xml" is for deployment

                 In JBoss4, Entity-Bean and Session-Bean can define as "<session>", it will work without error even you are deploying a entity-bean.

                 In JBoss5, you must define <entity> for entity-bean in jboss.xml.


                 So the cause for my case is a "jboss.xml" mistake. I write "<session>" for both session-bean and entity-bean in "jboss.xml".