GWT compiler doesn't find javax libraries - java

I'm new to GWT and trying to run my fist GWT app. I have classes that uses API from javax.persistence package. When I try to compile the code using GWT compiler it fails for not being able to find the mentioned package in the classpath. I have the libraries added to the class though.
<property name="gwt.sdk" location="C:/gwt-2.4.0" />
<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />
<path id="gwt.class.path">
<fileset dir="${devLib}"> <!-- here is all the dependent libraries-->
<include name="*.jar" />
</fileset>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
</path>
<target name="gwtc" description="GWT compile to JavaScript (production mode)">
<echo message="${gwt.class.path}"/>
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<path refid="gwt.class.path"/>
<pathelement location="gwt/project/src"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="web/five/gwtUI"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.scheduling.Scheduling"/>
</java>
</target>
here is the error that I see when run the ant target gwtc. Can someone help me to correct this?
[java] Compiling module org.scheduling.Scheduling
[java] Validating newly compiled units
[java] Ignored 91 units with compilation errors in first pass.
[java] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[java] Computing all possible rebind results for 'com.google.gwt.user.client.UserAgentAsserter'
[java] Rebinding com.google.gwt.user.client.UserAgentAsserter
[java] Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>
[java] [WARN] Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'. Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?
[java] Specify -logLevel DEBUG to see all errors.
[java] [WARN] Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
[java] Scanning for additional dependencies: file:/C:/Tolven_skandula/org.component.scheduling/gwt/project/src/org/scheduling/gwt/common/client/SchedulingEntryPoint.java
[java] Computing all possible rebind results for 'org.scheduling.common.service.SchedulingService'
[java] Rebinding org.scheduling.common.service.SchedulingService
[java] Checking rule <generate-with class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/>
[java] [ERROR] Errors in 'file:/C:/Tolven_skandula/org.component.scheduling/gwt/project/src/org/scheduling/common/model/Appointment.java'
[java] [ERROR] Line 5: The import javax.persistence cannot be resolved
[java] [ERROR] Line 6: The import javax.persistence cannot be resolved
[java] [ERROR] Line 7: The import javax.persistence cannot be resolved
[java] [ERROR] Line 8: The import javax.persistence cannot be resolved
[java] [ERROR] Line 9: The import javax.persistence cannot be resolved

Have a look at http://code.google.com/intl/de-DE/webtoolkit/doc/latest/RefJreEmulation.html, which describes the classes from the standard JRE GWT is emulating. javax.persistence doesn't seem to be supported.
That's the thing with gwt. Only a small subset of the standard JRE is supported (given by the fact that JavaScript will never have the same functionality, as it runs in a browser environment). Also, whilst the google guys are trying to integrate more and more classes, they are only that fast.
But you can always create your own classes and libraries.

Ahhh yes, an old problem: your domain classes annotated with JPA annotations can not be used by GWT. You probably need to send those objects via RPC?
People have been solving this for some time - google around:
GWT with JPA
GWT + entities + JPA + DTO + Dozer
http://objectgeneration.com/eclipse/16-GWT.html
http://uptick.com.au/content/transferring-jpa-objects-server-browser

I had same problem. I've downloaded: javamail from:
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.7-oth-JPR
and I've added : mailapi.jar to mu buildpath and GWT found javax.mail.*.
Good luck;
Anna

I have run into this issue using GWT 2.6.0. Rollbacking to GWT 2.5.1 solved it for me.
It's quite a wierd behaviour, as Java should treat annotations as mandatory. Not having sources should result in ignoring annotations, so annotations do not become tight coupling.

Related

Multiple artifacts of the module X are retrieved to the same file in Apache Ivy?

I am getting below error when i build with ant :
BUILD FAILED
/Users/rajeevprasanna/Desktop/Nutch/nutch-release-1.14/build.xml:116: The following error occurred while executing this line:
/Users/rajeevprasanna/Desktop/Nutch/nutch-release-1.14/src/plugin/build.xml:34: The following error occurred while executing this line:
/Users/rajeevprasanna/Desktop/Nutch/nutch-release-1.14/src/plugin/build-plugin.xml:230: impossible to ivy retrieve: java.lang.RuntimeException: problem during retrieve of org.apache.nutch#lib-selenium: java.lang.RuntimeException: Multiple artifacts of the module commons-codec#commons-codec;1.10 are retrieved to the same file! Update the retrieve pattern to fix this error.
at org.apache.ivy.core.retrieve.RetrieveEngine.retrieve(RetrieveEngine.java:206)
at org.apache.ivy.Ivy.retrieve(Ivy.java:540)
at org.apache.ivy.ant.IvyRetrieve.doExecute(IvyRetrieve.java:59)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
I have configuration set as per this post :
<target name="resolve-default" depends="clean-default-lib" description="--> resolve and retrieve dependencies with ivy">
<ivy:resolve file="${ivy.file}" conf="default" log="download-only"/>
<ivy:retrieve pattern="${build.lib.dir}/[artifact]-[type]-[revision].[ext]" symlink="false" log="quiet"/>
<antcall target="copy-libs"/>
</target>
<target name="resolve-test" depends="clean-test-lib, init" description="--> resolve and retrieve dependencies with ivy">
<ivy:resolve file="${ivy.file}" conf="test" log="download-only"/>
<ivy:retrieve pattern="${test.build.lib.dir}/[artifact]-[type]-[revision].[ext]" symlink="false" log="quiet"/>
<antcall target="copy-libs"/>
</target>
commons-codec dependency is like below in ivy.xml :
<dependency org="commons-codec" name="commons-codec" rev="1.10" conf="*->default" />
Can someone tell me what i am doing wrong?
Add the configuration name (conf) to the retrieve pattern, so that dependencies belongingn to multiple configurations (default and test, ...) map to different directories:
<ivy:retrieve pattern="${build.lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" symlink="false" log="quiet"/>

How to run FindBugs off of Ivy downloaded JARs

I've got Ant and Ivy setup so that I can use Ivy downloaded JARs to run PMD. Trying the same with FindBugs, setting the findbugs.home Ant property to ivy-jars/findbugs, where the Ivy JARs go. I initially got the error that it couldn't find the JAR files under the ${findbugs.home}/lib directory. I fixed that by changing Ivy to download the JAR files into ivy-jars/findbugs/lib. However, this gave rise to the new error:
Executing findbugs FindBugsTask from ant task
Running FindBugs...
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormatException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
This turns out to be caused by three problems:
I retrieved the JAR files using symlink="true". FindBugs dereferences the symlink to findbugs.jar and looks for all of its other JAR files under the same directory, but the way Ivy structures its cache only the findbugs.jar is in that directory. This can be fixed easily enough by not using symlinks.
FindBugs wants its JAR files to sometimes have the filename format [artifact].[ext] and sometimes have the format [artifact]-[revision].[ext], which can be solved by doing <ivy:retrieve> two times with different pattern values.
FindBugs wants the file name for the BCEL JAR file to be exactly bcel-6.0-SNAPSHOT.jar rather than bcel-findbugs.jar or bcel-findbugs-6.0.jar; this can be fixed with a symbolic link.
I consider this to just be a workaround, rather than a true solution, since #2 and #3 can't be how FindBugs is intended to be used under Ivy. So if anyone knows the right way to do it, please provide a better answer.
Contrary to the documentation, the home attribute is not required. Instead, you can provide a nested classpath element, which can be any path-like structure.
The following Ant target works for me:
<target name="findbugs" description="Run findbugs on the code">
<ivy:retrieve/>
<ivy:cachepath pathid="findbugs.classpath" conf="findbugs"/>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.classpath"/>
<findbugs>
<classpath refid="findbugs.classpath"/>
<class location="my-analysis-target.jar"/>
</findbugs>
</target>
Where my ivy.xml is:
<ivy-module version="2.0">
<info organisation="meh" module="meh"/>
<configurations defaultconfmapping="findbugs->default">
<conf name="findbugs"/>
</configurations>
<dependencies>
<dependency org="com.google.code.findbugs" name="findbugs" rev="3.0.1" conf="findbugs"/>
</dependencies>
</ivy-module>

Unable to enhance byte code to JDO 3.0 using version 2 of the DataNucleus GAE/J plug-in

