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

      Hi,

         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/


      DEPLOYMENTS IN ERROR:
        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, ",");
              m_modules.clear();
              while (st.hasMoreTokens())
              {
                  m_modules.add(st.nextToken().trim());
              }
          }

      ......
          public void setMainDeployer(ObjectName md)
          {
              m_mainDeployer = md;
          }

          protected void startService()
              throws Exception
          {
              super.startService();
              // initializing

      ......
              // starting application components
              try
              {
                  if (m_mainDeployer == null)
                  {
                      throw new Exception("MainDeployer is not set!");
                  }
                  for (String m : m_modules)
                  {
                      deployModule(m);
                  }
                  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);
              try
              {
                  server.invoke(m_mainDeployer, DEPLOY_METHOD_NAME,
                                new Object[]{m_modulesUrl + module},
                                DEPLOY_METHOD_SIGNATURE);
                  log.debug("Deployed application module " + module);
                  m_logger.log(m_deploymentLogLevel, "Deployed application module {0}",
                               module);
              }
              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"
              "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

          <ejb-jar>

              <enterprise-beans>
                  <!-- Configuration Entity: BMP version -->
                  <entity>       
                      <ejb-name>ConfigurationEntityBean</ejb-name>
                      <local-home>com.nokia.warlock.configuration.persistance.ConfigurationEntityHome</local-home>
                      <local>com.nokia.warlock.configuration.persistance.ConfigurationEntity</local>
                      <ejb-class>com.nokia.warlock.configuration.impl.ConfigurationEntityBeanBMP</ejb-class>
                      <persistence-type>Bean</persistence-type>
                      <prim-key-class>java.lang.String</prim-key-class>
                      <reentrant>False</reentrant>
                      <env-entry>
                          <env-entry-name>logger/nameSpace</env-entry-name>
                          <env-entry-type>java.lang.String</env-entry-type>
                          <env-entry-value>NBG.Configuration.ConfigurationEntity</env-entry-value>
                      </env-entry>
                      <env-entry>
                          <env-entry-name>logger/logLevel</env-entry-name>
                          <env-entry-type>java.lang.String</env-entry-type>
                          <env-entry-value>ALL</env-entry-value>
                      </env-entry>
                      <env-entry>
                          <env-entry-name>persistance/tableName</env-entry-name>
                          <env-entry-type>java.lang.String</env-entry-type>
                          <env-entry-value>CONFIG</env-entry-value>
                      </env-entry>
                      <resource-ref>
                          <res-ref-name>jdbc/OracleDB</res-ref-name>
                          <res-type>javax.sql.DataSource</res-type>
                          <res-auth>Container</res-auth>
                      </resource-ref>
                  </entity>
                  <!-- 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?

             

            Thanks,

            • 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".