Quantcast

Cannot get grails app to run

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cannot get grails app to run

Jeremy Aston
Hi,

I am having quite a lot of problems getting grails apps to run - the only one I have had running is the sample blog under Tomcat.  All the others manifest a number of common issues.  The main one is the following:

Using either say the Ajax sample or a noddy app of my own I get the following exception when doing "grails run-app":

   [script] Context initialization failed
   [script] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource loaded through InputStream: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
   [script] java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
   [script]     at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
   [script]     at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
   [script]     at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
  ..... more stuff ....

A word with my mate Graeme Rocher and a look into the JIRA suggests this is likely to be caused by the wrong asm lib being picked up although I am at a loss to see where from.

The GRAILS_ANT_CLASSPATH being used is as follows:

/java/grails/lib/bsf.jar:/java/grails/lib/groovy-all-1.0-jsr-05-SNAPSHOT.jar:/java/grails/lib/org.mortbay.jetty.jar:/java/grails/lib/commons-logging.jar:/java/grails/lib/commons-el.jar:/java/grails/lib/javax.servlet.jar:/java/grails/lib/log4j-1.2.8.jar:/java/grails/lib/jasper-compiler.jar:/java/grails/lib/jasper-runtime.jar

I have Groovy 1.0 JSR 4 running as my Groovy.  Grails and Groovy bins are on my PATH but I have not CLASSPATH or LIB environment vars set.

I do have Hibernate 3.0 separately installed but again no JARs are linked to nor are any hib folders in my path.

I am running on Mac OS X Tiger with Java 5.

The grails targets are copying asm.jar etc from the GRAILS_HOME/lib folder to the tmp/war/WEB-INF/lib folder.  Interestingly I note that the grails build file refers to asm.jsr and asm-2.0.jar, the latter is not in the lib folder however.  The same is true for asm-utils.  Dunno if that is significant but there we go....

Does anyone have any suggestions please?  If I can get over this issue then we can move on to the next ones ;-)

I have tried running in Tomcat - I just get a difference stack trace...

javax.servlet.ServletException: Servlet.init() for servlet grails threw exception
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:613)

root cause

java.lang.IllegalStateException: BeanFactory not initialized - call 'refresh' before accessing beans via the context: org.springframework.web.context.support.XmlWebApplicationContext: display name [Root WebApplicationContext]; startup date [Thu Jan 01 01:00:00 GMT 1970]; child of [org.springmodules.beans.factory.drivers.xml.XmlWebApplicationContextDriver$1: display name [WebApplicationContext for namespace 'grails-servlet']; startup date [Sat Dec 17 00:45:11 GMT 2005]; child of [org.springframework.web.context.support.XmlWebApplicationContext: display name [Root WebApplicationContext]; startup date [Sat Dec 17 00:45:06 GMT 2005]; root of context hierarchy; config locations [/WEB-INF/applicationContext.xml]]; config locations [/WEB-INF/grails-servlet.xml]]; config locations []
    org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:101)
    org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:552)
    org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.createWebApplicationContext(GrailsDispatcherServlet.java:58)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:111)
    javax.servlet.GenericServlet.init(GenericServlet.java:211)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:613)

Not sure again what is happening here and there is nothing appearing in catalina.out (tc 5.5.9 btw) - I've not had a chance to look into this in more details either yet.

Many thanks in advance....

Jeremy Aston



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot get grails app to run

graemer
Hi jez,

I'm almost certain that the problem you're experiencing with the
"grails run-app" command is down to the non-embeddable version of
groovy with its own asm jars being on your path somewhere. Have you
checked your ant lib directory? If possible maybe modify your ant BASH
script to add the -verbose command onto the call to java so you can
see which jar is actually being loaded.

As for your second problem, it is strange that this only occurs on OS
X it may be a case of justing calling refresh on the app context as
the error message suggests. I will have a look at the code that loads
the spring app context and see if it can be improved to avoid this
problem

Graeme

On 17/12/05, Jeremy Aston <[hidden email]> wrote:

