iKT
iKT

Reputation: 91

Tomcat ClassNotFound exception when trying to run Application

I have a grails application that I was running fine until yesterday when I decided to download an Email plugin into the STS. The download failed for some reason and I got around the issue with a few searches around. Once I resolved the plugin issues, my application stopped to work. I tried a lot of things including re-installing STS. I was maintaining a GIT repository and I reverted all my changes to the last known working one. This did not help either. I created a new Grails project and copied all my source files over there and everything was working fine.

I compared all the build paths and properties files between the working one and the non working one and they seem to be the same except the .classpath which is getting changed every time I try to run the application like the below

+       <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
        <classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSP
-       <classpathentry kind="src" path=".link_to_grails_plugins/tomcat-1.3.7/sr
-               <attributes>
-                       <attribute name="com.springsource.sts.grails.core.SOURCE
-               </attributes>
-       </classpathentry>

Can anyone please help me with where I should be looking to get this application back on track??

Here is the Error that I get:

    Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/mymac/springsource/grails-1.3.7/
Base Directory: /Users/mymac/MyProjects/MyGitSources/books_grails/books
Resolving dependencies...
Dependencies resolved in 862ms.
Running script /Users/mymac/springsource/grails-1.3.7/scripts/RunApp.groovy
Environment set to development
     [copy] Copying 1 file to /Users/mymac/.grails/1.3.7/projects/books
WARNING: No default container found, installing Tomcat..
Resolving plugin tomcat. Please wait...
Error executing script RunApp: java.lang.ClassNotFoundException: org.grails.tomcat.TomcatServerFactory
java.lang.ClassNotFoundException: org.grails.tomcat.TomcatServerFactory
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.ClassNotFoundException: org.grails.tomcat.TomcatServerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java_lang_ClassLoader$loadClass.call(Unknown Source)
    at _GrailsRun_groovy$_loadServerFactory_closure11.doCall(_GrailsRun_groovy:85)
    at _GrailsRun_groovy.loadServerFactory(_GrailsRun_groovy:101)
    at _GrailsRun_groovy.this$4$loadServerFactory(_GrailsRun_groovy)
    at _GrailsRun_groovy$this$4$loadServerFactory.callCurrent(Unknown Source)
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:114)
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
    at RunApp$_run_closure1.doCall(RunApp:33)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    ... 10 more
--- Nested Exception ---
java.lang.ClassNotFoundException: org.grails.tomcat.TomcatServerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java_lang_ClassLoader$loadClass.call(Unknown Source)
    at _GrailsRun_groovy$_loadServerFactory_closure11.doCall(_GrailsRun_groovy:85)
    at _GrailsRun_groovy.loadServerFactory(_GrailsRun_groovy:101)
    at _GrailsRun_groovy.this$4$loadServerFactory(_GrailsRun_groovy)
    at _GrailsRun_groovy$this$4$loadServerFactory.callCurrent(Unknown Source)
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:114)
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
    at RunApp$_run_closure1.doCall(RunApp:33)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
Error executing script RunApp: java.lang.ClassNotFoundException: org.grails.tomcat.TomcatServerFactory

[UPDATE]:

When I tried to install the mail plugin in my new working project again, The same error is reproduced if I try to run my application. Somehow the plugin is screwing up my application. Now I don't know how the plugins are installed and what they change in a project :-(

Thanks!!

Upvotes: 0

Views: 1197

Answers (1)

iKT
iKT

Reputation: 91

Posting it as an answer just in case anybody needs to find a solution...

I removed all the projects from under ~/.grails and also cleared the files that had my Project references. I re-imported my project into STS and it started to work again.

I guess the issue was because of the mail plugin. Since my maven repositories was commented out in the BuildConfig.groovy

//mavenLocal()
//mavenCentral()

installation of plugin failed and somehow messed up my project. I created a temp project, installed these plugins with the above lines uncommented, cleaned the original project as mentioned above and re-built my project.

Since now my plugins are locally available, I was able to install them into my main project without any hassle.

Though not a clean one and not sure if there is an existing issue with the failed plugin installations, I am posting this in case anyone runs into the same issue again!

Thanks!!

Upvotes: 1

Related Questions