Compiling GWT project using GUICE with ANT - gwt

I can successfully compile the source, but when I hit this ant task:
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg line="${gwt.args}"/>
<arg value="com.jwavro.jaguar.jaguar"/>
</java>
</target>
I'm getting these errors:
gwtc:
[java] Compiling module com.jwavro.jaguar.jaguar
[java] Scanning for additional dependencies: generated://9161C2B729E3521B2A51CBE6F2AE8A77/com/unnison/framework/client/GeneratedGinInjector.java
[java] Computing all possible rebind results for 'com.unnison.framework.client.GeneratedGinInjector'
[java] Rebinding com.unnison.framework.client.GeneratedGinInjector
[java] Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[java] [ERROR] Generator 'com.google.gwt.inject.rebind.GinjectorGenerator' threw an exception while rebinding 'com.unnison.framework.client.GeneratedGinInjector'
[java] com.google.inject.CreationException: Guice creation errors:
[java]
[java] 1) No implementation for javax.inject.Provider was bound.
[java] while locating javax.inject.Provider
[java] for parameter 9 at com.google.gwt.inject.rebind.BindingsProcessor.(BindingsProcessor.java:209)
[java] at com.google.gwt.inject.rebind.GinjectorGeneratorModule.configure(GinjectorGeneratorModule.java:59)
GUICE binding is supposed to be automatic, any idea how to fix it ?

Guice can not be used directly with GWT. You need to use GIN.

javax.inject is a dependency that needs to be in your classpath.
If you downloaded Guice from Google, there should be a lib folder in the exploded zip with a javax.inject.jar file, or you can download it direct from trunk.
The key is this line:
[java] 1) No implementation for javax.inject.Provider was bound.

There are two things I can think of. First of all make sure you have properly inherited the GIN module in your GWT module xml:
<module>
...
<inherits name="com.google.gwt.inject.Inject"/>
...
</module>
Secondly you have to be carefull about versions of GIN and Guice. On the GIN homepage it says:
GIN 1.0 requires ... and Guice 2.0
For Gin 1.5 you'll need to use the Guice snapshot distributed with Gin or ... Guice 3.0
So make sure you have the appropriate Guice JAR in path.

Related

Using eclipse in order to find the opencv native library doesn't work

I'm attempting to use opencv on an ubuntu installation and am following this tutorial. Everything seemed fine and it even listed amongst the installed parts so I proceeded into this tutorial. This went well up until the moment where you have to add opencv as a user library as it was not amongst the (completely empty) list of libraries found. I have looked throughout the opencv folder and can't find anything like a library either am I missing something? Any idea on how to fix this?
Note that it did manage to produce .jar file however the library is still missing. If it matters opencv is installed in usr/local/src.
If in order fix this you require any extra information feel free to ask in the comments.
This might have something to do with the problem:
ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
thijs#thijs-ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
This is my build.xml:
<property name="src.dir" value="src"/>
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="${ant.project.name}"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<sysproperty key="java.library.path" path="${ocvLibDir}"/>
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="rebuild" depends="clean,jar"/>
<target name="rebuild-run" depends="clean,run"/>
running
ulap:/usr/local/src/opencv-2.4.8/opencv/samples/java/ant$ ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
gave me:
clean:
compile:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
[javac] Compiling 1 source file to /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
jar:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar
[jar] Building jar: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar/SimpleSample.jar
run:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:844)
[java] at java.lang.System.loadLibrary(System.java:1051)
[java] at SimpleSample.<clinit>(Unknown Source)
[java] Could not find the main class: SimpleSample. Program will exit.
[java] Java Result: 1
rebuild-run:
BUILD SUCCESSFUL
Total time: 1 second
According to the first tutorial (how to build OpenCV from source), the result should be a JAR file and a .so native lib in the bin/ directory of your OpenCV directory. In the "SETTING UP ECLIPSE FOR USING OPENCV (JAVA) IN UBUNTU" tutorial, you must create the User Library by following the steps in the tutorial. That process involves browsing your file system to select the OpenCV JAR that was produced by the first tutorial and then selecting the .so file as the native library. Eclipse will not automatically "find" your OpenCV library, you have to configure it to know about it, that's what the second tutorial is doing.
I think you were running the wrong command with ant. You can read the manual here: https://ant.apache.org/manual/running.html
Below is the format to run ant:
ant [options] [target [target2 [target3] ...]]
So maybe your command line should look like:
ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
given that /usr/local/src/opencv-2.4.8/opencv/build/bin contains the opencv-248.jar
As shown on your build.xml file that the property ocvJarDir is pointing to the location of the classpath requires to build the project:
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
And you need to specify the target "rebuild-run" in the command line since your build.xml does not have a default target specified.
Try installing 2.4.6 version. I have similar problems when installing in VS. Older version worked. Maybe it's the same in Eclipse, too.