> Hi,
>
> I am having quite a lot of problems getting grails apps to run - the only
> one I have had running is the sample blog under Tomcat.  All the others
> manifest a number of common issues.  The main one is the following:
>
> Using either say the Ajax sample or a noddy app of my own I get the
> following exception when doing "grails run-app":
>
>    [script] Context initialization failed
>    [script]
> org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'sessionFactory' defined in resource loaded
> through InputStream: Initialization of bean failed; nested exception is
> java.lang.NoSuchMethodError:
> org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
>    [script] java.lang.NoSuchMethodError:
> org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
>    [script]     at
> net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
>    [script]     at
> net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
>    [script]     at
> net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
>   ..... more stuff ....
>
> A word with my mate Graeme Rocher and a look into the JIRA suggests this is
> likely to be caused by the wrong asm lib being picked up although I am at a
> loss to see where from.
>
> The GRAILS_ANT_CLASSPATH being used is as follows:
>
> /java/grails/lib/bsf.jar:/java/grails/lib/groovy-all-1.0-jsr-05-SNAPSHOT.jar:/java/grails/lib/org.mortbay.jetty.jar:/java/grails/lib/commons-logging.jar:/java/grails/lib/commons-el.jar:/java/grails/lib/javax.servlet.jar:/java/grails/lib/log4j-1.2.8.jar:/java/grails/lib/jasper-compiler.jar:/java/grails/lib/jasper-runtime.jar
>
> I have Groovy 1.0 JSR 4 running as my Groovy.  Grails and Groovy bins are on
> my PATH but I have not CLASSPATH or LIB environment vars set.
>
> I do have Hibernate 3.0 separately installed but again no JARs are linked to
> nor are any hib folders in my path.
>
> I am running on Mac OS X Tiger with Java 5.
>
> The grails targets are copying asm.jar etc from the GRAILS_HOME/lib folder
> to the tmp/war/WEB-INF/lib folder.  Interestingly I note that the grails
> build file refers to asm.jsr and asm-2.0.jar, the latter is not in the lib
> folder however.  The same is true for asm-utils.  Dunno if that is
> significant but there we go....
>
> Does anyone have any suggestions please?  If I can get over this issue then
> we can move on to the next ones ;-)
>
> I have tried running in Tomcat - I just get a difference stack trace...
>
> javax.servlet.ServletException: Servlet.init() for servlet grails threw
> exception
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>     java.lang.Thread.run(Thread.java:613)
>
> root cause
>
> java.lang.IllegalStateException: BeanFactory not initialized - call
> 'refresh' before accessing beans via the context:
> org.springframework.web.context.support.XmlWebApplicationContext:
> display name [Root WebApplicationContext]; startup date [Thu Jan 01 01:00:00
> GMT 1970]; child of
> [org.springmodules.beans.factory.drivers.xml.XmlWebApplicationContextDriver$1:
> display name [WebApplicationContext for namespace 'grails-servlet']; startup
> date [Sat Dec 17 00:45:11 GMT 2005]; child of
> [org.springframework.web.context.support.XmlWebApplicationContext:
> display name [Root WebApplicationContext]; startup date [Sat Dec 17 00:45:06
> GMT 2005]; root of context hierarchy; config locations
> [/WEB-INF/applicationContext.xml]]; config locations
> [/WEB-INF/grails-servlet.xml]]; config locations []
>
> org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:101)
>
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:552)
>
> org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.createWebApplicationContext(GrailsDispatcherServlet.java:58)
>
> org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
>
> org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
>
> org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:111)
>
> javax.servlet.GenericServlet.init(GenericServlet.java:211)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>     java.lang.Thread.run(Thread.java:613)
>
> Not sure again what is happening here and there is nothing appearing in
> catalina.out (tc 5.5.9 btw) - I've not had a chance to look into this in
> more details either yet.
>
> Many thanks in advance....
>
>
>
> Jeremy Aston
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Cannot get grails app to run

Jeremy Aston
Thanks Graeme, Ant was the problem - staring me in the face but there  
we go!  I had groovy jsr 4 and the the asm libs in my ant/lib  
folder.  Jetty runs fine now (to a point - see below) and I could see  
some minor bugs in my init code.  Fixing these also means that Tomcat  
works as the same as Jetty - obviously Tomcat is exposing errors  
differently.

The only issue for me is that I use those libs elsewhere in Ant tasks  
so I have to muck around with some other build files to get Ant  
nicely generic now.

Back to grails.... Although I can get Jetty to run ok now I am still  
having problems.  The example code does not seem to work correctly  
(missing method signatures, JSP compile errors under Jetty etc) but  
what I will do is take this offline with you, work out what the  
problems are and then work through any updates to the documentation.

Cheers

jez


On 18 Dec 2005, at 21:18, Graeme Rocher wrote:

