can't use Jetty with Grails?
After I did an uninstall-plugin tomcat and install-plugin jetty, IntelliJ can't compile my project. It fails on JettyServer.groovy, complaining about missing classes from org.mortbay.jetty. But grails run-app works outside of IntelliJ.
It looks like IntelliJ isn't recognizing the jetty plugin's dependencies. Its dependencies.groovy lists several required jars, including jetty:6.1.21. That jar is in my ~/.ivy2/cache, but IntelliJ doesn't seem to use it when trying to compile the plugin.
How can I fix this?
(IntelliJ 9.0.1, Grails 1.2.2, Fedora 12, Sun JDK 1.6.0_19)
Please sign in to leave a comment.
First, please use 9.0.2 EAP
(http://confluence.jetbrains.net/display/IDEADEV/Maia+EAP). Second,
there's an action on the Grails module's node popup menu in the
project/grails view called 'Synchronize Grails dependencies'. Try it.
No joy: I tried 95.54 (9.0.2rc3) and the Synchronize Grails dependencies, but it didn't help. Compile still gives me:
Information:Compilation completed with 6 errors and 0 warnings
Information:6 errors
Information:0 warnings
/home/jdb/.grails/1.2.2/projects/wcy/plugins/jetty-1.2-SNAPSHOT/src/groovy/org/grails/jetty/JettyServer.groovy
Error:Error:line (20)unable to resolve class org.mortbay.jetty.webapp.WebAppContext
Error:Error:line (21)unable to resolve class org.mortbay.jetty.nio.SelectChannelConnector
Error:Error:line (22)unable to resolve class org.mortbay.jetty.Server
Error:Error:line (23)unable to resolve class org.mortbay.jetty.Connector
Error:Error:line (24)unable to resolve class org.mortbay.jetty.security.SslSocketConnector
Error:Error:line (180)unable to resolve class org.mortbay.jetty.plus.webapp.EnvConfiguration
I also tried creating a new, empty project with 95.54 just now, compiled OK, uninstalled tomcat, installed jetty, Syncronized Grails dependencies, and it had the same compile error. (see attached consoleOutput.txt) So, this seems to be reproducible. The sync says it recognizes the jetty jar for "Compile", though.
Should I try manually adding jetty jars inside the ivy cache to the xxx-grailsPlugins module's Grails User Library? It has "Compile" Scope, at least. But, I don't know where it came from. It's not in my Libraries tab. Is it my "grails-1.2.2" Global Library? (Why is Grails a library, not an SDK?)
Attachment(s):
consoleOutput.txt.zip
IntelliJ was able to compile after I added the following jars via the GUI. I don't know how long this configuration will last, though.
<orderEntry type="module-library" exported="">
<library name="Grails User Library">
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty-util/jars/jetty-util-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty/jars/jetty-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty-plus/jars/jetty-plus-6.1.21.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
I just noticed that I have jetty jars (as follows) in my project's .iml, but the Grails User Library in the -grailsPlugins.iml was empty until I manually added the 3 jetty jars. I also got a link in the upper-right corner of the editor asking something about reloading Grails dependencies from disk, which I approved, but I'm not sure what that did. It didn't change the -grailsPlugins.iml, at least.
<orderEntry type="module-library">
<library name="Grails User Library">
<CLASSES>
<root url="file://$MODULE_DIR$/lib" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty/jars/jetty-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty-util/jars/jetty-util-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/servlet-api/jars/servlet-api-2.5-20081211.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty-plus/jars/jetty-plus-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/geronimo-spec/geronimo-spec-jta/jars/geronimo-spec-jta-1.0.1B-rc4.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jetty-naming/jars/jetty-naming-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/javax.mail/mail/jars/mail-1.4.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/tomcat/jasper-compiler-jdt/jars/jasper-compiler-jdt-5.5.15.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.eclipse.jdt/core/jars/core-3.1.1.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/tomcat/jasper-compiler/jars/jasper-compiler-5.5.15.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/org.mortbay.jetty/jsp-api-2.0/jars/jsp-api-2.0-6.1.21.jar!/" />
<root url="jar://$MODULE_DIR$/../../../.ivy2/cache/tomcat/jasper-runtime/jars/jasper-runtime-5.5.15.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
</library>
</orderEntry>
By the way, the tomcat jars probably shouldn't be there, since I uninstalled that plugin. But, I'm glad that IntelliJ hasn't removed the jetty jars that I manually configured in the -grailsPlugins module.
Now I see the problem, thank you for thorough investigation. I've
created an request for it which hopefully will be fixed in 9.0.x:
http://youtrack.jetbrains.net/issue/IDEA-54082.
> Why is Grails a library, not an SDK?
For many reasons. The module would have 2 SDKs: Grails and JDK. It would
make it impossible to add yet another SDK-like thing, e.g. Scala, Flex
or Python. Finally, there's a Grails-Maven plugin where the same Grails
jars don't lie as prescribed but instead come from various places in
pom.xml and just appear in the module dependencies. Therefore Grails
support functions as long as there are all the necessary jars in the
classpath, and doesn't depend on the fact they are organized into an SDK.