GWTP + MGWT - Errors in 'jar:file:mgwt-1.1.1.jar!/com/googlecode/mgwt/ui/client/theme/MGWTThemeBaseThemeStandardImpl.java'

I am trying to write the build.xml for a GWTP+MGWT project for mobile, desktop & tablet.
<javac srcdir="${apt_generated}" destdir="${out.classes.folder}" includeantruntime="true" source="1.6" target="1.6" nowarn="false" debug="true" debuglevel="lines,vars,source" >
<classpath refid="project.class.path" />
<compilerarg value="-Xlint"/>
</javac>
<javac srcdir="${in.src.folder}" fork="true" memoryinitialsize="512m" memorymaximumsize="1024m" includes="**" encoding="utf-8" destdir="${out.classes.folder}" source="1.6" target="1.6" nowarn="false" debug="true" debuglevel="lines,vars,source" includeantruntime="true">
<classpath refid="project.class.path" />
<compilerarg value="-Xlint"/>
</javac>
<copy todir="${out.classes.folder}">
<fileset dir="${in.src.folder}" includes="**/*.class" />
</copy>
<delete dir="${in.src.folder}" includes="**/*.class" failonerror="false" />
The application runs fine in dev mode but i see the following error when i do a "ant gwtc"-
gwtc:
[java] Compiling module com.company.proj.fe.TestApp
[java] Validating newly compiled units
[java] Ignored 1 unit with compilation errors in first pass.
[java] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[java] [ERROR] Errors in 'jar:file:/workspace/testapp/war/WEB-INF/lib/
mgwt-1.1.1.jar!/com/googlecode/mgwt/ui/client/theme/
MGWTThemeBaseThemeStandardImpl.java'
[java] [ERROR] Internal compiler error
[java] java.lang.OutOfMemoryError: Java heap space
[java] at java.lang.String.toCharArray(String.java:2725)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$CompilationUnitAdapter.getContents(AbstractCompiler.java:105)
[java] at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9485)
[java] at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9457)
[java] at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:8102)
[java] at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:322)
[java] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:131)
[java] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1090)
[java] at com.google.gwt.dev.javac.JdtCompiler.resolveType(JdtCompiler.java:438)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.resolvePossiblyNestedType(AbstractCompiler.java:292)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.access$500(AbstractCompiler.java:139)
[java] at com.google.gwt.dev.jdt.AbstractCompiler.resolvePossiblyNestedType(AbstractCompiler.java:625)
[java] at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.checkRebindResultInstantiable(WebModeCompilerFrontEnd.java:130)
[java] at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.doFindAdditionalTypesUsingRebinds(WebModeCompilerFrontEnd.java:118)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.process(AbstractCompiler.java:254)
[java] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:173)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:288)
[java] at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.access$400(AbstractCompiler.java:139)
[java] at com.google.gwt.dev.jdt.AbstractCompiler.compile(AbstractCompiler.java:588)
[java] at com.google.gwt.dev.jdt.BasicWebModeCompiler.getCompilationUnitDeclarations(BasicWebModeCompiler.java:97)
[java] at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations(WebModeCompilerFrontEnd.java:52)
[java] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:569)
[java] at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[java] at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
[java] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[java] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
I added fork="true" memoryinitialsize="512m" memorymaximumsize="1024m". but these do not seem to work.
I faced some problems compiling GWT applications, if the JRE has to few memory.
Try to increase the memory of your ant process.
One of my GWT applications is only compilable within a 64 bit JVM.
I compile my applications with 4g RAM and in a 64bit JVM.

