Tuesday, October 16, 2012

How to access remote JVM with JMX console

JMX console allows monitor and partially adjust properties or running JVM. Accessed JVM could be at localhost where is JMX console started or could be remote. When you start JMX console by command jconsole following screen will appear:
When remote JVM should be accessed than remote JVM have to be ready for this.

Let's configure JVM to provide JMX remote access and protect access by name and password. JVM have to be started with following parameters:
JAVA_OPTS=${JAVA_OPTS}" -Dcom.sun.management.jmxremote=true"
JAVA_OPTS=${JAVA_OPTS}" -Dcom.sun.management.jmxremote.port=9999"
JAVA_OPTS=${JAVA_OPTS}" -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS=${JAVA_OPTS}" -Dcom.sun.management.jmxremote.password.file=/home/.../jmxremote.password"
JAVA_OPTS=${JAVA_OPTS}" -Dcom.sun.management.jmxremote.access.file=/home/../jmxremote.access"
JAVA_OPTS=${JAVA_OPTS}" "
export JAVA_OPTS

At remote machine, where will be JVM started have to be accessible file jmxremote.password:
#content of file jmxremote.password

honza somePassword
And file jmxremote.access
# content of file jmxremote.access

honza readwrite

When this files are created and accessible by JVM running with previously listed parameters than remote JVM should be accessible from console.


Possible problems

When following error occurs:
jmx error: Password file read access must be restricted

You have to adjust access rights for both files in this way:
chmod 600 jmxremote.access
chmod 600 jmxremote.password

Additional info

Nice description could be found in file password.properties which is part of JDK 1.5.
# password.properties

# Password file for Remote JMX API authentication. This file defines
# the different roles and their passwords.

# The file format for the password file is syntactically the same as
# the Properties file format. The syntax is described in the Javadoc
# for java.util.Properties.load.

# A typical password file has multiple lines, where each line is blank,
# a comment (like this one), or a password entry.

# A password entry consists of a role name and an associated password.
# The role name is any string that does not itself contain spaces or
# tabs. The password is again any string that does not contain spaces
# or tabs. Note that passwords appear in the clear in this file, so it
# is a good idea not to use valuable passwords.

# A given role should have at most one entry in this file. If a role
# has no entry, it has no access.
# If multiple entries are found for the same role name, then the last
# one is used.

# In a typical installation, this file can be read by anybody on the
# local machine, and possibly by people on other machines.
# For security, you should either restrict the access to this file,
# or specify another, less accessible file in the management config
# file as described above.

# Role and password used for authentication by the RMI connector in
# this example.
#
username password

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.

Monday, August 9, 2010

GWT java.lang.AssertionError




Uncaught exception: java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
at com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:136)
at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)

Tato chyba se objevovalo po zavolanI: RootPanel.get("kTableHelper")

Problem byl, ze v HTML kodu bylo:

<div id="div1">

namisto spravneho:


<div id="table"></div>