3

I have a Singleton bean as follows:

@Singleton
@Startup
public class StartUpBean {

    private static final Logger logger = LoggerFactory.getLogger(StartUpBean.class.getName());

    public StartUpBean(){
        logger.info("here");
    }

    @PostConstruct
    public void onStartup(){
        logger.info("hello?");
    }
}

Which is inside a project named control that is referenced as an EJB module in a ear (i am using maven) as follows:

<project...>
    <packaging>ear</packaging>
    ...
    <dependencies>  
        ...
        <dependency>
            <groupId>com.thenaglecode</groupId>
            <artifactId>control</artifactId>
            <version>1.0.0.Pre-Alpha</version>
            <type>ejb</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                ...
                <configuration>
                    <ejbModule>
                        <groupId>com.thenaglecode</groupId>
                        <artifactId>control</artifactId>
                        <bundleFileName>control.jar</bundleFileName>
                        <bundleDir>/</bundleDir>
                    </ejbModule>
                    ...
                </configuration>
            </plugin>
            ...
        </plugins>
    </build>
</project>

I can see the output that is binding the StartUpBean to it's jndi names:

20:23:50,217 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-12) JNDI bindings for session bean named StartUpBean in deployment unit subdeployment "control.jar" of deployment "thenaglecode.ear" are as follows:

    java:global/thenaglecode/control/StartUpBean!com.thenaglecode.control.ejb.StartUpBean
    java:app/control/StartUpBean!com.thenaglecode.control.ejb.StartUpBean
    java:module/StartUpBean!com.thenaglecode.control.ejb.StartUpBean
    java:global/thenaglecode/control/StartUpBean
    java:app/control/StartUpBean
    java:module/StartUpBean

But the code never gets to the post construct method. The break points are never hit even though i can successfully hit other ones in the same run. anybody have a clue what i'm missing? i've seen other similar posts where the solution was to do with the annotations, but my annotations are correct as far as i've read.

EDIT: Startup and Singleton are both from the javax.ejb package.

coderatchet
  • 7,214
  • 15
  • 60
  • 109
  • are you sure that you are using javax.ejb.Singleton and javax.ejb.Startup? – Gabriel Aramburu Nov 18 '13 at 15:07
  • May be your jboss version doesn't support these annotations, take a look at http://stackoverflow.com/questions/2767460/how-do-i-write-a-java-ee-ejb-singleton – Gabriel Aramburu Nov 19 '13 at 01:21
  • They definitely do, as i had them working before, I decided to change the name of the class to StartupBean with lowercase u to test whether there was a caching problem, turns out i'm getting an old version of the StartUpBean class being packaged into the jar. I tried clean and even deleting the entries in .M2 folder but i can't seem to get rid of this phantom class. I'll post back after some more investigation. – coderatchet Nov 19 '13 at 01:40
  • did you manage to fix this? – dazito Dec 02 '15 at 10:49

0 Answers0