2.6.0-rc3 and Jetty's WebAppContext (jetty-web.xml)

3,229 views
Skip to first unread message

Thad Humphries

unread,
Jan 21, 2014, 4:12:52 PM1/21/14
to google-we...@googlegroups.com
In short: How to I configure my GWT 2.6.0-rc* webapp launch in Eclipse and process webapp context settings for Jetty?

I'm giving GWT 2.6.0-rc3 a trial run using Maven and SuperDevMode. I launch the code server in a console with "mvn clean generate-sources gwt:run-codeserver" and launch my webapp from Eclipse.

With GWT 2.5.1, I created src/main/webapp/WEB-INF/jetty-web.xml such as

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" 

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="initParams">
    <New class="java.util.HashMap">
      <Put name="app.tmpdir">/Users/thad/temp</Put>
      <Put name="cleanup.interval">86400</Put>
      <Put name="slf4j-init-file">/Users/thad/temp/slf4j.properties</Put>
    </New>
  </Set>
       
</Configure>

/Users/thad/temp/slf4j.properties declares "log4j.appender.MYAPP.File=/Users/thad/temp/mobile-slf4j.log" so I don't have to go chasing my log fill around my Mac's /var/folders directory.

This all works great with GWT 2.5.1 (as it did on an earlier project with GWT 2.5.1 using Ant and DevMode). And all this without any Jetty dependency in my pom.xml

However when I try GWT 2.6.0-rc3 (and GWT 2.6.0-rc1) a try, launching my webapp in Eclipse I get various errors in my console. Jetty does not read jetty-web.xml and my log file is no where to be found.

With the jetty-web.xml above, I get

[WARN] Server resource 'org/eclipse/jetty/xml/configure_6_0.dtd' could not be found in the web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/opt/gwt-2.6.0-rc3/gwt-dev.jar' to the web app classpath for this session
   For additional info see: file:/opt/gwt-2.6.0-rc3/doc/helpInfo/webAppClassPath.html
Starting Jetty on port 8888
   [WARN] Unable to process jetty-web.xml
java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppContext
at java.lang.ClassLoader.findClass(ClassLoader.java:531)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:407)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:100)
....

BTW, I see no such [WARN] on gwt-dev.jar with GWT 2.5.1 (gwt-dev is "<scope>provided</scope>" in my pom.xml).

On a hunch, I tried changing <Configure class="org.mortbay.jetty.webapp.WebAppContext"> to <Configure class="org.eclipse.jetty.webapp.WebAppContext"> but that gives the error below and the app fails to start:

[WARN] Server resource 'org/eclipse/jetty/xml/configure_7_6.dtd' could not be found in the web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/opt/gwt-2.6.0-rc3/gwt-dev.jar' to the web app classpath for this session
   For additional info see: file:/opt/gwt-2.6.0-rc3/doc/helpInfo/webAppClassPath.html
Starting Jetty on port 8888
   [WARN] Failed startup of context c.g.g.d.s.j.WebAppContextWithReload{/,file:/Users/thad/workspace/Mobile/target/Mobile-1.0-SNAPSHOT/},/Users/thad/workspace/Mobile/target/Mobile-1.0-SNAPSHOT
java.lang.IllegalArgumentException: Object of class 'com.google.gwt.dev.shell.jetty.JettyLauncher.WebAppContextWithReload' is not of type 'org.eclipse.jetty.webapp.WebAppContext'. Object Class and type Class are from different loaders.
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:323)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:281)
at org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:103)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:468)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1237)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
...

What's the magic? 


Thomas Broyer

unread,
Jan 22, 2014, 11:53:27 AM1/22/14
to google-we...@googlegroups.com
It's "broken" (between quotes, because I don't think GWT ever willfully supported the use-case, so it was a "feature" but rather just "luck")

Thad Humphries

unread,
Jan 22, 2014, 3:15:46 PM1/22/14
to google-we...@googlegroups.com
Thanks, Thomas. I understand the reasoning, but I don't agree with it. There are things I set in my app's context that I'd like to user during development without the hassle of compiling or using -noserver and losing the Eclipse debugger. If Jetty configuration can be put back, it would be greatly appreciated.

Jens

unread,
Jan 22, 2014, 4:25:43 PM1/22/14
to google-we...@googlegroups.com
or using -noserver and losing the Eclipse debugger

You don't loose Eclipse debugger when using -noserver. Just launch your app server of choice with debug enabled and then connect to it with Eclipse. You can also configure Eclipse to launch a Jetty of your choice (or any other supported app server) and let Eclipse deploy your application automatically to that Jetty instance (Eclipse WTP)

Personally I pretty much always use -noserver just because I want to use the same app server during development as for production. I don't think I loose anything (development speed, debugging, hot re-deploy) compared to using the build in Jetty of GWT.

-- J.

Thad Humphries

unread,
Jan 22, 2014, 5:46:44 PM1/22/14
to google-we...@googlegroups.com
Thanks, Jens. It's almost coming together, but not quite.

