-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Trouble with HibernateFilter
PostPosted: Fri Aug 12, 2005 8:39 pm 
Newbie

Joined: Wed Jul 06, 2005 10:18 am
Posts: 5
I'm using Hibernate 3 with Tomcat 5.5 and the Thread Local Session and HibernateFilter as found in the Wiki. This seemed to work fine up until I restarted Tomcat this afternoon, having made significant changes to my models. Now I'm getting this on the first page of my app:

Quote:
javax.servlet.ServletException: Filter execution threw an exception

root cause

java.lang.NoClassDefFoundError
net.traxtech.util.HibernateFilter.doFilter(Unknown Source)


This from catalina.out might also be relevant:
Quote:
Aug 12, 2005 4:03:30 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter HibernateFilter
java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1247)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:211)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:79)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3540)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4110)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)


Oddly enough it seems that this has nothing to do with Hibernate and perhaps I'm barking up the wrong tree. It is also possible that I was not, in fact, actually using the filter beforehand. If so, I suppose I shall be punished by the wasting away of my credits... ;)

Regards,

John


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 8:48 pm 
Newbie

Joined: Wed Jul 06, 2005 10:18 am
Posts: 5
So I've removed the filter and now I get:

Quote:
java.lang.ExceptionInInitializerError
net.myCompany.util.HibernateUtil.<clinit>(Unknown Source)
net.myCompany.app.model.Charge.allCharges(Unknown Source)
org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Which leads me to believe I'm running into the static initializer error mentioned in the FAQ. I'm definitely showing my lack of Java experience here. Can someone point me in the right direction? Again, I'm using the ThreadLocal Session version of HibernateUtil and HibernateFilter with Hibernate3 and Tomcat 5.5.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 8:58 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
What is in the static initialization block of HibernateUtil?
Did the changes made to your model break this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:03 pm 
Newbie

Joined: Wed Jul 06, 2005 10:18 am
Posts: 5
Right from the Wiki:

Code:
    static {
        try {
            configuration = new Configuration();
            sessionFactory = configuration.configure().buildSessionFactory();
            // We could also let Hibernate bind it to JNDI:
            // configuration.configure().buildSessionFactory()
        } catch (Throwable ex) {
            // We have to catch Throwable, otherwise we will miss
            // NoClassDefFoundError and other subclasses of Error
            log.error("Building SessionFactory failed.", ex);
            throw new ExceptionInInitializerError(ex);
        }
    }


When this worked before I believe we had erroneously used Hibernate's built-in connection pooling. It *should* be using Tomcat's connection pool, like this:

Code:
<property name="connection.datasource">java:/comp/env/jdbc/myDB</property>


That datasource is defined correctly in server.xml (I realize that might not be the best place for it). I know this because it's also used for the authentication realm (again, not the ideal solution). Am I defining it incorrectly in hibernate.cfg.xml?

Thanks,

John


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:10 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Try running that code outside the Util in a quick scriplet or something. Check to see that the configuration files and the dialect are in the classpath .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.