-->
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: Unable to find POJO class on jboss.
PostPosted: Tue Sep 23, 2008 3:17 am 
Newbie

Joined: Mon Sep 22, 2008 1:43 am
Posts: 2
Dear all


I am using Hibernate 3.2.6.I have created one small example of creating user using hibernate.I am using the database oracle 10g and JDK1.5.I am trying to deploy my application on the JBOSS 4.0.5-GA.

Here is my Persistence.xml Its inside WebContent/META-INF folder.

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">
<persistence-unit name="friendsnetwork">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm"/>

<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>

<property name="hibernate.connection.url" value="jdbc:oracle:thin:@10.37.54.19:1521:tstlive"/>

<property name="hibernate.connection.username" value="oeom" />

<property name="hibernate.connection.password" value="oeom"/>

<property name="hibernate.c3p0.min_size" value="5" />

<property name="hibernate.c3p0.max_size" value="20" />

<property name="hibernate.c3p0.timeout" value="300" />

<property name="hibernate.c3p0.max_statements" value="50" />

<property name="hibernate.c3p0.idle_test_period" value="3000" />

<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

<property name="current_session_context_class" value="thread" />

<property name="cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />

</properties>
</persistence-unit>
</persistence>


Here is my pojo class for the User entity.

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="userj")
public class jinesh {
private Integer userId;
private String userName;
private String userPassword;

@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="user_id")
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}

@Column(name="user_name")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}

@Column(name="user_password")
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}


}


Here is the code using which i tried to insert the value inside database.


package com.friends.manager;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;

import com.friends.pojo.Login.jinesh;

public class LoginManager {



public static Integer createUser(){
System.out.println("======11111=====");
try{

EntityManagerFactory emf = Persistence.createEntityManagerFactory("friendsnetwork");

EntityManager em;
em = emf.createEntityManager();

EntityTransaction tx = em.getTransaction();
tx.begin();

jinesh loginPojo = new jinesh();

loginPojo.setUserName("Abhi");

loginPojo.setUserPassword("jinesh");

em.persist(loginPojo);

tx.commit();

em.close();

return 0;//Object persisted successfully, hence return 0;
}
catch(Exception e){
System.out.println("=====Error while persisting user=====");
e.printStackTrace();
return -1;//Object not persisted successfully, hence return -1;
}

}
}


When i tried to deploy the above application on jboss and then run the web page.it asks me for the username and password when i submit the
page it gives me the following error stack tarce.It seems that it is not able to find the POJO class.

java.lang.NoClassDefFoundError: WEB-INF/classes/com/friends/pojo/Login/jinesh (wrong name: com/friends/pojo/Login/jinesh)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
java.net.URLClassLoader.access$100(URLClassLoader.java:56)
java.net.URLClassLoader$1.run(URLClassLoader.java:195)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:672)
org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:652)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:190)
org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:277)
org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:189)
org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
java.lang.ClassLoader.loadClass(ClassLoader.java:299)
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:579)
java.lang.ClassLoader.loadClass(ClassLoader.java:251)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1339)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:242)
org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1005)
org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1077)
org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:886)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:772)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:183)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:240)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
com.friends.manager.LoginManager.createUser(LoginManager.java:22)
com.friends.action.Login.LoginAction.execute(LoginAction.java:30)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


Plz help me on this issue.Since i am new to hibernate
Did i miss something inside the code.According to me its unable to find the class but i am not able to find the reason for it.

Any help would be exremely helpful to me.

Regards
Jinesh Parikh


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 12:38 am 
Newbie

Joined: Mon Sep 22, 2008 1:43 am
Posts: 2
Dear all,

Plz help me on this issue.


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.