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

Monday, October 20, 2008

On Web Frameworks

Thus far, working with Spring MVC hasn't been too much of a challenge. I'm not sure which one I prefer yet from the MVC frameworks I've previewed this past year. Shale was interesting, fresh and well, layered. I enjoyed working with Shale's Clay (like Tapestry or Facelets). I found Struts 2, powerful, fully-loaded and ready to go. I liked this one the best so far but am deferring total judgement until the completion of our latest project. I hope Struts 2 takes off better than Shale. JSF is elegant, simple and great to pick up for a Project Swing gal like me.

Sometimes, picking the best framework for a particular project given so many great choices is difficult. Most shops have standards that guide such selections, taking into consideration how well a framework fits into the organizations best practices and knowledge expertise. I love open source and don't mind bleeding a little bit, so long as security isn't compromised. I can't wait to see how the Spring MVC project turns out. So far, so good.

Monday, October 13, 2008

Too Much Bleeding?

So our development group decided against using Struts 2 and Tibco GI for the view on our latest project. After spending roughly 30 hours researching and playing with the online examples, it became apparant that there were security holes with OGNL (already addressed) and unexpected complexities with the integration of the GI layer.

We are exploring Spring MVC with JQuery now to keep things simpler for our small interface to a new transaction processing network gateway application. I can't deny that I'm dissappointed...a little more effort and late nights would have yielded the results we were seeking using our original design; however, the suits want to software one month sooner than expected, so its time to put something together without all the bells and whistles.

Wednesday, September 24, 2008

On Server Push Technologies

I've been impressed with how much information there is on the Internet on comet-like frameworks. Yet, I have not found a good reference implementation or even sample code that works. I see lots of pleas for help in forums posted by newbies trying to get the skinny examples they follow online to work. Its enough to make me pause for a second but not stop. I'm architecting a real-time message accepting web application, even if I have to code a nio page bus myself. Right now, I'm playing with Tomcat servlets. Next, I'll see how Jetty works. I'll keep it posted.

The issue with Active MQ was a typo in an example they provided; I ended up joining Confluence in an attempt to correct errors as I discovered them. In the end, I almost became an expert in embedded brokers (didn't need to really go there).

Wednesday, September 10, 2008

Struts 2 - Small Preview Successes

So no luck still connecting JBoss to ActiveMQ on a separate server but won't give up. There was some partial success binding a Queue (no stacktrace vomit), but haven't tested it yet so can't say this piece is over.

I'm looking also at Struts 2 for a small web application we're creating at work. After using the Maven archetype for the starter application, I successfully used the Jetty mojo that came included in the pom.xml file. A small thing - the example they have online published on Apache in the Creating an Application Using an Archetype section doesn't work. I had to change:
-DarchetypeVersion=2.0.5-SNAPSHOT \

To

-DarchetypeVersion=2.0.11.2-SNAPSHOT
I then installed the Maven pluggins for Eclipse so that I could see my source files to edit/play with them. But now, Eclipse is complaining about not seeing the JDK. I can't believe it doesn't use the JAVA_HOME enviornment variable. I know from dealing with this problem at work that I have to go modify an ini file or the Icon properties that launch the IDE, but jeez.

Setting up the development environment for this new project at work hasn't been easy, but I'm getting closer. Struts 2 seems like a good thing - I said the same about the Shale framework which was supposed to be Struts's evolution. I guess Struts 2 has a better chance at infiltrating the development world because of the name.