File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Exception while executing hibernate plugin

 
Asif Usman
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic