Exception sending context initialized event to listener

139 views
Skip to first unread message

Daniel Hunt

unread,
Jul 21, 2014, 5:27:49 PM7/21/14
to hibernate...@googlegroups.com
Im trying to profile a JSF/Spring/Hibernate application from within MyEclipse 10. Im new to all of the technologies, so Im probably doing something silly.  I update the name space and added the profiler to the sessionFactory bean which has a parent bean that I have not added the profiler to. The web.xml file is updated as instructed, but when the application start (Tomcat6 from within MyEclipse). I get the following dump at the end of startup:

log4jInitialization
rexusDataSource
rexusDataSourceOffline
starHibernateProperties
offlineSessionFactory
Jul 21, 2014 5:25:08 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NullPointerException
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.registerProperties(ProfilerBeanFactoryPostProcessor.java:51)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.overrideHibernateSettings(ProfilerBeanFactoryPostProcessor.java:44)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.postProcessBeanFactory(ProfilerBeanFactoryPostProcessor.java:32)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:646)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2014/07/21-17:25:08.952 -- ERROR - [main] - org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.NullPointerException
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.registerProperties(ProfilerBeanFactoryPostProcessor.java:51)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.overrideHibernateSettings(ProfilerBeanFactoryPostProcessor.java:44)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.postProcessBeanFactory(ProfilerBeanFactoryPostProcessor.java:32)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:646)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 21, 2014 5:25:08 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class xxx.xxx.xxx.xxx.common.webtier.MyAppListener
java.lang.NullPointerException
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.registerProperties(ProfilerBeanFactoryPostProcessor.java:51)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.overrideHibernateSettings(ProfilerBeanFactoryPostProcessor.java:44)
at hibernatingrhinos.hibernate.profiler.spring.ProfilerBeanFactoryPostProcessor.postProcessBeanFactory(ProfilerBeanFactoryPostProcessor.java:32)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:646)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 21, 2014 5:25:09 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.0.11 (SNAPSHOT 20130213-1632) for context '/MyAppUI'



Oren Eini (Ayende Rahien)

unread,
Jul 22, 2014, 4:37:38 AM7/22/14
to hibernate-profiler
Hi,
The code in question looks like this:


 public static void registerProperties(HibernateProfilerSpringSettings settings, BeanDefinition beanDefinition) {
        MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
        PropertyValue propertyValue = propertyValues.getPropertyValue("hibernateProperties");

        Object value = propertyValue.getValue();

do you have hibernateProperties there?



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





--
You received this message because you are subscribed to the Google Groups "Hibernate Profiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Hunt

unread,
Jul 22, 2014, 8:55:25 AM7/22/14
to hibernate...@googlegroups.com
That code doesnt exist anywhere in my workspace.
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profiler+unsub...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Jul 22, 2014, 9:08:38 AM7/22/14
to hibernate-profiler
This is _our_ code.

We are trying to find the configured hibernateProperties config section.
It appears to be missing on your end.
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profi...@googlegroups.com.

Daniel Hunt

unread,
Jul 22, 2014, 9:20:59 AM7/22/14
to hibernate...@googlegroups.com
I added hibernate3-profiler-1.1.jar to the WEB-INF/lib directory, but the remaining files in the zip are outside of the workspace.  Did I miss a step or should I download the zip file again?
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profiler+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Oren Eini (Ayende Rahien)

unread,
Jul 22, 2014, 9:22:42 AM7/22/14
to hibernate-profiler
What is your spring configuration?
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profi...@googlegroups.com.

Daniel Hunt

unread,
Jul 22, 2014, 9:41:14 AM7/22/14
to hibernate...@googlegroups.com
Im not sure I understand the question.  We are using Spring 3.0.5

Oren Eini (Ayende Rahien)

unread,
Jul 23, 2014, 6:28:21 AM7/23/14
to hibernate-profiler
How did you configure hibernate in your application?
The OR/M, not the profiler.
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profi...@googlegroups.com.

Daniel Hunt

unread,
Jul 23, 2014, 8:56:02 AM7/23/14
to hibernate...@googlegroups.com
The app-context file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      
     <bean id="log4jInitialization"
     class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
       <property name="targetClass"
                 value="org.springframework.util.Log4jConfigurer" />
       <property name="targetMethod" value="initLogging" />
       <property name="arguments">
          <list>
              <value>classpath:log4j.xml</value>
          </list>
       </property>
    </bean>
            
      <import resource="datasource.xml"/>
      <import resource="hibernate-props.xml"/>
      <import resource="hibernate-template.xml"/>
      <import resource="jdbc-template.xml"/>  
      <import resource="ds-dozer-mappings.xml"/> 
      <import resource="database-dao.xml"/>
      <import resource="aop-aspects.xml"/>
      <import resource="ehcache-props.xml"/>
                            
</beans>

then the hibernate-template file

<?xml version="1.0" encoding="UTF-8"?>
      xmlns:hprof="http://www.nhprof.com/schema/hprof"
      xsi:schemaLocation="http://www.springframework.org/schema/beans

<bean id="offlineSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
parent="superSessionFactory">
<property name="dataSource" ref="rexusDataSourceOffline" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
parent="superSessionFactory">
<property name="dataSource" ref="rexusDataSource" />
<hprof:profiler /> 
</bean>

<bean id="superSessionFactory" abstract="true">
<property name="hibernateProperties">
<ref bean="starHibernateProperties" />
</property>

<property name="annotatedClasses">
<list>
<value>xxx.xxx.xxx.xxx.common.model.domain.xxx</value>
         ......
<value>xxx.xxx.xxx.xxx.common.model.domain.xxx</value>
</list>
</property>

</bean>

<bean id="transactionManagerHibernate"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManagerHibernate" />
</property>
<property name="transactionAttributes">
<props>
<prop key="voidDigest">PROPAGATION_REQUIRES_NEW</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

</beans>

Marcin Lewandowski

unread,
Jul 25, 2014, 1:41:26 AM7/25/14
to hibernate...@googlegroups.com
Looks like the issue is related to this configuration:


<bean id="superSessionFactory" abstract="true">
<property name="hibernateProperties">
<ref bean="starHibernateProperties" />
</property>

Here you have property hibernateProperties. When we fetch value of this property in hibernate profiler we get null. Could you define starHibernateProperties  bean in the same xml confgiuration file?

Marcin
...

Daniel Hunt

unread,
Jul 25, 2014, 9:21:22 AM7/25/14
to hibernate...@googlegroups.com
That is in a separate file named hibernate-props.xml.

<!-- Database Properties -->
<bean id="starHibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.c3p0.max_statement">200</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="hibernate.default_batch_fetch_size">100</prop>
</props>
</property>
</bean>
</beans>
...

Oren Eini (Ayende Rahien)

unread,
Jul 26, 2014, 4:15:18 AM7/26/14
to hibernate-profiler
The likely issue is that we are looking for a bean with the id hibernateProperties, NOT starHibernateProperties

--
You received this message because you are subscribed to the Google Groups "Hibernate Profiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hibernate-profi...@googlegroups.com.

Daniel Hunt

unread,
Jul 28, 2014, 9:32:02 AM7/28/14
to hibernate...@googlegroups.com
I tried to replace the starHibernateProperties reference in hibernate-template.xml with the properties defined in hibernate-props.xml.  I also tried renaming starHibernateProperties as hibernateProperties.  Neither approach worked.


--
You received this message because you are subscribed to a topic in the Google Groups "Hibernate Profiler" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hibernate-profiler/HFU3mrtz5zw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hibernate-profi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks,

Dan
Reply all
Reply to author
Forward
0 new messages