Page 1 of 1

bean hibernateExporter defined twice in 1.5.0.M4

Posted: Fri Nov 11, 2011 12:03 pm
by Theo Schumacher

I'am currently evaluating Broadleafcommerce for a to be developed webshop application. Our own developments are done with MySQL, hibernate, Spring, GraniteDS and Flexbuilder. Occasionally we use JSF2.0 facelets with Icefaces libraries as well. We deploy on glassfish 3.1 app server. We use Netbeans 6.9 IDE for development and testing (in place deployment on glassfish).

I downloaded which contains Broadleaf SNAPSHOT 1.5.0.M4. I managed to deploy the 'site' project after having changed the dependencies for MySQL and changing the applicationcontext.xml.
Now I'am trying to deploy 'site-admin' application. The first problem I got was in the web.xml. Glassfish complained that webAppRootKey="bl.Admin.root" was already used in another application ('site' application). So I changed it to some arbitrary value.
Now I'am facing another problem (excerpt from glassfish logfile)

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateExporter' defined in resource loaded from byte array: Invocation of init method failed; nested exception is org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.hibernate.jmx.StatisticsService@53fb88] with key 'org.broadleafcommerce:name=hibernate.statistics-broadleaf'; nested exception is org.broadleafcommerce:name=hibernate.statistics-broadleaf. Please see server.log for more details.

I searched the full M4 distribution and found that hibernateExporter was defined in :

./core/BroadleafCommerceFramework/src/main/resources/bl-framework-applicationContext-test.xml: <bean id="hibernateExporter" class="org.springframework.jmx.export.MBeanExporter">
./core/BroadleafCommerceProfile/src/main/resources/bl-profile-applicationContext-persistence.xml: <bean id="hibernateExporter" class="org.springframework.jmx.export.MBeanExporter" depends-on="entityManagerFactory">

So effectively it is defined twice but both BroadleafCommerceFramework and BroadleafCommerceProfile are dependencies of the site-admin.
Can I simply remove the bean definition from one of this files and rebuild ?

Thank you for helping me out


Re: bean hibernateExporter defined twice in 1.5.0.M4

Posted: Fri Nov 11, 2011 12:23 pm
by jefffischer
The framework declaration is only is a 'test' application context, so it is only referenced during integration tests. The reference that's actually used at runtime is the one in profile. What is happening is that you have two separate wars attempting to register a bean with the same name in your Glassfish instance. This normally does not happen because the name used to register should be pre-pended with the appName defined in web.xml for each war module using broadleaf.

Check your Glassfish setup and make sure whatever jndi support necessary to recognize env-entry elements from web.xml is enabled.

Re: bean hibernateExporter defined twice in 1.5.0.M4

Posted: Tue Mar 13, 2012 2:44 pm
by bpolster
Also ran into this issue on Tomcat. In my case, I had a ROOT application in my Tomcat webapps directory with a broadleaf application and another being deployed with broadleafdemo as the application context. I deleted the ROOT directory and things were back to normal.