2 Replies Latest reply on Dec 16, 2014 9:33 AM by Stefan Mackovik

    Single instance of Session EJB using EJB 2.1 on JBOSS 5.1.1 EAP

    Stefan Mackovik Newbie



      In our project we're using quite old infrastructure and technlogy - EJB2.1  on a JBOSS 5.1.1 EAP and we don't have the time or budget to upgrade to EJB 3.0 or later.


      I'm using a MDB to process messages form a message queue. This message queue delegates work to a stateless session bean which creates objects in the database. Now I do have concurrency problems when the program runs (hibernate tries to create different Objects with the same primary key/id) and I want to ensure that there can only bw one instance of the EJB, which creates the objects.


      I tried to modify my jboss.xml (which is packaged in my META-INF dir in the ejb-jar) in the following way (changes in bold font)


      <?xml version="1.0"?>

      <jboss xmlns="http://www.jboss.com/xml/ns/javaee"








                  <configuration-name>Singleton Message Driven Bean</configuration-name>



      <configuration-name>Singleton Message Driven Bean</configuration-name>













      but JBOSS seems to ignore this setting. Changing the "Standard Stateless SessionBean" container-configuration in the standardjboss.xml is not an options because I have other EJBs in the same applications which should not be limited to one instance at a time.


      I would be thankful for any tips.



        • 1. Re: Single instance of Session EJB using EJB 2.1 on JBOSS 5.1.1 EAP
          Jay SenSharma Master

          In  "$JBOSS_HOME/docs/dtd/jboss_5_0.dtd"  i see an option to define the "container-configuration"  for individual session beans using jboss.xml something as following to override container provided settings.      I did not  test it though but it can be seen in doc [1].


          <?xml version="1.0" encoding="UTF-8"?>
          <jboss xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee  http://www.jboss.org/j2ee/schema/jboss_5_1.xsd" version="5.1">
                  <configuration-name>Individual SLSB Config</configuration-name>
          <!-- Overriding container configuration -->
                <container-configuration extends="Standard Stateless SessionBean">
                  <container-name>Individual SLSB Config</container-name>


          [1] Container configuration information   Says: 

          By placing a jboss.xml file in the EJB JAR META-INF directory, you can specify either overrides for container configurations in the standardjboss.xml file, or entirely new named container configurations. This provides great flexibility in the configuration of containers.

          • 2. Re: Single instance of Session EJB using EJB 2.1 on JBOSS 5.1.1 EAP
            Stefan Mackovik Newbie

            Thanks, tried that but it seems that "container-configurations" is in the DTD but not in the Schema Definition. Why?