-->
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: Executing Hibernate with Struts Application in WSAD5.1
PostPosted: Tue Nov 20, 2007 1:36 am 
Newbie

Joined: Tue Nov 20, 2007 12:36 am
Posts: 1
Location: INDIA
First Let me explain Situation. I am trying to perform database access using hibernate from Struts. I am using WSAD. Please help me in this situation as i am getting an error.

Hibernate version: 3.0
Mapping documents: hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/MYDSREF</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>

<!-- Mapping files -->
<mapping resource="Agent.hbm.xml"/>
</session-factory>
</hibernate-configuration>

b]Mapping documents: Agent.hbm.xml[/b]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.strutsweb.fomrs.AgentData" table="ADMIN.AGENT">

<id name="agentid" type="string" unsaved-value="null" >
<column name="AGENTID" sql-type="char(6)" not-null="true"/>
</id>

<property name="agentname">
<column name="AGENTNAME" length="40" not-null="true"/>
</property>

<property name="city">
<column name="CITY" />
</property>


</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():


public void createAgentHibernate(AgentData data){
try{
System.out.println("HiberNATEEEEEEEEEEE");
SessionFactory factory = new Configuration().configure().buildSessionFactory();

org.hibernate.Session session=factory.openSession();

Transaction trans = session.beginTransaction();

session.save(data);

trans.commit();
} catch(Exception e){
e.printStackTrace();
}


Full stack trace of any exception that occurs:

[11/20/07 9:56:13:031 IST] 6fe3ea54 WebGroup E SRVE0026E: [Servlet Error]-[org/hibernate/Session]: java.lang.NoClassDefFoundError: org/hibernate/Session
at com.strutsweb.actions.AgentAction.execute(AgentAction.java:33)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)


Name and version of the database you are using:

IDM DB2 v8.1


The generated SQL (show_sql=true):

I could understand, what to give here.. I am learning Hibernate for the first time.

The table i created with SQL:
create table agent
(agentid char(6) not null primary key,
agentname varchar(40) not null,
city varchar(40)
);

Debug level Hibernate log excerpt:


I hope i have given the information all i know. Hope you all will extend the help in solving the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 4:47 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Quote:
java.lang.NoClassDefFoundError: org/hibernate/Session

Looks like you hibernate3.jar is not included in your application or classpath.

_________________
dont forget to rate !


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.