Tuesday, May 19, 2009

GWT-Compiler Ant Out-Of-Memory

StackTrace (Ant)
gwt-compile:
[echo] env.GWT_HOME=C:\data\java\tools\gwt-windows-1.5.3
[java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[java] at java.util.Arrays.copyOf(Arrays.java:2882)
[java] at java.lang.String.(String.java:179)
[java] at java.lang.String.valueOf(String.java:2841)
[java] at com.google.gwt.dev.javac.CompiledClass.(CompiledClass.java:88)
[java] at com.google.gwt.dev.javac.CompilationUnit$FindTypesInCud.visit(CompilationUnit.java:111)
[java] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1181) [java]
....


Possible Issue and Solution

In order to invoke the gwt-compiler via an Ant task successfully, you will probably need to increase the maximum memory as follows:

<target name="gwt-compile" description="...">
<java classname="com.google.gwt.dev.GWTCompiler" fork="true” maxmemory="256m" failonerror="true">
<arg line="-out ${build}/www" />
<arg value="${gwt.module}" />
<classpath refid="gwt.classpath" />
</java>
</target>

Friday, April 17, 2009

GWT and Payload

StackTrace
onFailure: rocket.remoting.client.CometException: com.google.gwt.core.client.JavaScriptException: (SyntaxError): Unterminated string constant
number: -2146827273
description: Unterminated string constant
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.MethodDispatch.invoke(MethodDispatch.java:97)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)


Possible Issue and Solution

The String you are sending back to the client contains newline or carriage returns in it. This makes the JavaScript gwt handler vomit on the client side.

What I did was replace the newline with a pipe which I then converted back to a newline in my UI display logic.


public CometPayload(String pLogMessage) {
//logMessage = pLogMessage;
logMessage = pLogMessage.replace("\r\n", "").trim();
}

Tuesday, January 6, 2009

Maven JNLP Jar Install Issue

While researching the creation of a POM for a JNLP Java Swing project, I came accross the following helpful Maven code to install a JNLP jar file via the command line:

mvn install:install-file -Dfile=%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar \
-DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 \
-Dpackaging=jar -DgeneratePom=true

This works fine if your %JAVA_HOME% variable doesn't contain whitespace. If it does, the Stacktrace below occurs.

Solution
Add double quotes to the file parameter as follows:

mvn install:install-file -Dfile="%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar" -DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true -e

Stacktrace


mvn install:install-file -Dfile=%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar \
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE

[INFO] ------------------------------------------------------------------------
[INFO] Invalid task 'Files\Java\jdk1.6.0_06\sample\jnlp\servlet\jnlp-servlet.jar': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: <>
[INFO] Finished at: Tue Jan 06 11:02:13 CST 2009
[INFO] Final Memory: 1M/4M
[INFO] ------------------------------------------------------------------------
C:\JBuilder2007\workspace\H2HAdmin\bin>-DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 \'-DgroupId' is not recognized as an internal or external command,operable program or batch file.
C:\JBuilder2007\workspace\H2HAdmin\bin>-Dpackaging=jar -DgeneratePom=true


References


http://mojo.codehaus.org/webstart/webstart-maven-plugin/jnlp101.html