Tuesday, 19 May 2009

JARSearch

This is just a quick post to share a Windows utility (cmd script) for finding Java resources in JAR files located under a given location. This can be very useful in helping to solve ClassNotFound errors by finding out which JAR file should be on the classpath.

This utility looks for JAR files recursively under the given path hopefully simplifying the search process.

The command syntax for the utility is:

jarsearch search_term [search_base]

Where:
  • search_term is a string representing the resource to find and
  • search_base is the path which will be recursively searched for JAR files

This utility uses the JAR command and therefore understands Java packages as directories rather than true dot notation package names. Therefore referencing a package requires using the forward-slash '/' character. For example the following would look for the String class in the java.lang package in ALL JAR files located on drive C:

D:\> jarsearch java/lang/String C:\

And as the search term is just a substring of the filename contained in the JAR it is possible to search for a given package only.

The jarsearch utility is available at:

http://sites.google.com/site/weblogically/files/jarsearch.zip

Wednesday, 11 February 2009

JEE Tool of the Day: SoapUI

There are a number of tools that I personally find extremely useful in designing, developing and testing JEE applications. In my JEE Tool of the Day entries I hope to highlight a tool that I believe should be part of any JEE developer's toolbox.

Where possible I choose to highlight tools which are Java-centric (that is runs bytecode on a JVM, regardless of the actual implementation language), open source and as far as possible server/container agnostic (although those directly supporting WebLogic are considered favourably).

Please note that these tools are what I personally like and use and I have not direct affiliation to the authors of these tools. I would ask is that if you try these and like them then please do make an appropriate donation and support Java.

I realise that this type of post has a tendency to produce copious amounts of comments regarding alternatives, and I personally welcome this but please don't just post links, give a summary of how it differs and why it is better.

Today's tool of the day is Eviwares' SoapUI.

SoapUI provides a graphical tool that allows you to test and mock web services and as such positions itself as a SOA tool rather than a JEE tool.


For more information goto the SoapUI website.

Tuesday, 13 January 2009

Grep WebLogic Logs

The WebLogic logs do not obey a nice one line per entry, for example a log entry containing a stack trace will often occupy many lines. This makes reading the stack trace in the log quite easy but does not help if you try to use grep to search the logs.

For example:

####<13-jan-2009> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <1231840002265>
at weblogic.management.mbeanservers.edit.internal.ConfigurationManagerMBeanImpl.save(ConfigurationManagerMBeanImpl.java:243)
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:585)
at weblogic.management.jmx.modelmbean.WLSModelMBean.invoke(WLSModelMBean.java:443)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)

The following is a script that I use that makes use of gawk (available on most Linux installations or via Cygwin) that uses the WebLogic log record separator (####) to emulate grep for an entire log entry.

#!/bin/bash
if [ $# -lt 2 ]; then
echo "$0 pattern file(s)"
exit 1
fi
pattern=$1
shift
gawk "BEGIN{RS=\"####\"}/$pattern/{print \$0}" $*

For example if this script is saved as loggrep.sh then you can search for entries containing a pattern with:

loggrep.sh MyException /domain1/servers/ms1/logs/*.log*