> Hi jez,
>
> I'm almost certain that the problem you're experiencing with the
> "grails run-app" command is down to the non-embeddable version of
> groovy with its own asm jars being on your path somewhere. Have you
> checked your ant lib directory? If possible maybe modify your ant BASH
> script to add the -verbose command onto the call to java so you can
> see which jar is actually being loaded.
>
> As for your second problem, it is strange that this only occurs on OS
> X it may be a case of justing calling refresh on the app context as
> the error message suggests. I will have a look at the code that loads
> the spring app context and see if it can be improved to avoid this
> problem
>
> Graeme
>
> On 17/12/05, Jeremy Aston <[hidden email]> wrote:
>
>> Hi,
>>
>> I am having quite a lot of problems getting grails apps to run -  
>> the only
>> one I have had running is the sample blog under Tomcat.  All the  
>> others
>> manifest a number of common issues.  The main one is the following:
>>
>> Using either say the Ajax sample or a noddy app of my own I get the
>> following exception when doing "grails run-app":
>>
>>    [script] Context initialization failed
>>    [script]
>> org.springframework.beans.factory.BeanCreationException:
>> Error creating bean with name 'sessionFactory' defined in resource  
>> loaded
>> through InputStream: Initialization of bean failed; nested  
>> exception is
>> java.lang.NoSuchMethodError:
>> org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/
>> lang/String;[Ljava/lang/String;Ljava/lang/String;)V
>>    [script] java.lang.NoSuchMethodError:
>> org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/
>> lang/String;[Ljava/lang/String;Ljava/lang/String;)V
>>    [script]     at
>> net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
>>    [script]     at
>> net.sf.cglib.core.KeyFactory$Generator.generateClass
>> (KeyFactory.java:173)
>>    [script]     at
>> net.sf.cglib.core.DefaultGeneratorStrategy.generate
>> (DefaultGeneratorStrategy.java:25)
>>   ..... more stuff ....
>>
>> A word with my mate Graeme Rocher and a look into the JIRA  
>> suggests this is
>> likely to be caused by the wrong asm lib being picked up although  
>> I am at a
>> loss to see where from.
>>
>> The GRAILS_ANT_CLASSPATH being used is as follows:
>>
>> /java/grails/lib/bsf.jar:/java/grails/lib/groovy-all-1.0-jsr-05-
>> SNAPSHOT.jar:/java/grails/lib/org.mortbay.jetty.jar:/java/grails/
>> lib/commons-logging.jar:/java/grails/lib/commons-el.jar:/java/
>> grails/lib/javax.servlet.jar:/java/grails/lib/log4j-1.2.8.jar:/
>> java/grails/lib/jasper-compiler.jar:/java/grails/lib/jasper-
>> runtime.jar
>>
>> I have Groovy 1.0 JSR 4 running as my Groovy.  Grails and Groovy  
>> bins are on
>> my PATH but I have not CLASSPATH or LIB environment vars set.
>>
>> I do have Hibernate 3.0 separately installed but again no JARs are  
>> linked to
>> nor are any hib folders in my path.
>>
>> I am running on Mac OS X Tiger with Java 5.
>>
>> The grails targets are copying asm.jar etc from the GRAILS_HOME/
>> lib folder
>> to the tmp/war/WEB-INF/lib folder.  Interestingly I note that the  
>> grails
>> build file refers to asm.jsr and asm-2.0.jar, the latter is not in  
>> the lib
>> folder however.  The same is true for asm-utils.  Dunno if that is
>> significant but there we go....
>>
>> Does anyone have any suggestions please?  If I can get over this  
>> issue then
>> we can move on to the next ones ;-)
>>
>> I have tried running in Tomcat - I just get a difference stack  
>> trace...
>>
>> javax.servlet.ServletException: Servlet.init() for servlet grails  
>> threw
>> exception
>>
>> org.apache.catalina.valves.ErrorReportValve.invoke
>> (ErrorReportValve.java:105)
>>
>> org.apache.catalina.connector.CoyoteAdapter.service
>> (CoyoteAdapter.java:148)
>>
>> org.apache.coyote.http11.Http11Processor.process
>> (Http11Processor.java:856)
>>
>> org.apache.coyote.http11.Http11Protocol
>> $Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>>
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket
>> (PoolTcpEndpoint.java:527)
>>
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt
>> (LeaderFollowerWorkerThread.java:80)
>>
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
>> (ThreadPool.java:684)
>>     java.lang.Thread.run(Thread.java:613)
>>
>> root cause
>>
>> java.lang.IllegalStateException: BeanFactory not initialized - call
>> 'refresh' before accessing beans via the context:
>> org.springframework.web.context.support.XmlWebApplicationContext:
>> display name [Root WebApplicationContext]; startup date [Thu Jan  
>> 01 01:00:00
>> GMT 1970]; child of
>> [org.springmodules.beans.factory.drivers.xml.XmlWebApplicationContext
>> Driver$1:
>> display name [WebApplicationContext for namespace 'grails-
>> servlet']; startup
>> date [Sat Dec 17 00:45:11 GMT 2005]; child of
>> [org.springframework.web.context.support.XmlWebApplicationContext:
>> display name [Root WebApplicationContext]; startup date [Sat Dec  
>> 17 00:45:06
>> GMT 2005]; root of context hierarchy; config locations
>> [/WEB-INF/applicationContext.xml]]; config locations
>> [/WEB-INF/grails-servlet.xml]]; config locations []
>>
>> org.springframework.context.support.AbstractRefreshableApplicationCon
>> text.getBeanFactory(AbstractRefreshableApplicationContext.java:101)
>>
>> org.springframework.context.support.AbstractApplicationContext.getBea
>> n(AbstractApplicationContext.java:552)
>>
>> org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.create
>> WebApplicationContext(GrailsDispatcherServlet.java:58)
>>
>> org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo
>> ntext(FrameworkServlet.java:250)
>>
>> org.springframework.web.servlet.FrameworkServlet.initServletBean
>> (FrameworkServlet.java:219)
>>
>> org.springframework.web.servlet.HttpServletBean.init
>> (HttpServletBean.java:111)
>>
>> javax.servlet.GenericServlet.init(GenericServlet.java:211)
>>
>> org.apache.catalina.valves.ErrorReportValve.invoke
>> (ErrorReportValve.java:105)
>>
>> org.apache.catalina.connector.CoyoteAdapter.service
>> (CoyoteAdapter.java:148)
>>
>> org.apache.coyote.http11.Http11Processor.process
>> (Http11Processor.java:856)
>>
>> org.apache.coyote.http11.Http11Protocol
>> $Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>>
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket
>> (PoolTcpEndpoint.java:527)
>>
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt
>> (LeaderFollowerWorkerThread.java:80)
>>
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
>> (ThreadPool.java:684)
>>     java.lang.Thread.run(Thread.java:613)
>>
>> Not sure again what is happening here and there is nothing  
>> appearing in
>> catalina.out (tc 5.5.9 btw) - I've not had a chance to look into  
>> this in
>> more details either yet.
>>
>> Many thanks in advance....
>>
>>
>>
>> Jeremy Aston
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Cannot get grails app to run

Guillaume Laforge-2
In reply to this post by graemer
On 18/12/05, Graeme Rocher <[hidden email]> wrote:
> I'm almost certain that the problem you're experiencing with the
> "grails run-app" command is down to the non-embeddable version of
> groovy with its own asm jars being on your path somewhere. Have you
> checked your ant lib directory? If possible maybe modify your ant BASH
> script to add the -verbose command onto the call to java so you can
> see which jar is actually being loaded.

It makes me wonder... what if we'd put our own trimmed down version of
Ant in the distribution so that we avoid having such classpath / ant
problems?
I think some projects like RIFE do that, and bring their own version
of Ant with them, for consistency of the build.

--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Cannot get grails app to run

graemer
On 19/12/05, Guillaume Laforge <[hidden email]> wrote:

> On 18/12/05, Graeme Rocher <[hidden email]> wrote:
> > I'm almost certain that the problem you're experiencing with the
> > "grails run-app" command is down to the non-embeddable version of
> > groovy with its own asm jars being on your path somewhere. Have you
> > checked your ant lib directory? If possible maybe modify your ant BASH
> > script to add the -verbose command onto the call to java so you can
> > see which jar is actually being loaded.
>
> It makes me wonder... what if we'd put our own trimmed down version of
> Ant in the distribution so that we avoid having such classpath / ant
> problems?
> I think some projects like RIFE do that, and bring their own version
> of Ant with them, for consistency of the build.

Agreed.. could prevent lots of painful debugging

>
> --
> Guillaume Laforge
> Groovy Project Manager
> http://glaforge.free.fr/blog/groovy
>
Loading...