JBoss Community

Re: Using ejb-jar.xml for @Singleton bean

created by Viggo Navarsete in EJB3 - View the full discussion

Did you ever get this to work? I have a Singleton bean like this:

 

@Singleton

public class DummySingleton implements Dummy {

 

 

          public String getHello() {

                    return "Hello Dummy!";

          }

}

 

 

and an interface like this:

 

public interface Dummy {

          public String getHello();

}

 

I've tried this in ejb-jar.xml (everything is packaged into an EAR file):

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

 

 

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.1"

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

                    <enterprise-beans>

        <session>

            <ejb-name>DummySingleton</ejb-name>

            <ejb-class>com.tracetracker.global.aps.DummySingleton</ejb-class>

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

            <init-on-startup>false</init-on-startup>

            <ejb-local-ref>

                <ejb-ref-name>ejb3/hub/DummySingleton</ejb-ref-name>

                <local>com.tracetracker.global.aps.Dummy</local>

             </ejb-local-ref>

        </session>

                    </enterprise-beans>

</ejb-jar>

 

I've also tried to add it to jboss.xml like this:

<session>

     <ejb-name>DummySingleton</ejb-name>

     <local-jndi>ejb3/hub/DummySingleton</local-jndi>

</session>

 

but no matter what I try it will not end up in JNDI bound to ejb3/hub/DummySingleton.

I can have normal session beans, and they will bind to ejb3/hub/xxxxx, but not when it's a singleton.

 

What am I doing wrong?

Reply to this message by going to Community

Start a new discussion in EJB3 at Community