You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ue...@mra.man.de on 2005/08/01 11:48:52 UTC

Problems using StartupServletContextListener to init JDO-PersistenceManagerFactory...

Hi all,
I am trying to init the JDO-PersistenceManagerFactory by using the StartupServletContextListener.
But it does not work, I get the console output below. The JDOHelper class whose ClassDef is not found
is a class that PmContext uses.
Am I using the StartupServletContextListener incorrectly?
Is there another way to initialize the JDO-PersistenceManagerFactory?

My configuration:
Apache Tomcat/5.5.7, JVM Version: 1.5.0_04-b05, myfaces-1.0.9.

Below is the console output, JDOInitializer code and the relevant web.xml fragment.

Thanks,

Ünsal
 

...
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class com.karthago.web.JDOInitializer
java.lang.NoClassDefFoundError: javax/jdo/JDOHelper
	at com.karthago.domain.PmContext.initialize(PmContext.java:51)
	at com.karthago.web.JDOInitializer.contextInitialized(JDOInitializer.java:68)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3637)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4073)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440)
	at org.apache.catalina.core.StandardService.start(StandardService.java:450)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
01.08.2005 11:15:43 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error listenerStart
01.08.2005 11:15:43 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context startup failed due to previous errors
01.08.2005 11:15:43 org.apache.catalina.core.ApplicationContext log
SCHWERWIEGEND: Exception sending context destroyed event to listener instance of class com.karthago.web.JDOInitializer
java.lang.NoClassDefFoundError: com/versant/core/jdo/VersantPersistenceManagerFactory
	at com.karthago.domain.PmContext.shutdown(PmContext.java:78)
	at com.karthago.web.JDOInitializer.contextDestroyed(JDOInitializer.java:78)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3678)
	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4293)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4101)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440)
	at org.apache.catalina.core.StandardService.start(StandardService.java:450)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
...

_______________________________________________________

package com.karthago.web;

import javax.servlet.*;
import org.apache.myfaces.webapp.StartupServletContextListener;
import com.karthago.domain.PmContext;

public class JDOInitializer extends StartupServletContextListener
{

	
	public JDOInitializer()
	{
	}
	
	public void contextInitialized(ServletContextEvent event)
	{
		ServletContext servletContext = event.getServletContext();
		Utils.log(servletContext, "Initializing ProjectTrack...");
		try {
			servletContext.setAttribute(Constants.PM_CONTEXT_KEY,
					PmContext.class);
            PmContext.initialize(PmContext.loadJDOProperties());
        } catch (Exception e) {
        	servletContext.log("Unable to load PMF properties.", e);
		} 
        
		Utils.log(servletContext, "Initialization complete...");
	}
	
	public void contextDestroyed(ServletContextEvent event)
	{
			PmContext.shutdown();
	}
}

_____________________________________


web.xml:

	...
    <!-- Listener, that does all the startup work (configuration, init).-->
    <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
	<listener>
        <listener-class>com.karthago.web.JDOInitializer</listener-class>
    </listener>
	...



Re: Problems using StartupServletContextListener to init JDO-PersistenceManagerFactory...

Posted by Bruno Aranda <br...@gmail.com>.
It complains about a mising class:
com.versant.core.jdo.VersantPersistenceManagerFactory. Do you have the
jar that has this class in the classpath?

Regards,

Bruno

2005/8/1, Uensal_Kara@mra.man.de <Ue...@mra.man.de>:
> Hi all,
> I am trying to init the JDO-PersistenceManagerFactory by using the StartupServletContextListener.
> But it does not work, I get the console output below. The JDOHelper class whose ClassDef is not found
> is a class that PmContext uses.
> Am I using the StartupServletContextListener incorrectly?
> Is there another way to initialize the JDO-PersistenceManagerFactory?
> 
> My configuration:
> Apache Tomcat/5.5.7, JVM Version: 1.5.0_04-b05, myfaces-1.0.9.
> 
> Below is the console output, JDOInitializer code and the relevant web.xml fragment.
> 
> Thanks,
> 
> Ünsal
> 
> 
> ...
> SCHWERWIEGEND: Exception sending context initialized event to listener instance of class com.karthago.web.JDOInitializer
> java.lang.NoClassDefFoundError: javax/jdo/JDOHelper
>         at com.karthago.domain.PmContext.initialize(PmContext.java:51)
>         at com.karthago.web.JDOInitializer.contextInitialized(JDOInitializer.java:68)
>         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3637)
>         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4073)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
>         at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
>         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440)
>         at org.apache.catalina.core.StandardService.start(StandardService.java:450)
>         at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
>         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> 01.08.2005 11:15:43 org.apache.catalina.core.StandardContext start
> SCHWERWIEGEND: Error listenerStart
> 01.08.2005 11:15:43 org.apache.catalina.core.StandardContext start
> SCHWERWIEGEND: Context startup failed due to previous errors
> 01.08.2005 11:15:43 org.apache.catalina.core.ApplicationContext log
> SCHWERWIEGEND: Exception sending context destroyed event to listener instance of class com.karthago.web.JDOInitializer
> java.lang.NoClassDefFoundError: com/versant/core/jdo/VersantPersistenceManagerFactory
>         at com.karthago.domain.PmContext.shutdown(PmContext.java:78)
>         at com.karthago.web.JDOInitializer.contextDestroyed(JDOInitializer.java:78)
>         at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3678)
>         at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4293)
>         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4101)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
>         at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
>         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440)
>         at org.apache.catalina.core.StandardService.start(StandardService.java:450)
>         at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
>         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> ...
> 
> _______________________________________________________
> 
> package com.karthago.web;
> 
> import javax.servlet.*;
> import org.apache.myfaces.webapp.StartupServletContextListener;
> import com.karthago.domain.PmContext;
> 
> public class JDOInitializer extends StartupServletContextListener
> {
> 
> 
>         public JDOInitializer()
>         {
>         }
> 
>         public void contextInitialized(ServletContextEvent event)
>         {
>                 ServletContext servletContext = event.getServletContext();
>                 Utils.log(servletContext, "Initializing ProjectTrack...");
>                 try {
>                         servletContext.setAttribute(Constants.PM_CONTEXT_KEY,
>                                         PmContext.class);
>             PmContext.initialize(PmContext.loadJDOProperties());
>         } catch (Exception e) {
>                 servletContext.log("Unable to load PMF properties.", e);
>                 }
> 
>                 Utils.log(servletContext, "Initialization complete...");
>         }
> 
>         public void contextDestroyed(ServletContextEvent event)
>         {
>                         PmContext.shutdown();
>         }
> }
> 
> _____________________________________
> 
> 
> web.xml:
> 
>         ...
>     <!-- Listener, that does all the startup work (configuration, init).-->
>     <listener>
>         <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
>     </listener>
>         <listener>
>         <listener-class>com.karthago.web.JDOInitializer</listener-class>
>     </listener>
>         ...
> 
> 
>