MaintainJ Blog

September 27, 2015

MaintainJ.war is updated

Filed under: Uncategorized — maintainj @ 10:15 am

The following fix and enhancements went into this release.

1. In the previous version, in some browsers, nothing happens when the ‘Install’ button is clicked. This bug is fixed now.
2. At installation time, a warning is shown in Perm Gen space is low.
3. An option to just trace method calls and not the data is added
4. An option not to merge trace files with data is added. Trace files can be merged offline later in eclipse. Merging trace files with data takes up lot of heap space in server JVM.

-Choudary Kothapalli.

September 22, 2015

JBoss EAP 6+ is JBoss AS 7 and its problems with MaintainJ

Filed under: Uncategorized — maintainj @ 8:50 pm

As this link shows, JBoss EAP 6+ based on JBoss AS 7.

JBoss AS 7 uses OSGI class loading model, which is very different from the regular hierarchical class loading model we are familiar with in application servers. Even if you add a jar file to the server classpath, the web applications (the war files) cannot see it. The workaround is to specify the packages in those jar files using a special JBoss system property jboss.modules.system.pkgs.

MaintainJ.war, which helps to configure MaintainJ on application servers, sets this property in the run_with_mnj.bat file as below. Users are supposed to use this script to restart JBoss so that they can trace the applications using MaintainJ. Below is a sample content of run_with_mnj.bat.

————

SETLOCAL set JAVA_OPTS=”-javaagent:C:\JBossEAP610\maintainj\MaintainJAgent.jar” -Dorg.aspectj.weaver.loadtime.configuration=file:C:\JBossEAP610\maintainj\maintainj.xml -Djboss.modules.system.pkgs=com.maintainj.aspect,com.maintainj.inst,org.aspectj -Dorg.aspectj.tracing.enabled=false -Dorg.aspectj.tracing.factory=default %JAVA_OPTS%

call “standalone.bat” %* ENDLOCAL

————-

As highlighted in bold, MaintainJ sets its packages as the value of System property jboss.modules.system.pkgs. But, for some users, the MaintainJ configuration still fails even with this setting being there. Why?

The reason is, this property is overridden by user’s server settings in¬†standalone.conf.bat like in the line below.

set JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman

If this is the case, the solution is to add MaintainJ’s system packages to this line like below.

set JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman,com.maintainj.aspect,com.maintainj.inst,org.aspectj

This should resolve the issue.

–Choudary Kothapalli.

September 9, 2015

New MaintainJ.war to trace web applications

Filed under: Uncategorized — maintainj @ 7:40 pm

A new and much simplified version of MaintainJ.war is released to configure MaintainJ on web applications. Now you just need to add two JVM arguments to server JVM to instrument the application and start tracing. Check these screenshots to get an overview of this process.

–Choudary Kothapalli

May 10, 2012

The tricks of Java serialization

Filed under: Uncategorized — maintainj @ 4:59 pm

Whenever I start looking deeper into Java’s serialization mechanism, I seem to learn something new. Here is something I learned yesterday. Read the code snippet below and try to guess the output.

import java.io.*;

class DataHolder implements Serializable{
String data = "data";
}
public class SerializationTester {
static String serFile = "test.ser";
static void write() throws Exception{
//Create an object and write to ObjectOutputStream
DataHolder dh = new DataHolder();
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(serFile));
oos.writeObject(dh);

//Change the state and write to the same stream again
dh.data = "New data";
oos.writeObject(dh);
oos.close();
}
static void read() throws Exception{
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(serFile));
DataHolder dh1 = (DataHolder)ois.readObject();
DataHolder dh2 = (DataHolder)ois.readObject();
ois.close();
System.out.println(dh1.data + "--" + dh2.data);
}
public static void main(String[] args) throws Exception{
write();
read();
}
}

What do you think will be the output? It’s ‘data–data’. The new value set to the DataHolder.data field is not written to the stream. To make the Java serialization mechanism write the new value to the stream, we have to reset the stream by calling ObjectOutputStream.stream().

Check this article on Serialization to understand what’s going on. The part that’s of interest to us is below:

—–

… consider the situation in which an object is written to a stream and then written again later. By default, an ObjectOutputStream will maintain a reference to an object written to it. That means that if the state of the written object is written and then written again, the new state will not be saved! Here is a code snippet that shows that problem in action:

10 ObjectOutputStream out = new ObjectOutputStream(...);
20 MyObject obj = new MyObject(); // must be Serializable
30 obj.setState(100);
40 out.writeObject(obj); // saves object with state = 100
50 obj.setState(200);
60 out.writeObject(obj); // does not save new object state

There are two ways to control that situation. First, you could make sure to always close the stream after a write call, ensuring the new object is written out each time. Second, you could call the ObjectOutputStream.reset() method, which would tell the stream to release the cache of references it is holding so all new write calls will actually be written. Be careful, though — the reset flushes the entire object cache, so all objects that have been written could be rewritten.

—–

–Choudary Kothapalli.

April 19, 2012

The class xxx exceeds the maximum class size supported by the JVM

Filed under: Uncategorized — maintainj @ 10:31 am

If you get this error when you start your application with MaintainJ, please exclude that class in the aop.xml. Check this FAQ entry on how to edit the aop.xml and exclude a class.

–choudary Kothapalli.

Unable to continue, this version of AspectJ supports classes built with weaver version 6.0 but the class XXX is version 7.0

Filed under: Uncategorized — maintainj @ 10:19 am

You might see this kind of exception when you start your application with MaintainJ. The reason for this exception is nicely described by the AspectJ lead Andy in his blog.

This exception might occur if you are already using AspectJ in your application, which may conflict with the version of AspectJ that MaintainJ is using. Below are the steps to resolve this:

1. Search if you have aspectjrt.jar or aspectjweaver.jar in your application classpath. Remove them if so.

2. MaintainJ already places aspectjweaver.jar at a higher level in the classpath. So, you don’t need it in your application. aspectjweaver.jar has all the classes in aspectjrt.jar and so you can safely remove it from your classpath.

Do those steps and restart your application. If you still have any problems, contact me.

–Choudary Kothapalli.

Next Page »

Powered by WordPress