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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate-servlet" Watch "hibernate-servlet" New topic
Author

hibernate-servlet

nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Hi friends,
I am getting following exception and my cde is as given below.please any one could help to locate the fault.

org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:80)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:62)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:460)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:155)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at mypack.PdServlet.init(PdServlet.java:35)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at mypack.PdServlet.doPost(PdServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)



Thanks..


SCJP 6.0
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

nimesh hindocha wrote:I am getting following exception...

What is that?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Hi
I want to know how to do hibernate configuration in this servlet based hibernate application.
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
nimesh hindocha wrote:Hi
I want to know how to do hibernate configuration in this servlet based hibernate application.
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:80)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:62)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:460)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:155)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at mypack.PdServlet.init(PdServlet.java:35)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at mypack.PdServlet.doPost(PdServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

I suggest you start here. It's a complete example with servlet. You can ignore the Maven configurations if you already have the required jar files etc... Specially look for the hibeernate.cfg.xml and the hbm files where you need to setup with the appropriate values for your application.
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Hi,
How to configure when the application is deployed because apache tomcat looks in deployment descriptor that is web.xml.
so how i can direct it to hibernate.cfg.xml file from web.xml for configuration.
below is my configuration file. Please give some way.
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Hi,
I have understood the problem but i am unable to fix it..so anybody can help please.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

..so how i can direct it to hibernate.cfg.xml file from web.xml for configuration....

You don't. In this example when you first hit the servlet hibernate will initialize. Just make sure you have the hibernate.cfg.xml file directly inside the WEB-INF/classes directory. Of course this is to test the hibernate and if you use in a real application you might bind the hibernate service to JNDI in the server startup, initialized in a listener etc...
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Thanks Vijitha for your reply.
I wanted to know if i keep hibernate.cfg.xml file directly inside the WEB-INF/classes do i have to write context path in server.xml file and i would also like to know second approach which you have mentioned

if you use in a real application you might bind the hibernate service to JNDI in the server startup, initialized in a listener etc...


again thanks for reply...
nimesh hindocha
Greenhorn

Joined: Aug 11, 2010
Posts: 20
Hi vijitha,
I have kept hibernate.cfg.xml file as said by you but i am getting the same exception again and i am giving server.xml file might be needed .I have attached the project structure and i am using eclipse.


I am waiting for your reply....


[Download project structure.bmp] Download

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

nimesh hindocha wrote:Thanks Vijitha for your reply.
I wanted to know if i keep hibernate.cfg.xml file directly inside the WEB-INF/classes do i have to write context path in server.xml file and i would also like to know second approach which you have mentioned

if you use in a real application you might bind the hibernate service to JNDI in the server startup, initialized in a listener etc...


again thanks for reply...


Hibernate doesn't know anything about the container you deploy it in (or indeed if there is a container used at all) so context.xml (by which I assume you are referring to a Tomcat file?) is unrelated to Hibernate.

Your configuration file needs to be on the classpath. If you don't explicitly state where it is (see the Hibernate JavaDocs for the Configuration class) Hibernate looks in the default package.

The JNDI-bound SessionFactory Vijitha mentions is explained in the Hibernate documentation here.

The error message you are seeing:

org.hibernate.HibernateException: Hibernate Dialect must be explicitly set

suggest your configuration does not include a Dialect. Given the one you've posted does define one, I would double check you are using the one you think you are.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
Consider Paul's rocket mass heater.
 
subject: hibernate-servlet