I've got Tomcat started with debug and I've got Eclipse linked to it (per http://wiki.apache.org/tomcat/FAQ/Developing). However when I make a change to my servlet, I don't see it reflected in the run. 

I've got the Eclipse Web Application DevMode -noserver option and -war /Library/Tomcat/catalina/webapps/myapp
I changed a line of debug in my servlet and ran this. The servlet's class file does not change, and the new log message does not appear. How do I make this work?

Thad Humphries

unread,
Jan 24, 2014, 12:13:25 PM1/24/14
to google-we...@googlegroups.com
Hm... Okay, it's working on this machine. 

I start my app with Maven from a console (`mvn clean generate-sources gwt:run-codeserver`) and from Eclipse start a debug Remote Java Application for my project. 

Before all this (as in yesterday) I ran Web Application in Eclipse with the -noserver flag and killed it. The program arguments box looks like

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -codeServerPort 9997 -noserver -war
/Library/Tomcat/catalina/webapps/myapp -startupUrl http://localhost:8080/myapp -logLevel TRACE 
com.corp.myapp.MyApp

(Eclipse insists on putting in all that you see before "-noserver" though I delete it.)

In Chrome I open an new tab, go to http://localhost:8080/myapp, click my Dev Mode On bookmark and Compile. I log in to my app. I can get to debug in my servlet and see the log written.

I log out and change a log entry in my servlet. I open a new tab in Chrome, etc., and I see the new message written in my log file. Interestingly (to me, at least) is that the date and time of the servlet class in /Library/Tomcat/catalina/webapps/myapp/WEB-INF/classes is still from yesterday. The update has occurred to the class file in target/MyApp-1.0-SNAPSHOT/WEB-INF/classes. That seems magical to me. Isn't my app running from Tomcat?

And, yes, if I make a change to, say, a *.ui.xml file and press my Compile bookmark, the change happens.

I'm a bit uncomfortable with the magic described above, but it is working. I'm working remote today, but when I'm back with my in my on Monday, I'll compare settings on that system and see why it wasn't working there. You can bet I'll ask again if something goes wrong (and I have other projects to convert to SuperDevMode).

Meanwhile if anyone cares to explain what I'm seeing with the *.class file updates, I'd appreciate it.

Jens

unread,
Jan 24, 2014, 3:48:01 PM1/24/14
to google-we...@googlegroups.com
I log out and change a log entry in my servlet. I open a new tab in Chrome, etc., and I see the new message written in my log file. Interestingly (to me, at least) is that the date and time of the servlet class in /Library/Tomcat/catalina/webapps/myapp/WEB-INF/classes is still from yesterday. The update has occurred to the class file in target/MyApp-1.0-SNAPSHOT/WEB-INF/classes. That seems magical to me. Isn't my app running from Tomcat?

Well, if you start Tomcat through Maven using the tomcat-maven-plugin then the folder target/MyApp-1.0-SNAPSHOT will be deployed to Tomcat via Maven as thats the exploded war output folder of your Maven project. Also Eclipse has most likely configured itself to output class files into target/MyApp-1.0-SNAPSHOT/WEB-INF/classes because Eclipse knows you are using Maven.

-- J.

Thad Humphries

unread,
Jan 25, 2014, 2:32:33 PM1/25/14
to google-we...@googlegroups.com
I'm not using the tomcat-maven-plugin. I'm managing Tomcat in a separate console using the $CATALINA_HOME/bin/startup.sh and shutdown.sh scripts (having modified startup.sh to add jpda to the command).

I can see that Eclipse is writing to target/MyApp-1.0-SNAPSHOT/WEB-INF/classes. What I can't understand is how Tomcat sees those changes. $CATALINA_HOME/webapps/myapp/WEB-INF/classes doesn't change, but that is certainly what I'm pointing my browser to.

joerg.h...@googlemail.com

unread,
Feb 27, 2014, 7:25:48 PM2/27/14
to google-we...@googlegroups.com
Hi there,
GWT 2.6.0 is out and officially released and the problem is still there. It used to work fine before with 2.5. Also I read that dev-mode plugin may not be supported in next firefox version. This is all a real pity:
The whole thing about GWT is that you can do RIAs in pure Java with all the Java tooling and eco-system. I want to debug my Java client code in Eclipse. If I have to drop all this and move to SuperDevMode I think that all the investment I did in the last years into GWT have been in vain. Then I can also go for AngularJS and harmonize with JS hell...

Any chances for hope in the future?

Thanks and regards
  Jörg

Jens

unread,
Feb 28, 2014, 3:54:36 AM2/28/14
to google-we...@googlegroups.com
GWT 2.6.0 is out and officially released and the problem is still there. It used to work fine before with 2.5.

It is not a real issue as it was never really officially supported. If you want to configure your server you should use -noserver and a local jetty distribution on your host. Using -noserver you don't loose productivity.

 
Also I read that dev-mode plugin may not be supported in next firefox version.

DevMode does not work anymore in FireFox 27+. However it has been updated to work with FireFox 24 ESR.
 

This is all a real pity:
The whole thing about GWT is that you can do RIAs in pure Java with all the Java tooling and eco-system. I want to debug my Java client code in Eclipse.

There is some work going on to support debugging in your IDE when using SuperDevMode, although you probably will not have the full feature set you currently have in Java debugging.


 
Any chances for hope in the future?

Not for classic DevMode. But SuperDevMode can only get better (and it is already pretty good).


-- J. 
Reply all
Reply to author
Forward
0 new messages