views:

358

answers:

3

Hello, while trying to deploy a Grails application into tomcat6 I ran into some problems: I used the grails war command to build up a war, then copied it to var/lib/tomcat6/webapps and tried to restart the container.

I had to change default Tomcat policy to skip security exceptions, since I couldn't access environment variable (like grails.env), then tried again but it gives me an exception related to instantiating something, but it's not clear where should I try to fix the error, according to tomcat6 logs the problem is:

SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsC$ org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext$ at java.lang.Thread.run(Thread.java:619) Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [Hiberna$ ... 1 more Caused by: java.lang.NoClassDefFoundError: org.hibernate.cfg.Environment

It seems like it's unable to load org.hibernate.cfg.Environment class.

I checked the applicationContext.xml and it refers to grails.xml to search for plugins, in this last file I actually have HibernateGrailsPlugin.

Where should I look to find if the plugin is present?

A: 

Not a grails guy, but you seem to be missing the hibernate-core dependencies. You could try to drop that .jar into your server shared lib and see if that resolves your problem. Ideally this would be located somewhere in your grails war libs but I'm not sure where.

lucas
+3  A: 

I have not had your specific problem, I would suggest you try running

grails clean

Then try

grails run-war

If it's runs successfully then try deploying it.

I have found when you get weird errors from grails it's time to do a clean.

Scott Warren
Running grails clean beforehand did the trick - Thank you very much!
Peter
A: 

Placing the jar file hibernate-core-3.3.2.GA.jar in tomcat/lib did the trick. Thanks Buddy!

Strange thing is: I had the older version of the same jar file in the war, but it was giving exception. The application works fine from within NetBeans using Jetty, but deploying it on tomcat gives this problem.

Anyways, it's working now by placing the jar file hibernate-core-3.3.2.GA.jar in tomcat/lib.

Thanks again

Bokhari