3 Replies Latest reply on Oct 31, 2013 2:29 PM by Wolf-Dieter Fink

    Setting timeout method through ejb-jar.xml does not work, while annotation does.

    aqtwrdnr aqtwrdnr Newbie

      Hi,

       

      I have a local Singleton bean:

       

      <local-bean />

      ...

      <session-type>Singleton</session-type>

       

      in which I want a timeout method. This works as expected through annotations:

       

          @Timeout

             void handleTimeout(Timer t)

             {

       

      But if I try to set the timeout method via ejb-jar.xml on the same bean:

       

          <timeout-method>

              <method-name>handleTimeout</method-name>

              <method-params>

                  <method-param>javax.ejb.Timer</method-param>

              </method-params>

          </timeout-method>

       

      JBoss 7.2.0.Final gives me the following error when deploying:

       

      ERROR (2013-10-31 09:28:10,621) (MSC service thread 1-12) [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.deployment.subunit."CorporateNews-ear.ear"."ejb-0.0.1-SNAPSHOT.jar".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."CorporateNews-ear.ear"."ejb-0.0.1-SNAPSHOT.jar".PARSE: JBAS018733: Failed to process phase PARSE of subdeployment "ejb-0.0.1-SNAPSHOT.jar" of deployment "CorporateNews-ear.ear"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final.jar:7.2.0.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA.jar:1.0.4.GA]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA.jar:1.0.4.GA]

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_32]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_32]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_32]

      Caused by: java.lang.IllegalStateException: EJB 3.1 FR 4.3.8: Only stateless beans can have timeouts: org.jboss.metadata.ejb.spec.GenericBeanMetaData@ac361db7{AnnouncementBean}

          at org.jboss.metadata.ejb.spec.AbstractGenericBeanMetaData.setTimeoutMethod(AbstractGenericBeanMetaData.java:673)

          at org.jboss.metadata.ejb.parser.spec.SessionBeanMetaDataParser.processElement(SessionBeanMetaDataParser.java:180)

          at org.jboss.metadata.ejb.parser.spec.SessionBean30MetaDataParser.processElement(SessionBean30MetaDataParser.java:127)

          at org.jboss.metadata.ejb.parser.spec.SessionBean31MetaDataParser.processElement(SessionBean31MetaDataParser.java:144)

          at org.jboss.metadata.ejb.parser.spec.SessionBean31MetaDataParser.processElement(SessionBean31MetaDataParser.java:39)

          at org.jboss.metadata.ejb.parser.spec.AbstractMetaDataParser.processElements(AbstractMetaDataParser.java:69)

          at org.jboss.metadata.ejb.parser.spec.SessionBeanMetaDataParser.parse(SessionBeanMetaDataParser.java:83)

          at org.jboss.metadata.ejb.parser.spec.EnterpriseBeansMetaDataParser.processElement(EnterpriseBeansMetaDataParser.java:93)

          at org.jboss.metadata.ejb.parser.spec.EnterpriseBeansMetaDataParser.processElement(EnterpriseBeansMetaDataParser.java:40)

          at org.jboss.metadata.ejb.parser.spec.AbstractMetaDataParser.processElements(AbstractMetaDataParser.java:69)

          at org.jboss.metadata.ejb.parser.spec.EnterpriseBeansMetaDataParser.parse(EnterpriseBeansMetaDataParser.java:75)

          at org.jboss.metadata.ejb.parser.spec.EnterpriseBeansMetaDataParser.parse(EnterpriseBeansMetaDataParser.java:68)

          at org.jboss.metadata.ejb.parser.spec.AbstractEjbJarMetaDataParser.processElement(AbstractEjbJarMetaDataParser.java:112)

          at org.jboss.metadata.ejb.parser.spec.AbstractEjbJarMetaDataParser.processElement(AbstractEjbJarMetaDataParser.java:39)

          at org.jboss.metadata.ejb.parser.spec.AbstractMetaDataParser.processElements(AbstractMetaDataParser.java:69)

          at org.jboss.metadata.ejb.parser.spec.EjbJarMetaDataParser.parseDocument(EjbJarMetaDataParser.java:110)

          at org.jboss.metadata.ejb.parser.spec.EjbJarMetaDataParser.parse(EjbJarMetaDataParser.java:54)

          at org.jboss.as.ejb3.deployment.processors.EjbJarParsingDeploymentUnitProcessor.parseEjbJarXml(EjbJarParsingDeploymentUnitProcessor.java:246)

          at org.jboss.as.ejb3.deployment.processors.EjbJarParsingDeploymentUnitProcessor.deploy(EjbJarParsingDeploymentUnitProcessor.java:120)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final.jar:7.2.0.Final]

          ... 5 more

       

      The relevant code can be found at: https://github.com/jboss/metadata/blob/7.x/ejb/src/main/java/org/jboss/metadata/ejb/spec/AbstractGenericBeanMetaData.java#L670.

      I want all configuration for this bean to be in ejb-jar.xml.

       

      Any ideas?