Uploaded image for project: 'JBoss Metadata'
  1. JBoss Metadata
  2. JBMETA-350

Merging entity bean metadata yields ClassCastException

XMLWordPrintable

    • Hide

      Either run unit test EntityBeanMetaDataMergingTestCase, or deploy an application to JBoss AS containing both jbosscmp-jdbc.xml and jboss-ejb3.xml files.

      Show
      Either run unit test EntityBeanMetaDataMergingTestCase, or deploy an application to JBoss AS containing both jbosscmp-jdbc.xml and jboss-ejb3.xml files.

      I have encountered this issue on JBoss AS 7.1.0.CR1b with an application containing EJB2 entity beans. When deploying the beans I get the following ClassCastException:

      13:04:55,292 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."myapp.ear"."myapplication-ejb-1.3-SNAPSHOT.jar".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."myapp.ear"."myapplication-ejb-1.3-SNAPSHOT.jar".PARSE: Failed to process phase PARSE of subdeployment "myapplication-ejb-1.3-SNAPSHOT.jar" of deployment "myapp.ear"
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.1.0.CR1b.jar:7.1.0.CR1b]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
      at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
      Caused by: java.lang.ClassCastException: org.jboss.metadata.ejb.spec.EntityBeanMetaData cannot be cast to org.jboss.metadata.ejb.jboss.ejb3.JBossGenericBeanMetaData
      at org.jboss.metadata.ejb.spec.EntityBeanMetaData.merge(EntityBeanMetaData.java:121)
      at org.jboss.metadata.ejb.spec.EntityBeanMetaData.createMerged(EntityBeanMetaData.java:112)
      at org.jboss.metadata.ejb.spec.EntityBeanMetaData.createMerged(EntityBeanMetaData.java:32)
      at org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData.merge(EnterpriseBeansMetaData.java:81)
      at org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData.createMerged(EnterpriseBeansMetaData.java:52)
      at org.jboss.metadata.ejb.spec.EjbJarMetaData.merge(EjbJarMetaData.java:175)
      at org.jboss.metadata.ejb.spec.EjbJarMetaData.createMerged(EjbJarMetaData.java:668)
      at org.jboss.as.ejb3.deployment.processors.EjbJarParsingDeploymentUnitProcessor.deploy(EjbJarParsingDeploymentUnitProcessor.java:124)
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.1.0.CR1b.jar:7.1.0.CR1b]
      ... 5 more

      I have recreated the exception in isolation in a unit test, which can be pulled from my fork of jboss-metadata at github https://github.com/runeflobakk/metadata.

      I have identified the bug to be a faulty cast at EntityBeanMetaData.java:121 (well, obviously). The immediate cause of this is the call to EntityBeanMetaData#merge at EntityBeanMetaData.java:112, passing this as argument for the AbstractEnterpriseBeanMetaData or parameter. or is then being cast to JBossGenericBeanMetaData, which is an entirely different type than EntityBeanMetaData. The code simply cannot possibly run.

      I can change the cast to EntityBeanMetaData and the code still compiles, but I do not know if this has any other implications, e.g. if the public merge method is being called by any others which actually do pass an JBossGenericBeanMetaData.

              rhn-engineering-cdewolf Carlo de Wolf
              rflob Rune Flobakk (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: