Tuesday, January 12, 2010

Apache Tika (Lucene) build issue - java.lang.OutOfMemoryError: Java heap space

While building apache tika from source, I get the following issue


$ mvn package

[INFO] [bundle:bundle {execution: default-bundle}]
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.(String.java:215)
at java.lang.StringBuilder.toString(StringBuilder.java:430)
at aQute.lib.osgi.Clazz.normalize(Clazz.java:696)
at aQute.lib.osgi.Clazz.doClassReference(Clazz.java:409)
at aQute.lib.osgi.Clazz.parseClassFile(Clazz.java:262)
at aQute.lib.osgi.Clazz.(Clazz.java:101)
at aQute.lib.osgi.Analyzer.analyzeJar(Analyzer.java:1647)
at aQute.lib.osgi.Analyzer.analyzeBundleClasspath(Analyzer.java:1563)
at aQute.lib.osgi.Analyzer.analyze(Analyzer.java:108)
at aQute.lib.osgi.Builder.analyze(Builder.java:294)
at aQute.lib.osgi.Builder.doConditional(Builder.java:260)
at aQute.lib.osgi.Builder.build(Builder.java:75)
at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlugin.java:391)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:282)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:236)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:227)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
......
......


The solution is easy enough - just increase memory like so

$ MAVEN_OPTS="-Xmx3g" mvn package


Hope this helps folks who are getting tripped on this issue

2 comments:

Unknown said...

Hi Amitava,

I'm building tika on a virtual Ubuntu so I had to set memory to a lower size and run
MAVEN_OPTS="-Xmx1g" mvn install
but your tip definitely solved.

Thanks a lot!
rash*

Unknown said...

thanks for blogging this, it worked for me too