I have a singleton ejb which is getting initialised twice. I have no idea why and it is completly defenting the point in having a singleton bean as far as I can tell. Any help will be appreciated. As you can see I tried to put a static boolean in to prevent the multiple initialisation (not that it should be required) but it made no difference.
Bean:
@Singleton
@Startup
public class DataModelBean implements DataModelBeanLocal {
private static Logger log = Logger.getLogger(DataModelBean.class.getName());
@PostConstruct
public void init(){
log.info(this);
}
}
Log output snippet:
2010-02-17 16:06:13,670 INFO [AutoDeployer :DataModelBean ] com.xxx.xxx.datamodel.DataModelBean@117843d
2010-02-17 16:06:14,233 INFO [AutoDeployer :DataModelBean ] com.xxx.xxx.datamodel.DataModelBean@62b9d3
Is it creating 2 beans!! or is it deploying the app twice?
As an aside I am using glassfish v3, is this mature enough? Should I use v2 or something else? Thoughts?
The following singleton:
And the following servlet:
packaged as a war works as expected when deployed “manually” under GFv3. It also deploys fine and works as expected under NetBeans (the
initCacheis called once only).My only problem is that the deployment fails under Eclipse (GFv3 complains aboutBut outside Eclipse, GFv3 behaves normally, I couldn’t reproduce your issue.eclipseApps/$projectNamenot containing any EJB module, which are however ineclipseApps/$projectName/WEB-INF/classses). Sadly, this seems to be a bug with the GlassFish Eclipse plugin (at least the version I’m using). I don’t see many issues in the issue tracker though… weird because this looks like a big blocking one.Update: I finally got things working under Eclipse and GlassFish v3. I won’t give all the details but the problem is that I somehow failed to get my project directly recognized as a “Dynamic Web Module” 2.5, the version was initially set to 2.3 and I think this had something to do with the deployment error on GFv3. After settings up my project correctly (with a facet set to 2.5), deploying it worked fine. So I just screwed up myself.