Wednesday, July 13, 2011

java.lang.OutOfMemoryError during package deployment

Following problem appears in our environement.

[INFO] Uploading repository metadata for: 'artifact com.o2.sso:sso-distribution-atg'
Uploading: http://172.26.214.14:8080/nexus/content/repositories/release//com/o2/sso/sso-distribution-atg/1.1.14/sso-distribution-atg-1.1.14-to2.zip
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:61)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:492)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:457)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:411)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
at org.apache.maven.artifact.manager.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:317)
at org.apache.maven.artifact.manager.DefaultWagonManager.putArtifact(DefaultWagonManager.java:227)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:107)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:190)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 10 seconds
[INFO] Finished at: Wed Jul 13 13:32:14 CEST 2011
[INFO] Final Memory: 97M/292M
[INFO] ------------------------------------------------------------------------

solution is quite simple, just make bigger available memory:


export MAVEN_OPTS=" -Xms100M -Xmx1024M"



Wednesday, July 6, 2011

java.lang.NoClassDefFoundError: antlr/ANTLRException

2011.07.06.13.06.28 ERROR tapestry5.services.TapestryModule.RequestExceptionHandler - Processing of request failed with uncaught exception: antlr/ANTLRException
java.lang.NoClassDefFoundError: antlr/ANTLRException
 at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:35)
 at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
 at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
 at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
 at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
 at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
 at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)

Problem appears when hibernate 3.2.0.ga is not used with correct version of antlt 2.7.6 but with greater version 3.1.1 because of tapestry 5 dependencies. To fix it just provide correct version 2.7.6.

Tuesday, July 5, 2011

Problem with max allowed packed size property 'max_allowed_packet'

I have meet following problem in logs.
java.sql.BatchUpdateException: Packet for query is too large (2542834 > 1048576).
You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
Solution is to change value 'max_allowed_packet' in mysql. It could be done in few ways:
  • change value in command line
  • setup value in configuration file 'my.cnf'
  • set value in startup property
  • change value in configuration table
let me briefly describe some of these options

add 3)

start mysql with following property:
mysqld --max_allowed_packet=32M
then restart mysql service.

add 4)

mysql -u root -p<password>

show variables like 'max_allowed_packet';

+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 | 
+--------------------+---------+
1 row in set (0.00 sec)

set global max_allowed_packet = 15000000;
Please note that this change is visible and applied to all new JDBC connection.