aspose file tools*
The moose likes Object Relational Mapping and the fly likes Getting Exception while executing hibernate plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting Exception while executing hibernate plugin" Watch "Getting Exception while executing hibernate plugin" New topic
Author

Getting Exception while executing hibernate plugin

Asif Usman
Greenhorn

Joined: Mar 16, 2009
Posts: 12
Hi all,

My name is Asif.

I am trying to Run one simple application using NetBeans IDE, and using Struts frame work with hibernate and MySQL database.
I am getting exection in hibernatePlugin.java while execting _factory = configuration.buildSessionFactory(); statement.

Here below is code of 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">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sampledb</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">asif</property>
<property name="connection.pool_size">3</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="show_sql">true</property>
<mapping resource="/Model/test.hbm.xml"/>
</session-factory>
</hibernate-configuration>

code of HibernatePlugin.java

try{

configFileURL = HibernatePlugIn.class.getResource(_configFilePath);
System.out.println("2*************************************");
context = servlet.getServletContext();
configuration = (new Configuration()).configure(configFileURL);
_factory = configuration.buildSessionFactory();
//Set the factory into session
System.out.println("5*************************************");
context.setAttribute(SESSION_FACTORY_KEY, _factory);

}catch(HibernateException e){
e.printStackTrace();
System.out.println("Error while initializing hibernate: " + e.getMessage());
}
System.out.println("*************************************");
}


its giving error and execution will hang when it executes below line

_factory = configuration.buildSessionFactory();

Erro Details:

2009-03-16 18:41:14 StandardContext[/WebApplication1]Marking servlet action as unavailable
2009-03-16 18:41:14 StandardContext[/WebApplication1]Servlet /WebApplication1 threw load() exception
javax.servlet.UnavailableException: org/aspectj/lang/Signature
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)


tomcat server log ...

Mar 16, 2009 7:09:20 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\Asif\My Documents\NetBeansProjects\WebApplication1\build\web\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
*************************************
**** Initilizing HibernatePlugIn **********
2*************************************

(its hanged here)





In browser i get this message.

HTTP Status 503 - Servlet action is currently unavailable


Please can anyone help on this. i am working on this from past 3 days but not getting what to do..

Thanks in advance!
Regards
Asif

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Hello Asif,

Welcome to JavaRanch!

Verify the value of _configFilePath. The error stacktrace doesn't seem to be informative. Why don't you try to isolate the problem? Make a small Java standalone programme and try to get a reference to session factory.

Apart from your problem refer this. http://faq.javaranch.com/java/UseCodeTags . It gives ease in reading the post.
 
Consider Paul's rocket mass heater.
 
subject: Getting Exception while executing hibernate plugin