Page 1 of 1

Glassfish v.3, Broadleaf 1.5 and Spring JNDI failure in JMX

Posted: Thu Feb 16, 2012 4:55 pm
by laazik
Hi,

It has already been in this forum once, but as the problem hasn't disappeared I thought I put some lines about this here. So basically the problem revolves around the iniatlization of AnnotationJmxAttributeSource class from the bl-framework-applicationContext.xml configuration file and the appName parameter there.

I'll put the code here also for reference:

Code: Select all

<bean id="blAttributeSource" class="org.broadleafcommerce.profile.jmx.AnnotationJmxAttributeSource">
        <constructor-arg>
            <bean class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiName">
                  <value>java:/comp/env/appName</value>
              </property>
              <property name="defaultObject" value="broadleaf"/>
         </bean>
        </constructor-arg>
</bean>


The problem I have been struggling was that although the env-entry in web.xml has been defined in the Glassfish, during the deployment the forementioned .xml intialization completely ignored it. I did spend quite a significant amount of time debugging in broadleaf and spring framework and reached a couple of conclusions, I'm going to write down here, even if it is only for reference to others struggling with this. And my conclusion is:

Spring lookup during the application deployment and initalization is failing in the java:comp/env/appName entry for non understandable reason. The context is initialized by Spring and I didn't notice anything strange there (seemed to be quite generic new InitialContext() with some env proprerties), but it claims the environment entry is missing and just initializes with the default value.


Now comes the part where I was unwilling to dig into the workings of the Spring framework, but was able to confirm by changing the constructor code in AnnotationJmxAttributeClass and adding there

Code: Select all

InitialContext ic = new InitialContext();
String appNameLocal = ic.lookup("java:comp/env/appName");

When this code is being run during the deployment it is actually getting the correct value from the web.xml. I'm not sure if it is the shortcoming in the Spring framework or Glassfish container code, but currently I did an ugly hack for myself, which actually does the lookup in constructor instead of the correct initialization from the Spring config.

Any ideas on how to decently fix this are of course welcome. I apologize for not being more thorough learing the Spring framework right now and not proposing a solution myself :P.

Re: Glassfish v.3, Broadleaf 1.5 and Spring JNDI failure in JMX

Posted: Tue Feb 21, 2012 11:15 am
by jefffischer
We'll add this as a JIRA item for glassfish compatibility. We definitely don't see this problem in other containers.

Re: Glassfish v.3, Broadleaf 1.5 and Spring JNDI failure in JMX

Posted: Mon Sep 03, 2012 2:26 pm
by bharath
Can someone help on this... I am getting following error when deploying in Glassfish 3. JNDI mapping for jndi/web is done. I hope this is becoz null persistant unit

Code: Select all


INFO: [ WARN] 00:06:26 CacheManager - Creating a new instance of CacheManager using the diskStorePath "C:\Users\Bharath\AppData\Local\Temp\" which is already used by an existing CacheManager.
The source of the configuration was net.sf.ehcache.config.generator.ConfigurationSource$DefaultConfigurationSource@6b305e44.
The diskStore path for this CacheManager will be set to C:\Users\Bharath\AppData\Local\Temp\\ehcache_auto_created_1346697386681.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.

INFO: [ERROR] 00:06:30 Ejb3Configuration - Container is providing a null PersistenceUnitRootUrl: discovery impossible

INFO: [ WARN] 00:06:33 Ejb3Configuration - hibernate.connection.autocommit = false break the EJB3 specification

INFO: [ WARN] 00:06:34 AbstractEhcacheRegionFactory - Couldn't find a specific ehcache configuration for cache named [blSandBoxElements]; using defaults.

INFO: [ WARN] 00:06:41 AbstractEhcacheRegionFactory - Couldn't find a specific ehcache configuration for cache named [org.hibernate.cache.UpdateTimestampsCache]; using defaults.

INFO: [ WARN] 00:06:43 JmxUtils - Found more than one MBeanServer instance. Returning first from list.

INFO: [ERROR] 00:06:44 Ejb3Configuration - Container is providing a null PersistenceUnitRootUrl: discovery impossible

INFO: [ WARN] 00:06:44 Ejb3Configuration - hibernate.connection.autocommit = false break the EJB3 specification

INFO: [ WARN] 00:06:48 JmxUtils - Found more than one MBeanServer instance. Returning first from list.

INFO: [ERROR] 00:06:50 Ejb3Configuration - Container is providing a null PersistenceUnitRootUrl: discovery impossible

INFO: [ WARN] 00:06:50 Ejb3Configuration - hibernate.connection.autocommit = false break the EJB3 specification

INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'mycompany'
INFO: [ WARN] 00:06:54 RuntimeEnvironmentPropertiesConfigurer - Unable to determine runtime environment, using default environment 'development'

INFO: WEB0671: Loading application [com.mycompany_site_war_1.0] at [/site]
INFO: com.mycompany_site_war_1.0 was successfully deployed in 116,203 milliseconds.
WARNING: StandardWrapperValve[mycompany]: PWC1406: Servlet.service() for servlet mycompany threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   at java.lang.String.substring(String.java:1952)
   at java.lang.String.substring(String.java:1925)
   at org.broadleafcommerce.core.catalog.dao.ProductDaoImpl.findProductByURI(ProductDaoImpl.java:392)
   at org.broadleafcommerce.core.catalog.service.CatalogServiceImpl.findProductByURI(CatalogServiceImpl.java:268)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy359.findProductByURI(Unknown Source)
   at org.broadleafcommerce.core.web.catalog.ProductHandlerMapping.getHandlerInternal(ProductHandlerMapping.java:36)
   at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:288)
   at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1063)
   at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1048)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:886)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
   at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
   at org.broadleafcommerce.cms.web.URLHandlerFilter.doFilterInternal(URLHandlerFilter.java:57)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
   at org.broadleafcommerce.common.web.BroadleafRequestFilter.doFilterInternal(BroadleafRequestFilter.java:146)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.broadleafcommerce.profile.web.core.security.SessionFixationProtectionFilter.doFilter(SessionFixationProtectionFilter.java:89)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.broadleafcommerce.core.web.order.security.CartStateFilter.doFilter(CartStateFilter.java:86)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.broadleafcommerce.profile.web.core.security.CustomerStateFilter.doFilter(CustomerStateFilter.java:150)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:144)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
   at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
   at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
   at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
   at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
   at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
   at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
   at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
   at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
   at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
   at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
   at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
   at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
   at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
   at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
   at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
   at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
   at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
   at java.lang.Thread.run(Thread.java:722)