2 Replies Latest reply on Oct 6, 2010 6:34 AM by jaikiran pai

    Singleton bean deployment on jboss 6.0.0.M4

    mojito java Newbie

      hello,i'm facing some problems deploying a singleton bean on JBoss 6.0.0.M4.

      Here is my bean class, my ejb-jar file and jboss.xml (it works fine without the jboss.xml for the singleton bean)

       

      package beaimport javax.ejb.EJB;
      import javax.ejb.Singl
      import javax.ejb.Stapackage beans;

      import javax.ejb.EJB;

      import javax.ejb.Singleton;

      import javax.ejb.Stateless;

      @Singleton(name = "MySingletonBeanClass")

      public class MySingletonBeanClass implements MySingletonBeanClassRemote {

      private int number;

      public int getNumber() {

      return number;

      }

      public void setNumber(int number) {

      this.number = number;

      }

      public MySingletonBeanClass() {         // TODO Auto-generated constructor stub     }

      public String sayHello(String msg){

      number++;

      try {                Thread.sleep(30000);           }

      catch (InterruptedException e)

      {                // TODO Auto-generated catch block                e.printStackTrace();           }

      return msg + number;     }

      }

      @Singleton(name = "MySingletonBeanClass")
      public class MySingletonBeanClass implements MySingletonBeanClassRemote {

       

      ****************************************************

      package beans;

      import javax.ejb.Remote;

       

      @Remote

      public interface MySingletonBeanClassRemote {

      public String sayHello(String msg);

      public int getNumber();

      }

      private int number;
      public int getNumber() {
      return number;
      }
      public void setNumber(int number) {
      this.number = number;
      }
      public MySingletonBeanClass() {
              // TODO Auto-generated constructor stub
          }
         
         
          public String sayHello(String msg){
               number++;
               try {
      Thread.sleep(30000);
      } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
               return msg + number;
          }
      }

      ****************************************************

      <?xml version="1.0" encoding="UTF-8"?>

      <ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

        <display-name>MySingletonProject14</display-name>

        <enterprise-beans>

        <session >

        <ejb-name>MySingletonBeanClass</ejb-name>

        <ejb-class>beans.MySingletonBeanClass</ejb-class>

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

        </enterprise-beans>

      </ejb-jar>

      *************************************************

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss>

      <enterprise-beans>

      <session>

      <ejb-name>MySingletonBeanClass</ejb-name>

      <jndi-name>java:comp/env/ejb/MySingletonBean/MySingletonBeanClassRemote</jndi-name>

      </session>

      </enterprise-beans>

      </jboss>

      **************************************************
      "jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3' ** -> org.jboss.deployers.client.spi.IncompleteDeploymentException:Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): DEPLOYMENTS MISSING DEPENDENCIES: Deployment "auto-timer-initializer:vfs:///D:/JBoss6/jboss-6.0.0.20100721-M4/server/default/deploy/MySingletoProjectEAR45.ear/MySingletonProject14.jar/$MySingletonBeanClass" is missing the following dependencies: Dependency "jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3' **") Deployment "jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3_endpoint" is missing the following dependencies: Dependency "jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3' **") DEPLOYMENTS IN ERROR: Deployment "jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.j2ee:ear=MySingletoProjectEAR45.ear,jar=MySingletonProject14.jar,name=MySingletonBeanClass,service=EJB3' **

      changing the bean type to be stateless in different files makes things work. i don't know what i'm missing here
      Thank you for ur help

        • 1. Re: Singleton bean deployment on jboss 6.0.0.M4
          jaikiran pai Master

          mojito java wrote:

           


           

           

          <?xml version="1.0" encoding="UTF-8"?>

          <jboss>

          <enterprise-beans>

          <session>

          <ejb-name>MySingletonBeanClass</ejb-name>

          <jndi-name>java:comp/env/ejb/MySingletonBean/MySingletonBeanClassRemote</jndi-name>

          </session>

          </enterprise-beans>

          </jboss>


          The JNDI name in the jboss.xml is incorrect. You can't add a java:comp/env jndi name there. Instead change your jboss.xml to use:

           

          <?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="3.0">
                  
                  <enterprise-beans>
                      <session>
                          <ejb-name>MySingletonBeanClass</ejb-name>
                          <jndi-name>MySingletonBean/MySingletonBeanClassRemote</jndi-name>
                      </session>
                  </enterprise-beans>
          </jboss>     
          

           

          Also, you don't need that ejb-jar.xml, if you are using annotations on the bean. Infact, you can even use (JBoss specific) annotations if you want to override the default JNDI name.

          1 of 1 people found this helpful
          • 2. Re: Singleton bean deployment on jboss 6.0.0.M4
            jaikiran pai Master

            And yes, if fixing the jboss.xml doesn't solve the issue, then please post the console logs including any exception stacktrace or error message. Please do not use different font size or colour while posting those error messages. Those error messages are already difficult enough to understand.