JBoss Community

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

created by jaikiran pai in EJB3 - View the full discussion

Looks like there's a problem merging the xml metadata and the annotations with respect to the @Startup annotation. Use this ejb-jar.xml as a workaround (I have explicitly added the init-on-startup to true in that xml:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar 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"
    version="3.1">

    <enterprise-beans>
        <session>
            <ejb-name>StartupBean</ejb-name>
            <ejb-class>com.example.services.startup.StartupBean</ejb-class>
            <session-type>Singleton</session-type>
            <init-on-startup>true</init-on-startup>
            <ejb-local-ref>
                <ejb-ref-name>ejb/VersionManager</ejb-ref-name>
                <local>com.example.services.version.VersionManager</local>
                <injection-target>
                    <injection-target-class>com.example.services.startup.StartupBean</injection-target-class>
                    <injection-target-name>versionManager</injection-target-name>
                </injection-target>

                <lookup-name>${services.loader}/VersionManagerBean/local</lookup-name>
            </ejb-local-ref>
        </session>
    </enterprise-beans>

</ejb-jar>

 

 

Could you please create a JIRA here https://jira.jboss.org/browse/JBMETA about the @Startup issue and point to this thread?

Reply to this message by going to Community

Start a new discussion in EJB3 at Community