ant gwt compiler task fails

I'm following this tutorial to create my ant build file that java compiles, than GWT compiles than perform the correct actions to build my .war file.
I use Eclipse and GWT-compile works, and when I run the development mode it works. I have also successfully deployed on tomcat.
The things is when I run my script, the compiles work but it fails on the gwt-compiler task. My ant build script is as follow :
<project name="vlp" default="gwt.compile" basedir=".">
<tstamp />
<!-- ################# PROPERTIES ################ -->
<!-- directory properties -->
<!-- source -->
<property name="projectName" value="VirtualLabPortal" />
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="src.build.dir" location="${build.dir}/src" />
<property name="gwt.build.dir" location="${build.dir}/gwt" />
<property name="gwt.unitCache.dir" location="gwt-unitCache" />
<!-- libraries -->
<property name="src.lib.dir" location="war/WEB-INF/lib" />
<!-- ___________________________________________________________________
| |
| Configure path source/test |
|___________________________________________________________________|
-->
<path id="compile.path">
<fileset dir="${src.lib.dir}" includes="*.jar" />
<fileset dir="${src.lib.dir}/gwt" includes="*.jar" />
</path>
<!-- ___________________________________________________________________
| |
| Clean old compiled source/test/war |
|___________________________________________________________________|
-->
<target name="clean" description="Clean all the old build files.">
<delete dir="${build.dir}" />
<delete dir="${gwt.unitCache.dir}" />
<delete file="${projectWar}" />
<delete file="${src.lib.dir}/${projectJar}" />
</target>
<!-- ___________________________________________________________________
| |
| Compile the source |
|(should exclude gwtview code which is compiled by the gwt compiler)|
|___________________________________________________________________|
-->
<target name="src.compile" depends="clean" description="Compile the source code when everything has been cleaned.">
<mkdir dir="${src.build.dir}" />
<javac encoding="utf-8" destdir="${src.build.dir}" nowarn="true">
<src path="${src.dir}" />
<classpath refid="compile.path" />
</javac>
</target>
<!-- ___________________________________________________________________
| |
| Invoke the GWT compiler |
|___________________________________________________________________|
-->
<property name="module.gwt.xml" location="${src.dir}/com/banctecmtl/ca/vlp" />
<target name="gwt.compile" depends="src.compile">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<!-- src dir is added to ensure the module.xml file(s) are on the classpath -->
<pathelement location="${module.gwt.xml}" />
<path refid="compile.path" />
</classpath>
<jvmarg value="-Xmx512m" />
<arg line="${projectName} -logLevel ALL -style OBF -war ${build.dir}" />
</java>
</target>
<!-- ___________________________________________________________________
| |
| Copy the config files in the war directory |
|___________________________________________________________________|
-->
<property name="config.dir" location="war/config" />
<target name="copy-resources">
<copy todir="war/config" preservelastmodified="true">
<fileset dir="${config.dir}">
<include name="**.*" />
</fileset>
</copy>
</target>
<!-- ___________________________________________________________________
| |
| Create a Jar to be included in the war |
|___________________________________________________________________|
-->
<property name="projectJar" value="${projectName}.jar" />
<property name="gwt.client.dir" location="com/banctecmtl/ca/vlp/view/webview" />
<target name="jar" depends="src.compile">
<!-- should also depend on gwt.compile -->
<jar jarfile="${src.lib.dir}/${projectJar}" basedir="${src.build.dir}/">
<!-- Don't wrap any of the client only code into the JAR
<exclude name="${gwt.client.dir}/**/*.class"/> -->
<exclude name="${gwt.client.dir}/**/*.class" />
</jar>
</target>
<!-- ___________________________________________________________________
| |
| Create a War from the source |
|___________________________________________________________________|
-->
<property name="projectWar" value="${projectName}.war" />
<target name="war" depends="jar,copy-resources">
<war basedir="war" destfile="${projectWar}" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="war/WEB-INF/">
<include name="lib/*.jar" />
<include name="classes/*.properties" />
<exclude name="**/gwt-dev.jar" />
<exclude name="**/gwt-user.jar" />
</webinf>
</war>
</target>
<!-- ___________________________________________________________________
| |
| Deploy to the production server |
|___________________________________________________________________|
-->
<!-- It is possible you can't run this from eclipse,
you need to edit the run configurations and add the
latest jsch library to the classpath -->
<property name="user" value="root" />
<property name="password" value="Banctec01" />
<property name="prodHost" value="vlp" />
<property name="dest" value="/usr/share/tomcat6/webapps/ROOT.war" />
<target name="deploy" depends="war">
<echo message="Copying to : ${user}#${prodHost}:${dest}" />
<scp file="${projectWar}" remoteTofile="${user}#${prodHost}:${dest}" password="${password}" trust="true" />
</target>
</project>
It fails with the following error :
Buildfile: D:\workspace\vlp\build.xml
clean:
[delete] Deleting directory D:\workspace\vlp\war\WEB-INF\classes
src.compile:
[mkdir] Created dir: D:\workspace\vlp\war\WEB-INF\classes
[javac] D:\workspace\vlp\build.xml:42: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 134 source files to D:\workspace\vlp\war\WEB-INF\classes
[javac] Note: D:\workspace\vlp\src\com\banctecmtl\ca\vlp\controller\schedule\ScheduledTaskManager.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
gwt.compile:
[java] Checking for updates
[java] First launch was 134c3e23387
[java] Last ping was Mon Apr 23 14:42:48 EDT 2012, min wait is 86400000ms
[java] Module location: file:/D:/workspace/vlp/src/com/banctecmtl/ca/vlp/VirtualLabPortal.gwt.xml
[java] Loading inherited module 'com.google.gwt.user.User'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/user/User.gwt.xml
[java] Loading inherited module 'com.google.gwt.animation.Animation'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/animation/Animation.gwt.xml
[java] Loading inherited module 'com.google.gwt.core.Core'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/core/Core.gwt.xml
[java] Loading inherited module 'com.google.gwt.dev.jjs.intrinsic.Intrinsic'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-dev.jar!/com/google/gwt/dev/jjs/intrinsic/Intrinsic.gwt.xml
[java] Loading inherited module 'com.google.gwt.lang.LongLib'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-dev.jar!/com/google/gwt/lang/LongLib.gwt.xml
[java] Loading inherited module 'com.google.gwt.emul.Emulation'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/emul/Emulation.gwt.xml
[java] Loading inherited module 'com.google.gwt.logging.LogImpl'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/logging/LogImpl.gwt.xml
[java] Loading inherited module 'com.google.gwt.xhr.XMLHttpRequest'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/xhr/XMLHttpRequest.gwt.xml
[java] Loading inherited module 'com.google.gwt.core.Core'
[java] Module 'com.google.gwt.core.Core' has already been loaded and will be skipped
[java] Loading inherited module 'com.google.gwt.core.CompilerParameters'
[java] Module location: jar:file:/D:/workspace/vlp/war/WEB-INF/lib/gwt/gwt-user.jar!/com/google/gwt/core/CompilerParameters.gwt.xml
[java] [...]
[java] Loading inherited module 'com.google.gwt.user.User'
[java] Module 'com.google.gwt.user.User' has already been loaded and will be skipped
[java] Public resources found in...
[java] Translatable source found in...
[java] Persistent unit cache dir set to: D:\workspace\vlp\war\..\gwt-unitCache
[java] Compiling module VirtualLabPortal
[java] Looking for previously cached Compilation Units in D:\workspace\vlp\war\..\gwt-unitCache
[java] Loaded 0 units from persistent store.
[java] Starting UnitWriteThread.
[java] Found 0 cached units. Used 0 / 2413 units from cache.
[java] [ERROR] Unexpected internal compiler error
[java] java.lang.RuntimeException: Exception processing units
[java] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:248)
[java] at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:447)
[java] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
[java] at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:252)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[java] at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
[java] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[java] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[java] at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[java] Caused by: java.lang.NoSuchMethodError: com.google.gwt.dev.jjs.ast.JProgram.serializeTypes(Ljava/util/List;Ljava/io/ObjectOutputStream;)V
[java] at com.google.gwt.dev.javac.CompilationUnitImpl.<init>(CompilationUnitImpl.java:68)
[java] at com.google.gwt.dev.javac.SourceFileCompilationUnit.<init>(SourceFileCompilationUnit.java:48)
[java] at com.google.gwt.dev.javac.CompilationUnitBuilder$ResourceCompilationUnitBuilder.makeUnit(CompilationUnitBuilder.java:154)
[java] at com.google.gwt.dev.javac.CompilationUnitBuilder.build(CompilationUnitBuilder.java:266)
[java] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$1.run(CompilationStateBuilder.java:223)
BUILD FAILED
D:\workspace\vlp\build.xml:60: Java returned: 1
Total time: 36 seconds
I found that changing the gwt-compiler class name to the DevMode is building successfully. Using : classname="com.google.gwt.dev.DevMode" instead of classname="com.google.gwt.dev.Compiler".
EDIT : I refactored the XML above.
The build.xml cleans all the bin directory. I also pointer the javacto the bin/src directory and Google Web Toolkit compiler outputs to : bin/gwt. The compiler still doesn't work...
EDIT : I downloaded the latest SDK right away from google developpers site, and overrided the old librairies found in my classpath and in my eclipse plugin. Still won't work with the ant build script.
Anybody sees what could be the problem here?
All I can say is that the method com.google.gwt.dev.jjs.ast.JProgram.serializeTypes(Ljava/util/List;Ljava/io/ObjectOutputStream;)V is introduced only in gwt-dev 2.4.0. It doesn't exist in gwt-dev 2.3.0.
Which implies there are somewhere, in the classpath, two gwt-dev versions. One of them is 2.4.0, which is why com.google.gwt.dev.javac.CompilationUnitImpl is looking for that method. The other is of 2.3.0 or older, which is why that method isn't found (JProgram class was loaded by the compiler using the older version).
Try to look them up thoroughly. Or try to start a fresh environment in which you put a good eye on what's getting in.
tl;dr: this is due to differences in the linkers provided by Compiler versus DevMode in cases of insufficient or incorrect class context
Tracing the issue
I noticed that the repro you have exists in the current GWT trunk. Specifically, it's failing in this block of code:
ArrayList<CompilationUnit> resultUnits = new ArrayList<CompilationUnit>();
do {
// Compile anything that needs to be compiled.
buildQueue = new LinkedBlockingQueue<CompilationUnitBuilder>();
final ArrayList<CompilationUnit> newlyBuiltUnits = new ArrayList<CompilationUnit>();
final CompilationUnitBuilder sentinel = CompilationUnitBuilder.create((GeneratedUnit) null);
final Throwable[] workerException = new Throwable[1];
Thread buildThread = new Thread() {
#Override
public void run() {
try {
do {
CompilationUnitBuilder builder = buildQueue.take();
if (builder == sentinel) {
return;
}
// Expensive, must serialize GWT AST types to bytes.
CompilationUnit unit = builder.build(); // <-- Right here.
newlyBuiltUnits.add(unit);
} while (true);
} catch (Throwable e) {
workerException[0] = e;
}
}
};
Unwinding the stack further than your trace, we bounce through a factory and ten layers of code, until we finally hit UnifyAst.java. And, lo and behold:
...
mapApi(enclosingType);
// Now the method should be there.
method = methodMap.get(sig);
if (method == null) {
// TODO: error logging
throw new NoSuchMethodError(sig);
}
assert !method.isExternal();
return method;
...
This is the only instance of NoSuchMethodError called by the Precompilation stage of GWT.
Differences in Compiler and DevMode linking
Cool. Now that we've taken the deep dive into why this is exploding, let's figure out why DevMode works when Compiler doesn't. We note that both import the same copy of Util.java, so technically, both types are available statically to our Java compiler (just not the GWT compiler).
Inspecting the linkers, we note that Compiler uses Link.link directly:
Link.link(logger.branch(TreeLogger.TRACE, logMessage), module,
generatedArtifacts, allPerms, resultFiles, options.getWarDir(),
options.getDeployDir(), options.getExtraDir(), precompileOptions);
Whereas DevMode uses a much terser static call, with a separate pass filling in an instance of StandardLinkerContext:
link(loadLogger, module);
...
#Override
protected synchronized void produceOutput(TreeLogger logger, StandardLinkerContext linkerStack,
ArtifactSet artifacts, ModuleDef module, boolean isRelink) throws UnableToCompleteException {
...
linkerStack.produceOutput(linkLogger, artifacts, Visibility.Public, outFileSet);
linkerStack.produceOutput(linkLogger, artifacts, Visibility.Deploy, deployFileSet);
linkerStack.produceOutput(linkLogger, artifacts, Visibility.Private, extraFileSet);
...
}
Great! So, how do I fix it?
As accepted in the middle of writing this post, yair provides one such diagnosis for the issue, noting that the precompilation step is non-robust to conflicting class identities in the context of two versions of GWT. Other class visibility problems where precompilation.getGeneratedArtifacts(); pulls in wrong or insufficient objects may also cause this repro.
I will assume the issue has now been resolved, given yair was given accepted answer status. But it is conceivable for other people running across this post that other classpath or visibility issues may cause this exact issue to recur.
java.io.ObjectOutputStream class isn't supported by GWT compiler.
You have to refer to https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation#Package_java_io before using Java classes to be sure GWT supports it.
You fork a JVM to run Gwt Compiler and the bin directory is in ClassPath.
As Eclipse compiles in development mode, a remaining class in bin may prevent the compiler to process properly some source files.
You should make sure the bin directory is empty before you invoke your Ant target. It may pass then.
I recommend you to use two target directories: one for classes compiled from Java sources and another one for GWT generated files. Then the target war will collect both into the WAR.

error when building a GWT app after updating GWT

after updating GWT2.0 to the GWT2.4, eclipse shows error message when building GWT app with ant.
here is the message:
[java] Compiling module com.certus.noc.noc
[java] Validating newly compiled units
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/user/client/ui/HasDirectionalSafeHtml.java'
[java] [ERROR] Line 26: No source code is available for type com.google.gwt.safehtml.client.HasSafeHtml; did you forget to inherit a required module?
[java] [ERROR] Line 33: No source code is available for type com.google.gwt.safehtml.shared.SafeHtml; did you forget to inherit a required module?
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/event/shared/SimpleEventBus.java'
[java] [ERROR] Line 27: No source code is available for type com.google.web.bindery.event.shared.SimpleEventBus; did you forget to inherit a required module?
[java] [ERROR] Line 32: Cannot cast from GwtEvent.Type<H> to Event.Type<H>
[java] [ERROR] Line 32: No source code is available for type com.google.web.bindery.event.shared.Event<H>.Type<H>; did you forget to inherit a required module?
[java] [ERROR] Line 36: No source code is available for type com.google.web.bindery.event.shared.HandlerRegistration; did you forget to inherit a required module?
[java] [ERROR] Line 42: Cannot cast from GwtEvent.Type<H> to Event.Type<H>
[java] [ERROR] Line 51: No source code is available for type com.google.web.bindery.event.shared.Event<H>; did you forget to inherit a required module?
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/user/client/ui/DirectionalTextHelper.java'
[java] [ERROR] Line 32: No source code is available for type com.google.gwt.i18n.shared.HasDirectionEstimator; did you forget to inherit a required module?
and the inherites module in gwt.xml file
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.extjs.gxt.ui.GXT'/>
<inherits name='com.extjs.gxt.desktop.WebDesktop' />
<inherits name='com.certus.noc.resources.Resources' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.certus.noc.resources.Resources' />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name='com.extjs.gxt.themes.Themes' />
<inherits name='com.google.gwt.i18n.I18N' />
<inherits name='com.extjs.gxt.charts.Chart' />
Thanks in advance for any answer
Try to add
<inherits name="com.google.web.bindery.event.Event"/>
to your main <project>.gwt.xml it should solve Events problems
Also try to place your gwt jars before gxt jars in your classpath
And check that HasDirectionalSafeHtml take HasSafeHtml and SafeHtml from gwt-servlet-2.4.0.jar, or event check if gwt-servlet-2.4.0.jar exists in your classpath.
This should solve HasDirectionalSafeHtml problems
I have solved the problem.
delete all the jars in the WEB-INF/lib, and then copy the new jar from APP Engine and other
userful . then it works

How do you use JPA objects with GWT in a different project?

I'm new to GWT, and I'm setting up a project to hold the UI portion of a complicated application. The JPA data objects are defined in a separate project using MyBatis generated POJOs. Once I manually modify the JPA objects to include 'implements Serializable' (this is a separate problem I need to solve), the gwtc step in the build process can't continue because it needs the source code for the JPA object, but can't find them.
I've created the 'core' project's jar files so that it includes the source .java files, but this didn't work. I've tried adding a classpath element to the gwtc ant java call.
How can I make my UI project compile while keeping the JPA objects defined in a separate project?
Errors:
Buildfile: /Users/user/source/user_interface/build.xml
libs:
javac:
gwtc:
[java] Compiling module org.mysite.ui
[java] Validating newly compiled units
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyService.java'
[java] [ERROR] Line 21: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyServiceAsync.java'
[java] [ERROR] Line 19: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/presenter/MainTabPresenter.java'
[java] [ERROR] Line 75: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] Scanning for additional dependencies: file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java
[java] Computing all possible rebind results for 'org.mysite.ui.client.MyService'
[java] Rebinding org.mysite.ui.client.MyService
[java] Checking rule <generate-with class='com.google.gwt.user.rebind.ui.ImageBundleGenerator'/>
[java] [ERROR] Unable to find type 'org.mysite.ui.client.MyService'
[java] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[java] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java'
[java] [ERROR] Line 23: Failed to resolve 'org.mysite.ui.client.MyService' via deferred binding
[java] [ERROR] Cannot proceed due to previous errors
BUILD FAILED
/Users/user/source/user_interface/build.xml:39: Java returned: 1
Total time: 26 seconds
Ant gwtc target:
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<pathelement location="../core/src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="web"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.mysite.ui.MyApp"/>
</java>
</target>
GWT has always had this problem.
The approach I have taken in the past is to make a .gwt.xml module in the other JAR including the JPA POJOs and putting the JPA annotation classes in an "emul" javax.persistence folder. This won't work w/ many providers that use lazy fetching of course, so Gilead (as mentioned in another answer here) will be needed.
Another way is to make copies of the JPA objects and just Dozer them before sending across RPC
Luckily, GWT 2.1 has solved this problem. Use Entity proxies and request factories. It works well.
Either use the new GWT 2.1 RequestFactory / EntityProxy approach, or
Better, ditch the JPA and use Objectify or Twig.
We use Objectify, because JPA is not a good fit for Datastore. JPA was created with SQL-based relational databases in mind, while GAE Datastore is an entirely different thing.
Google ported JPA layer to Datastore to lure in developers, pretending that Datastore is just a plain old SQL relational database. This later blows up in their faces once projects grow big.
You really need to understand the Datastore tradeoffs if you want to use AppEngine. JPA is not making you a favor here.
Your best bet if you want to serialize POJOs to GWT is to use Gilead http://noon.gilead.free.fr/gilead/
All you have to do on your POJO is extend LightEntity and implement Serializable
The tutorial is pretty straight forward in how to set up the RPC.