My question
I am porting my application from version 1.x to 2.0 of the DataNucleus plug-in for GAE/J using the new 1.7.5 GAE/J SDK, but I am unable to use the arguments -enhancerVersion and v2 successfully. (Is the default target without these arguments version 1 of the DataNucleus GAE/J plug-in, which I do not want?)
Does anyone know how I could specify these arguments successfully?
My software environment
Web framework: Apache Wicket 6.5.0
Web server: Google App Engine for Java version 1.7.5
Java version: 1.6.0_39; Java HotSpot(TM) Client VM 20.14-b01
IDE: NetBeans 7.2 (build 201207171143)
GAE/J DataNucleus plug-in version: 2.1.2
DataNucleus Access Platform version: 3.1.3
Operating system: Microsoft Windows XP version 5.1 running on x86
Background information and build failure log output
The GAE/J documentation at
Google App Engine | Java | Storing Data | JDO | Overview JDO (3.0) | Migrating to Version 2.x of the DataNucleus Plugin | Changes to Configuration Files
says:
In build.xml
...
2. The datanucleusenhance target has changed. Update this section:
<target name="datanucleusenhance" depends="compile"
description="Performs enhancement on compiled data classes.">
<enhance_war war="war" />
</target>
to:
<target name="datanucleusenhance" depends="compile"
description="Performs enhancement on compiled data classes.">
<enhance_war war="war">
<args>
<arg value="-enhancerVersion"/>
<arg value="v2"/>
</args>
</enhance_war>
</target>
My code in my NetBeans build.xml is slightly different:
<!-- ******************************************************************* -->
<!-- ** -->
<!-- ** This block extends the original "-post-compile" target in -->
<!-- ** "nbproject/build-impl.xml" by adding "depends" and "description" -->
<!-- ** attributes and implementing them. -->
<!-- ** -->
<target
name="-post-compile"
depends="datanucleusenhancer"
description="Called after javac compilation (DataNucleus enhancement)"
/>
...
<target
name="datanucleusenhancer"
description="Performs the DataNucleus post-compilation enhancement"
>
<taskdef
name="datanucleusenhancertask"
classpathref="datanucleus.enhancer.classpath"
classname="org.datanucleus.enhancer.tools.EnhancerTask"
/>
<datanucleusenhancertask
dir="${build.classes.dir}"
classpathref="datanucleus.enhancer.classpath"
api="JDO"
failonerror="true"
verbose="true"
filesuffixes="class"
>
<fileset dir="${build.classes.dir}" casesensitive="false">
<filename name="**/persistence/**"/>
</fileset>
<jvmarg line="-Dlog4j.configuration=file:nbproject/log4j.properties"/>
<args> <!-- Added -->
<arg value="-enhancerVersion"/> <!-- code -->
<arg value="v2"/> <!-- to set -->
</args> <!-- args -->
</datanucleusenhancertask>
</target>
The build process failed with output:
...
datanucleusenhancer:
Enhancer api: JDO
Enhancer verbose: true
C:\...\build.xml:154: datanucleusenhancertask doesn't support the nested "args" element.
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:362)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:201)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:283)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:541)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: The <datanucleusenhancertask> type doesn't support the nested "args" element.
at org.apache.tools.ant.IntrospectionHelper.throwNotSupported(IntrospectionHelper.java:503)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:352)
... 12 more
BUILD FAILED (total time: 44 seconds)
The (official) DataNucleus enhancer Ant task (seen here) has no such args as input. Those args are Google's own stuff (whatever the "enhance_war" thing refers to). All DataNucleus enhancer cares about is having the relevant jars in the CLASSPATH and is configurable as per this.

Ivy CleanCache Task throwing NullPointException

