java.lang.ClassNotFoundException: org.springframework.orm.hibernate.support.OpenSessionInViewFilter

4.8k views Asked by At

i am new to spring/hibernate and was trying out my first app. I got stuck at this error, at first there was something like a 'no session factory bound to thread' error. i resolved it by declaring an OpenSessionInView filter in my web.xml given below

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> cricket_calendar

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/calendar-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.do</url-pattern>
</filter-mapping>


<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

Now i am getting this class not found error, but if I ctrl-shift-t and search it, its in the orm jar. i.e enter image description here

no idea whats the problem, please, any help will be greatly appreciated :)

EDIT: Full stacktrace

Jan 16, 2012 1:51:53 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\development\apache-ant-1.8.2\lib;C:\development\apache-ant-1.8.2\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;.
Jan 16, 2012 1:51:54 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:cricket_calendar' did not find a matching property.
Jan 16, 2012 1:51:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 16, 2012 1:51:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 16, 2012 1:51:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 648 ms
Jan 16, 2012 1:51:54 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 16, 2012 1:51:54 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Jan 16, 2012 1:51:58 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Jan 16, 2012 1:51:58 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 16, 2012 1:51:58 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter hibernateFilter
java.lang.ClassNotFoundException: org.springframework.orm.hibernate.support.OpenSessionInViewFilter
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:124)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4624)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Jan 16, 2012 1:51:58 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Jan 16, 2012 1:51:58 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/cricket_calendar] startup failed due to previous errors
Jan 16, 2012 1:51:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 16, 2012 1:51:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 16, 2012 1:51:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4066 ms
1

There are 1 answers

2
Ralph On BEST ANSWER

I do not know if it is a spring 3.1 change.

But you tryed to load java.lang.ClassNotFoundException: org.springframework.orm.hibernate.support.OpenSessionInViewFilter

but you have only:

  • java.lang.ClassNotFoundException: org.springframework.orm.hibernate.support3.OpenSessionInViewFilter
  • java.lang.ClassNotFoundExcepion: org.springframework.orm.hibernate.support4.OpenSessionInViewFilter

The difference is the 3 or 4 in the classname. -- Because you do not posted the complete stacktrace I can only make a guess.

  • there is still the old package name use in a configuration file, or
  • you used a lib the is written for spring 3.0, or mixed spring 3.1 and 3.0 jars