help needed on gwt-maven-plugin

1 view
Skip to first unread message

nicolas.deloof

unread,
Jan 20, 2009, 5:04:50 AM1/20/09
to Google Web Toolkit Contributors
Hi,

the gwt-maven-plugin development has a Classloader issue with tomcat
embedded
http://jira.codehaus.org/browse/MGWT-14

We have no idea of what's wrong, so any of you with ClassLoader /
Tomcat embedded skills would be welcome to help if possible.
Please apologies for "spaming" this group for a maven-dev related
issue.


The plugin generates a command script to lanch the GWT Shell from
command line. To bypass windows command line length limitation, it
uses a "booter" to setup an URLClassLoader with all project/gwt
libraries and run the GWTShell.main().

But the shell fails with :

[WARN] StandardContext[]Error loading WebappClassLoader
delegate: false
repositories:
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@1ba34f2
com.google.gwt.dev.shell.GWTShellServlet
java.lang.ClassNotFoundException:
com.google.gwt.dev.shell.GWTShellServlet
org.apache.catalina.loader.WebappClassLoader.loadClass
(WebappClassLoader.java:1340)


To reproduce this issue, checkout https://svn.codehaus.org/mojo/trunk/mojo/gwt-maven-plugin
run "mvn clean install"
goto target\it\gwt-compile
run "mvn gwt:gwt"

Cheers,
Nicolas

Scott Blum

unread,
Jan 20, 2009, 10:19:48 AM1/20/09
to Google-Web-Tool...@googlegroups.com
Hi Nicolas,

Can you supply the actual script produced and any Java classes that are used to setup the "booter"?

Thanks,
Scott

nicolas de loof

unread,
Jan 20, 2009, 10:44:59 AM1/20/09
to Google-Web-Tool...@googlegroups.com
You can get the test project from http://people.apache.org/~nicolas/MGWT-14/ as a ZIP of browse its content.


The maven plugin creates :
-  a classpath entries list in target/gwt.classpath file (warning : files path are absolute)
-  a run.cmd script to lanch de GWT Shell using a booter

The "ForkBooter" class is used to launch a JVM and build a classloader with all required classpath entries, without requirement for a long command line :

/**
 * A (simplified) surefire-like bootstrapper to run some GWT component in a forked JVM without limitation of command
 * line length to define the classpath.
 * 
 * @author ndeloof
 * @version $Id: ForkBooter.java 8738 2009-01-17 21:15:43Z olamy $
 */
public class ForkBooter
{
    public static void main( String[] args )
        throws Exception
    {
        String fileName = args[0];
        String className = args[1];
        ClassLoader cl = getClassLoader( fileName );

        Class<?> gwt = cl.loadClass( className );
        
        Thread.currentThread().setContextClassLoader( cl );
        
        Method method = gwt.getMethod( "main", new Class[] { String[].class } );
        String[] compilerArgs = new String[args.length - 1];
        System.arraycopy( args, 1, compilerArgs, 0, args.length - 1 );
        method.invoke( null, (Object) compilerArgs );
    }

    private static ClassLoader getClassLoader( String fileName )
        throws FileNotFoundException, IOException, MalformedURLException
    {
        BufferedReader reader = new BufferedReader( new FileReader( fileName ) );
        List<URL> classpath = new LinkedList<URL>();
        String line;
        while ( ( line = reader.readLine() ) != null )
        {
            classpath.add( new File( line ).toURI().toURL() );
        }
        URL[] urls = (URL[]) classpath.toArray( new URL[classpath.size()] );
        return new URLClassLoader( urls, ClassLoader.getSystemClassLoader() );
    }
}

2009/1/20 Scott Blum <sco...@google.com>

Scott Blum

unread,
Jan 20, 2009, 9:41:23 PM1/20/09
to Google-Web-Tool...@googlegroups.com
Thanks, nicolas.  Your test reproduced an issue, but I was unable to get Tomcat to work properly.  We will probably not fix this for 1.6 since Jetty works fine.


Scott

John Tamplin

unread,
Jan 20, 2009, 10:08:50 PM1/20/09
to Scott Blum, Google-Web-Tool...@googlegroups.com
On Tue, Jan 20, 2009 at 9:41 PM, Scott Blum <sco...@google.com> wrote:
Thanks, nicolas.  Your test reproduced an issue, but I was unable to get Tomcat to work properly.  We will probably not fix this for 1.6 since Jetty works fine.


Actually, I think jetty has a similar issue (see the internal error report Lex is looking at) -- I think the root cause is jarjar missed some reflective references to classes, so code is looking for classes under the un-mangled name yet the classes have been renamed inside our jar.

Can you try it with surpressing the jarjar mangling?

--
John A. Tamplin
Software Engineer (GWT), Google

Scott Blum

unread,
Jan 20, 2009, 10:10:45 PM1/20/09
to John Tamplin, Google-Web-Tool...@googlegroups.com
Jarjar is a trunk issue that I believe is unrelated.

nicolas de loof

unread,
Jan 21, 2009, 3:17:12 AM1/21/09
to Google-Web-Tool...@googlegroups.com
The same script can run the shell with a "inlined" classpath :


set CLASSPATH=D:\platina\repository\com\google\gwt\gwt-user\1.5.3\gwt-user-1.5.3.jar;D:\platina\repository\com\google\gwt\gwt-dev\1.5.3\gwt-dev-1.5.3-windows.jar
...
java  -cp %CLASSPATH% -Dcatalina.base="D:\projets\apache\gwt-maven-plugin\target\it\gwt-compile\target\tomcat"   com.google.gwt.dev.GWTShell -gen ...

But this option fails on windows whith command line limitation on large projects with lot's of dependencies.

So I don't thing this issue is related to some jarjar packaging. It seems the TomcatEmbedded doesn't support to run inside a hierarchized classloader (looks really strange) and is fine only when all dependencies are set in the Classpath.



2009/1/21 Scott Blum <sco...@google.com>

Olivier Modica

unread,
Jan 21, 2009, 8:37:16 AM1/21/09
to Google Web Toolkit Contributors
Hi,

I wrote a blog post about this exact subject here:
http://development.lombardi.com/?p=380

I believe this will help. My understanding is that
EmbeddedTomcatServer doesn't set up the ClassLoader as you would
expect.

Thanks,
Olivier.
Reply all
Reply to author
Forward
0 new messages