Where the SAP Java classes are
When you develop a SAP Java application (Portal, PI, WDJ, Neo) you do not have to take too much care into the Java classes used by your project. The Eclipse SDK is already handling this. Nevertheless, from time to time you may want to know more about the Java classes packaged in JAR files used by your applications. Alternatively, you even get charged in providing reports detailing the class references your project is using, or even tasked with creating reports that show the Java classes used in a NetWeaver installation.
One tool that helps you in getting reports out of the content of JAR files is tattletale.A look at the feature list shows that several of it are appealing:
- “Identify dependencies between JAR files
- Spot if a class/package is located in multiple JAR files
- Spot if the same JAR file is located in multiple locations
- With a list of what each JAR file requires and provides
- Locate a class in a JAR file” [1]
The most obvious use case where the reports tattletale provides helps you is finding “that CLASS” that is somehow missing (ex: JCA use cases). It reports the dependencies your application has as well as finding a duplicate (outdated) CLASS inside a JAR file.
Two directory that contain valuable JAR packages from SAP are:
SAP NetWeaver AS Java: 7.0x
- /usr/sap/<INST>/JC<##>/j2ee/cluster/server<N>/apps/sap.com/
- /usr/sap/<INST>/JC<##>/j2ee/cluster/server<N>/bin
SAP NetWeaver AS Java: 7.3x
- /usr/sap/<INST>/JC<##>/j2ee/cluster/apps/sap.com/
- /usr/sap/<INST>/JC<##>/j2ee/cluster/bin
To get a list of SAP jars you only have to run tattletale against these directories to get the reports.
Reports
It takes a time for tattletale to create the reports, but this is a one time task (per SP, EHP or even release). Still, in my case, the report generation took 30 minutes for the sap.com folder. The reports are rather large. For 7.0x it’s more than 320 MB.
Class location
The JAR files another JAR file depends on
Details about a JAR file
Tattletale can also be run against a single WAR or EAR file:
./java/bin/java -Xmx512m -jar tattletale.jar com.tobias.trn.test.war ./reports/
Possible problems
There can be many, many JAR files inside a directory like apps/sap.com. If this is the case, tattletale will exit with an OOME:
./java/bin/java -jar tattletale.jar /usr/sap/CTB/JC00/j2ee/cluster/server0/apps/sap.com/ ./reports/
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1055)
at javassist.bytecode.ConstPool.read(ConstPool.java:1033)
at javassist.bytecode.ConstPool.<init>(ConstPool.java:149)
at javassist.bytecode.ClassFile.read(ClassFile.java:764)
at javassist.bytecode.ClassFile.<init>(ClassFile.java:108)
at javassist.CtClassType.<init>(CtClassType.java:94)
at javassist.ClassPool.makeClass(ClassPool.java:717)
at javassist.ClassPool.makeClass(ClassPool.java:695)
at org.jboss.tattletale.analyzers.AbstractScanner.scanClasses(AbstractScanner.java:179)
at org.jboss.tattletale.analyzers.JarScanner.scan(JarScanner.java:106)
at org.jboss.tattletale.analyzers.WarScanner.scan(WarScanner.java:175)
at org.jboss.tattletale.Main.execute(Main.java:612)
at org.jboss.tattletale.Main.main(Main.java:1099)
Adjust the heap size to a value high enough like [2]:
./java/bin/java -Xmx512m -jar tattletale.jar /usr/sap/CTB/JC00/j2ee/cluster/server0/apps/sap.com/ ./reports/
Tattletale needs Java 5 to run. In case your NetWeaver is <7.1, you’ll have to install Java 5.
[1] Tattletale home page http://www.jboss.org/tattletale
[2] Documentation http://docs.jboss.org/tattletale/userguide/1.2/en-US/html_single/#running
Nice blog Tobias, thanks for sharing!
In addition, Tattletale may also help in finding duplicate classes with different versions -- or duplicate jar files in different locations.
Hi Robin,
yes, tattletale comes with additional reports like the ones you mentioned. I skipped them to prevent people running these reports against the JAR files used by NW AS Java. People might come to the right or wrong conclusion 😆
Hi Tobias,
I liked your blog.
It is very good to find a tool like http://www.jboss.org/tattletale
which is not only helpful but also a great help to all Java Developers.
It helps not only in finding the duplicate classes with different versions but also creates a reports based on the class files.
Another point I need to ask from both you and Robin; is it feasible to change the SAP Standard onclick event to onkeypress event ?
I have posted the below post in this regard.
http://scn.sap.com/thread/3311732
Thanks & Regards
Kaushik Banerjee