-->
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.  [ 4 posts ] 
Author Message
 Post subject: Web Project accessing Java project with Hibernate
PostPosted: Fri Jan 27, 2006 4:02 pm 
Newbie

Joined: Thu Jun 09, 2005 4:13 pm
Posts: 7
Hello All,

I have a web project in MyEclipse where I have successfully added my Java project to it so I can use the method validateNetId(). However, this project and method use hibernate. Is there something else I need to do so a web project that does not use Hibernate can call on my Java project for the information needed? Below you will find my code and error message I receive in my JSP.

Thanks in advance.

Hibernate version: 2.1.8

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

public static String validateNetId(String setAuthorization){
String sNetId = "";
String sLNetId = setAuthorization;
String sAuthorized = "";
String sActive = "";
System.out.println("IN VALIDATE NETID:");
try{
Session session = SessionManager.currentSession();
System.out.println("BEFORE THE QUERY IN Employee validateNETID");

List myUsers = session.createQuery("from employee in class edu.uc.ucemployee.hibernate.Employee").list();
int increment = 0;

if (myUsers.size() > 0) {
for (Iterator i = myUsers.iterator(); i.hasNext() ; ) {

Employee nextUser = (Employee) i.next();
sNetId = nextUser.getNetId();
sActive = nextUser.getActive();
if(sNetId.equalsIgnoreCase(sLNetId) && sActive.equalsIgnoreCase("yes")){
sAuthorized = "YES";
}
increment++;
}
} else {
System.out.println("Didn't find any matching users..");
sAuthorized = "NO";
}
if(!(sAuthorized.equalsIgnoreCase("YES"))){
sAuthorized = "NO";

}
session.flush();
session.close();
}catch(HibernateException e){
System.out.println("RETRIEVAL really failed With Employee ADVISORS");
}finally{
try{
SessionManager.closeSession();
}catch(HibernateException e1){
//do nothing
}
}//end finally

return sAuthorized;
}

Full stack trace of any exception that occurs:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: net/sf/hibernate/HibernateException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.index_jsp._jspService(index_jsp.java:229)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NoClassDefFoundError: net/sf/hibernate/HibernateException
org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.



Name and version of the database you are using:

MySQL 4.1

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 4:48 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
The Hibernate classes must be deployed to your application server. You can configure this in the MyEclipse project setting of webapplications how to deal with jars in dependent projects.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 7:01 pm 
Newbie

Joined: Thu Jun 09, 2005 4:13 pm
Posts: 7
Hello,

Yea, that is what I am trying to figure out. I have tried every option/combination there is. Take a look at these screen shots and maybe you can tell me what I am missing. I think this should be a very simple task but it is not turning out that way.

Image

[/img]

Here is a shot of my work space where I dropped the jar file into the lib directory.

Image
[/img]

and one final view here is the project properties.

Image[/img]

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 5:29 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hello,

I do not know how stable this works. I also spent once quite some time.

Check if you are exporting the hibernate files. If if still does not work, create a user library containing all needed hibernate libraries and add it directly to your web application. You can find some notes about needed libraries in my tutorials.
If this helps, I would appreciate if you rate.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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