I have the following project directory structure:
MyProject/
src/main/java/
All of my Java sources
build/
build.xml
build.properties
ivy.xml
ivy-settings.xml
ivy-settings.properties
The build.xml looks like this:
<project name="MyProject" default="audit" basedir=".." xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="build/build.properties"/>
<property environment="env"/>
<path id="ant.lib.path">
<fileset dir="${env.ANT_HOME}/lib" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ant.lib.path"/>
<target name="configIvy">
<echo message="Configuring Ivy."/>
<echo message="URL is: ${ivy.settings.home}"/>
<ivy:settings url="${ivy.settings.home}"/>
<!-- Clear/flush the Ivy cache. -->
<echo message="Cleaning the local Ivy cache for the current build."/>
<ivy:cleancache/>
</target>
</project>
When I run ant -buildfile /<path-to-my-project>/MyProject/build/build.xml configIvy, I get the following console output:
Buildfile: /<path-to-my-project>/MyProject/build/build.xml
configIvy:
[echo] Configuring Ivy.
[echo] URL is: file:////<path-to-my-project>/MyProject/build/ivy-settings.xml
[ivy:cleancache] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::
BUILD FAILED
/<path-to-my-project>/MyProject/build/build.xml:85: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.ivy.util.url.URLHandlerRegistry.getHttp(URLHandlerRegistry.java:47)
at org.apache.ivy.ant.IvyAntSettings.configureURLHandler(IvyAntSettings.java:367)
at org.apache.ivy.ant.IvyAntSettings.createIvyEngine(IvyAntSettings.java:267)
at org.apache.ivy.ant.IvyAntSettings.getConfiguredIvyInstance(IvyAntSettings.java:237)
at org.apache.ivy.ant.IvyTask.getIvyInstance(IvyTask.java:92)
at org.apache.ivy.ant.IvyTask.prepareTask(IvyTask.java:256)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:276)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.NullPointerException
at org.apache.log4j.Category.isDebugEnabled(Category.java:129)
at org.apache.commons.logging.impl.Log4JLogger.isDebugEnabled(Log4JLogger.java:239)
at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:69)
... 25 more
My ivy-settings.xml file specifies a URL resolver of an Artifactory repo that is hosted on my local machine (http://localhost:8080/artifactory/myrepo). I'm wondering if Ivy uses HttpClient under the hood (as the stacktrace suggests), and for some reason, is choking because its an HTTP URL on the same machine? Maybe?!? And yes, I'm sure that the URL is correct and that Artifactory is running while I run the Ant build!
Can anyone spot what is going on here? Why would <ivy-cleancache> throw a NPE? I'm looking at its source code and can't seem to find where the NPE is coming from, or why. I can supply more details if needed. Thanks in advance!
I thought I gave a response to this, but I don't see it here...
Don't put extra jars for your projects into $ANT_HOME/lib. There are several reasons for this:
As you've found out, there can be jar clash as each set of optional tasks tries to setup the classpath they need. Yes, it's nice not having to set a classpath when you do a <taskdef>, but it's not that bad.
If you give your project to someone else, they'll have to install all of the optional jars too before they can do a build.
The better way is to create a ${basedir}/ant.lib directory, and then put each set of ant task jars in their own sub-directory. For example, you'd put Ivy jars in ${basedir}/ant.lib/ivy and you put Checkstyle jars in ${basedir}/ant.lib/checkstyle. Then, you define your taskdef with a classpath pointing to the directory like this:
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant">
<classpath>
<fileset dir="${basedir}/lib/ivy"/>
</classpath>
</taskdef>
This way, Ivy doesn't pick up the wrong jars. As a bonus, you can also give someone your project, and Ivy is already installed and running for them. No need for them to download Ivy and setup the jar in the right classpath.
By the way, $ANT_HOME/lib is already in the Ant classpath, so if you didn't specify a classpath, all the jars in $ANT_HOME/lib will be picked up automatically. You could have simply done this:
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant"/>
with no classpath required.

Dojo 1.7 Build: Out of Memory Errors

After upgrading to Dojo 1.7.3, our ant build that was working flawlessly for years on previous versions of Dojo is now completely non-operational due to out of memory errors:
[java] starting writing resources...
[java] java.lang.OutOfMemoryError: GC overhead limit exceeded
[java] at org.mozilla.javascript.Interpreter.getArgsArray(Interpreter.java:4623)
[java] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335)
[java] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
[java] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
[java] at org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:1565)
[java] at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:313)
[java] at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
[java] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335)
[java] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
[java] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
[java] at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2347)
[java] at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:272)
[java] at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
[java] at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
[java] at org.mozilla.javascript.gen.c1._c62(Unknown Source)
[java] at org.mozilla.javascript.gen.c1.call(Unknown Source)
[java] at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
[java] at org.mozilla.javascript.gen.c1._c69(Unknown Source)
[java] at org.mozilla.javascript.gen.c1.call(Unknown Source)
[java] at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
[java] at org.mozilla.javascript.gen.c1._c40(Unknown Source)
[java] at org.mozilla.javascript.gen.c1.call(Unknown Source)
[java] at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
[java] at org.mozilla.javascript.gen.c1._c42(Unknown Source)
[java] at org.mozilla.javascript.gen.c1.call(Unknown Source)
[java] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335)
[java] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
[java] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
[java] at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2347)
[java] at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:272)
[java] at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
[java] at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
[java] js: exception from uncaught JavaScript throw: java.lang.OutOfMemoryError: GC overhead limit exceeded
I have extensively documented our troubles here.
In particular, where I note:
If I run my build straight from the CL as a Java command, with the '
--optimize shrinksafe" switch, it fails, but without it succeeds. (running it with internStrings alone seems to cause other errors).
Not sure what to make of this, since I believe that oprtimize defaults
to shrinksafe, but I have determined the following:
WORKS:
c:\temp\dojo-release-1.7.3rc1-src\util\buildscripts>java -Xms256m
-Xmx256m -cp ../shrinksafe/js.jar;../closureCompiler/compiler.jar;../shrinksafe/shrinksafe.jar
org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js
baseUrl=../../dojo load=build -p
C:\company\builds\head\build\generated\general\comComplete.profile.js
--action release --releaseDir C:\company\builds\head\build\generated\general\htdocs\company\javascript\1420
BROKEN (out of memory errors):
c:\temp\dojo-release-1.7.3rc1-src\util\buildscripts>java -Xms256m
-Xmx256m -cp ../shrinksafe/js.jar;../closureCompiler/compiler.jar;../shrinksafe/shrinksafe.jar
org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js
baseUrl=../../dojo load=build -p
C:\company\builds\head\build\generated\general\comComplete.profile.js
--action release --releaseDir C:\company\builds\head\build\generated\general\htdocs\company\javascript\1420
--optimize shrinksafe --internStrings true
Unfortunately, the following ant script target continues to fail with
memory errors:
BuildNum: ${buildNum}
<path id="js.path"> <pathelement location="${basedir}"/>
</path>
<pathconvert targetos="unix" property="js.path.unix" refid="js.path"
/> js.path.unix: ${js.path.unix}
<!-- clean unpack and output dirs --> <delete
dir="${outputDir}/htdocs/company/javascript/src/" />
<copy file="${externalDir}/dojo/companyComplete.profile.js"
tofile="${outputDir}/companyComplete.profile.js" filtering="yes"
overwrite="yes">
<java fork="true"
dir="${outputDir}/htdocs/company/javascript/src/util/buildscripts"
classname="org.mozilla.javascript.tools.shell.Main"
failonerror="true">
-->
--> --> -->
Update 1
I've also tried it with:
<jvmarg value="-Xms5120m"/>
<jvmarg value="-Xmx5120m"/>
And also using the maxmemory setting on the ant java task itself.
Finally found the problem, the releaseDir switch value had both windows and unix file separators in it. That used to work fine in Dojo < 1.6 and typically Java has no problem with it. For some reason, the Dojo 1.7 build system hits memory problems in that case.
The releaseDir, after resolving the ant tokens from the question, had a mix of both unix and windows file separators:
<arg value="releaseDir=${output.dir}/path/foo/bar" />
-> Became ->
releaseDir=blah\blah\blah/path/foo/bar
And that was enough to cause the build to lock up at 'writing resources' and then crash with 'out of heap space'. (This is something Java normally handles without issue).
The fix was simple enough:
<path id="dojo.output.tmp">
<pathelement location=" ${output.dir}/path/foo/bar "/>
</path>
<pathconvert targetos="unix" property="dojo.output.dir" refid="dojo.output.tmp" />
...
<arg value="releaseDir=${dojo.output.dir}" />

Categories

Resources