-->
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.  [ 2 posts ] 
Author Message
 Post subject: Need help with Unable to load class issue
PostPosted: Sun Aug 01, 2010 7:29 pm 
Newbie

Joined: Sun Aug 01, 2010 6:38 pm
Posts: 2
Hi ,

I would appreciate any inputs on the error i am getting.
I deployed war file under weblogic 10.3 successfully, I get this error when i submit a form using Static html which has action as Servlet listed below.

org.hibernate.MappingException: Unable to load class declared as <mapping class="com.project.dblayer.Project"/> in the configuration:
............
java.lang.ClassNotFoundException: com.project.dblayer.Project
........

WEB-INF/classes should be visible so i am not sure why this error.



I am deploying this under weblogic 10.3.

---------------------------------------
web.xml-
...
<servlet>
<servlet-name>ptrackerServlet</servlet-name>
<servlet-class>com.ptracker.servlet.ptrackerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ptrackerServlet</servlet-name>
<url-pattern>/Project/ptrackerServlet</url-pattern>
</servlet-mapping>
....


---------------------------------------
hibernate.cfg.xml -
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">xxxxx</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@XXXX:1521:XE</property>
<property name="hibernate.connection.username">xxxxx</property>
<property name="hibernate.default_schema">xxxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="connection.pool_size">1</property>

<mapping class="com.project.dblayer.Project" />
<mapping class="com.project.dblayer.ProjectId" />
<mapping class="com.project.dblayer.ProjectOwners" />
<mapping class="com.project.dblayer.ProjectOwnersId" />
<mapping class="com.project.dblayer.WeeklyStatus" />
<mapping class="com.project.dblayer.WeeklyStatusId" />
</session-factory>
</hibernate-configuration>


---------------------------------------
weblogic.xml - (Based on some comments added this file)
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>



---------------------------------------
Servlet Code -
package com.ptracker.servlet;

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.http.*;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import com.ptracker.dblayer.*;


public class ptrackerServlet extends HttpServlet {
SessionFactory sf= null;

public void init(){
sf = new AnnotationConfiguration().configure().buildSessionFactory();
}


public void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String projectName = req.getParameter("pName");
Long projectId = Long.valueOf(req.getParameter("pId"));
String projectCode = req.getParameter("pCode");
String projectDesc = req.getParameter("pDesc");
String pOperation = req.getParameter("optSelected");

if (pOperation.equals("add")) {
try {
Session session = sf.openSession();
session.beginTransaction();
Project vProject = new Project();
vProject.setId(new ProjectId(projectId,projectCode));
vProject.setName(projectName);
vProject.setDescription(projectDesc);
session.save(vProject);
session.getTransaction().commit();
}
catch (Exception e) {
System.out.println(""+e);
}
}

}
}


---------------------------------------
Generated Hibernate code -

package com.ptracker.dblayer;
// Generated Jul 31, 2010 8:14:44 AM by Hibernate Tools 3.1.0.beta4

import java.util.HashSet;
import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
* Project generated by hbm2java
*/
@Entity
@Table(name="PROJECT"
, uniqueConstraints = { }
)

public class Project implements java.io.Serializable {


// Fields

private ProjectId id;
private String name;
private String description;
.........



---------------------------------------

Environment Details -
Eclipse 3.4.0
jdk/jre 1.6

jar file Details -
C:\workspace\ProjectTracker\dist>jar -tvf ptracker.war
0 Sun Aug 01 12:47:44 EDT 2010 META-INF/
102 Sun Aug 01 12:47:42 EDT 2010 META-INF/MANIFEST.MF
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/logiclayer/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/servlet/
0 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/
3551 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/Employee.class
2287 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/Project.class
1198 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/ProjectId.class
3776 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/ProjectOwners.class
1537 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/ProjectOwnersId.class
2266 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/WeeklyStatus.class
2816 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/dblayer/WeeklyStatusId.class
1235 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/logiclayer/ProjectTest.class
1256 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/logiclayer/ProjectUpdate.class
2222 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/com/ptracker/servlet/ptrackerServlet.class
1341 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/classes/hibernate.cfg.xml
443432 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/antlr-2.7.6.jar
559366 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/commons-collections-3.1.jar
60841 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/commons-logging-1.1.1.jar
313898 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/dom4j-1.6.1.jar
279714 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/hibernate-annotations.jar
119292 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/hibernate-entitymanager-3.4.0.GA.jar
3916110 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/hibernate3.jar
1051818 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/javaee.jar
597476 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/javassist-3.9.0.GA.jar
134684 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/javax.persistence-2.0.0.jar
10899 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/jta-1.1.jar
23445 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/slf4j-api-1.5.8.jar
8817 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/slf4j-jdk14-1.5.8.jar
9679 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/lib/slf4j-log4j12-1.5.8.jar
830 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/web.xml
448 Sun Aug 01 12:47:44 EDT 2010 WEB-INF/weblogic.xml
459 Sun Aug 01 12:47:44 EDT 2010 ptracker.html


---------------------------------------
Trace logs -

http://localhost:7001/ptracker/ptracker.html
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2; MS-RTC LM 8)
Content-Length: 67
Connection: Keep-Alive
Cache-Control: no-cache

]] Root cause of ServletException.
org.hibernate.MappingException: Unable to load class declared as <mapping class="com.project.dblayer.Project"/> in the configuration:
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:650)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1047)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011)
at com.ptracker.servlet.ptrackerServlet.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:521)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
java.lang.ClassNotFoundException: com.project.dblayer.Project
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:42)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:647)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1047)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011)
at com.ptracker.servlet.ptrackerServlet.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:521)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


Top
 Profile  
 
 Post subject: Re: Need help with Unable to load class issue
PostPosted: Mon Aug 02, 2010 12:10 pm 
Newbie

Joined: Sun Aug 01, 2010 6:38 pm
Posts: 2
Incorrect Path in the cfg file. This issue is resolved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.