users@glassfish.java.net

Re: ClassNotFoundException: Spring, JPA packaged as a .war archive

From: <glassfish_at_javadesktop.org>
Date: Mon, 19 Mar 2007 16:28:52 PST

Hi Gordon,

Sorry for the late reply, but the stack trace is below. Basically, Toplink couldn't load the entity.

[#|2007-01-13T01:40:10.187-0800|SEVERE|sun-appserver-pe9.0|org.springframework.web.context.ContextLoade r|_ThreadID=10;_ThreadName=main;_RequestID=4cc5377 b-f758-4ece-bec4-a6e7f4bd936a;|Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.PersistenceUn itLoadingException
Exception Description: An exception was thrown while loading class: xxx.yyy.domain.Customer to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: xxx.yyy.domain.Customer
Caused by: Local Exception Stack:
Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.PersistenceUn itLoadingException
Exception Description: An exception was thrown while loading class: xxx.yyy.domain.Customer to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: xxx.yyy.domain.Customer
Reply With Quote


There is another stack trace from zekey posted here:
http://forum.springframework.org/showthread.php?t=30954
This is his finding: "With Spring you can use JPA and entities under tomcat without EJBs. But it is not possible to deploy the same application under glassfish because EJBClassLoader is used to resolve persistence units and not WebAppClassLoader.
So JPA has to be implemented using EJB under glassfish."

Here is the same error from the user Abhi:
http://java-x.blogspot.com/2006/12/data-access-with-spring-and-jpa.html
"In order to run the example on Glassfish, you have to create an EAR and install the EAR instead of trying to deploy a WAR file on Glassfish. Deploying WAR files gives some classloading related exceptions. The reason is, as yet, unknown to me. Hope to find out soon."

FYI, I had abandoned Spring and Toplink since I posted this question. I'm using Hibernate JPA and application-managed entity managers. Hope someone using spring/toplink/jpa/glassfish will find this post helpful.
[Message sent by forum member 'tmv' (tmv)]

http://forums.java.net/jive/thread.jspa?messageID=208826