Bundling external library classes inside a jar

September 13, 2007

Some software suppliers are bundling external classes inside their propriety jars. A good, or should I say bad, example is ATG…..

JAXB conflict

With GlassFish Metro’s wsimport.sh script I generated Java interfaces and other supporting classes from a wsdl file. In a small test project it all worked like a charm.

Then I copied my code to an ATG project which needed my code. My testcase suddenly failed with a java.lang.NoSuchMethodError: javax.xml.bind.JAXBContext.newInstance(..
Ouch.

It took me some time to understand the problem. The problem is that the ATG das2007.1.jar contains a lot of external libraries. For instance Xerces or Xalan. However they changed the namespace to for instance atg.apache.xerces.. So conflicts are less likely.

But it also contains javax.xml.bind.JAXBContext. Grr this is JAXB 1 and my JAX-WS Metro stuff needs JAXB 2. Of course I can change the class-path order and I can do this in Eclipse, so my tests will work.
However ATG specification says that ATG-Required modules will be started up, in the order specified, before any modules started with ATG-Class-Path. So DAS will always be loaded before any custom jars according to the specification… I have not validated this yet, but I’m afraid that the specification is the way it works and thus my code will not work inside the Application container.

This will mean that this lovely solution will not work

And Spring, and CGLib, and Mozilla packages, and Sun packages and IBM BSF, Apache Commons etc etc?

IBM BSF? The Bean Scripting Framework got promoted to Jakarta in 2002 and for some time now it has an Apache namespace and not an IBM namespace. That is some old stuff in the das jar. This is taking “If it aint broke don’t fix it” to a new level.
And does anybody else find it funny that an ATG jar, especially the one containing Nucleus, contains Spring classes. Ok it is just the Spring AOP classes, but still. Nucleus and Spring IOC are birds of a feather. These are just some of the examples of some of the embedded classes.

Why bundle libraries?

I sort of understand that you want to control the versions of external libraries you need, but bundling them in stealth mode is bad practice in my opinion. Especially if you are a framework like ATG. Frameworks don’t live in a vacuum, they need extra custom code and thus clashes are likely. I rather see the jars and documentation for which library versions your product is tested.

I’m not really fluent in Ruby but Ruby’s require_gem with the version argument sounds like a nice feature.


ATG 2007.1 on Mac OS X with MySQL

August 13, 2007

For some weeks now ATG 2007.1 is available. My entry about installing ATG on Mac OS X explained how to install ATG 2006.3 on Mac OS X Tiger which is not supported by ATG . It got a few hits, so perhaps an update is needed.

Pre installation

  • Have jboss-4.0.5GA ready. This is the only version supported by ATG 2007.1.
  • Have MySQL ready. Only 5.0.20 is supported. However I have used 5.0.45 and so far it seems to be working fine. Make sure you use the InnoDB engine instead of the MyISAM.
  • Create an ATG user on MySQL in a way you seem fit
  • Add export JBOSS_HOME=<your JBOSS 4.0.5GA path here> to .bash_login. If you use another shell, you know what to do.
  • Take care of your permissions.
  • Download ATG2007.1 for Unix

Installation and configuration

  • Run ATG2007.1.bin
  • When asked to enter the path where to install ATG, remove the space. It will make things easier.
  • When asked for JAVA_HOME use /System/Library/Frameworks/JavaVM.framework/Versions/ 1.5.0/Home or your preferred version.
  • Drop your license files in <ATG folder>/home/localconfig
  • Add the following line export ATGJRE=/System/Library/Frameworks/JavaVM.framework/ Versions/CurrentJDK/Commands/java to dasEnv.sh
  • Copy MySQL JDBC driver (mysql-connector-java-5.0.7-bin.jar) to <JBOSS_HOME>/server/atg/lib
  • Add a mysql-ds.xl to <JBOSS_HOME>/server/atg/deploy and fill in the correct database name etc.
  • Create a file, like this: /home/localconfig/atg/dynamo/service/jdbc/JTDataSource.properties
    The ATG documentation states to create a jbossconfig folder with a change to a manifest to point to that path. I skipped that.
  • Edit this JTDataSource.properties. It should contain:
    JNDIName=java:/MySqlDS
    and
    $class=atg.nucleus.JNDIReference
  • Run datascripts:
    • /Applications/ATG2007.1/DAS/sql/install/mysql/das_ddl.sql
    • /Applications/ATG2007.1/DPS/sql/install/mysql/dps_ddl.sql
    • /Applications/ATG2007.1/DSS/sql/install/mysql/dss_ddl.sql
    • /Applications/ATG2007.1/DCS/sql/install/mysql/dcs_ddl.sql

    I used mysql -D <dbname> < /Applications/ATG2007.1/DAS/sql/install/mysql/ das_ddl.sql --user=<username> --password=<password>

Some notes

Adding Darwin to <ATG folder>/home/bin/DynamoEnv.sh is not something I use anymore as I did in 2006.3. I will assume Solaris. This will make patching easier, as Robert Hellwig found out.

Unlike ATG 2006.3 ATG2007.1 JTDatasource.properties can contain $class=atg.nucleus.JNDIReference

The executing of the SQL scripts was not correct in the previous Blog. The user and password command was wrong. Why didn’t anybody tell me?

On the previous blog entry, I got some questions on how you can tell MySQL to use InnoDB. Check your my.cnf or my.ini file. It’s in the ATG documentation:
ATG Doc


Debugging Nucleus components in JBoss with Eclipse

May 27, 2007

It seems that ATG developers are creatures of old habits. Most of them use VI or Emacs because they are used to it. Perhaps because they think it is better…. Only my observation of course. For all I know a lot of them are using Textmate with their custom ATG bundles.

And debugging? : through debug logging statements…

Since Java 1.2 we have the Java Platform Debugger Architecture. It amazes me how few are using it..

If you don’t know how to debug with JPDA when developing for ATG on JBoss with Eclipse it’s easy:

  • First start JBoss with debugging enabled. Do this by adding the line:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket, address=5000,server=y,suspend=n"

to the run.conf file in the <JBOSS_HOME>/bin folder and then

  • create a debug configuration in Eclipse. Use the Remote Java Application, Socket Attach. Use the port as defined in the JAVA_OPTS. Port 5000 in this example.

It should look something like this:
Eclipse debugging

Happy debugging


Fixing ACC “Preview site using profile” on Mac OS X

April 11, 2007

The Preview Site Using Profile functionality from the ACC does not work out of the box on Mac OS X. This is functionality which is really nice to have so you can preview the JSP page with a specific profile.

Because we are using the Linux installer on Mac OS X, I was unsure how the browser was started when you pressed preview. I did a global grep and noticed the showurl.sh containing the script to start the browser. This contains code to either startup Mozilla or Netscape. This will not work of course. So we need to change this. However before this can be done another step is needed.

Firefox new instance

Starting Firefox from the command line will not work if Firefox is already started. If somebody knows a way to open an already started Firefox with an URL I would really like to know.

Unknown to most people, but you can start Firefox for a second time with another Firefox profile.

To create a Firefox profile I did the folowing:

ls <firefox path>/Firefox.app/Contents/MacOS

./firefox -Profilemanager
And created a new firefox profile. I named mine atg.

Change showurl.sh

Then I altered the showurl.sh and added the following line

/<firefox path>/Firefox.app/Contents/MacOS/firefox-bin -p atg ${1}

And behold: It just works™


JBoss startup errors

April 9, 2007

Finally I got around to remove some errors which were visible during JBoss ATG startup.

One of them was:
FATAL [JspServletOptions] The scratchDir you specified: ……… is unusable (or something along that line)

This one is solved by setting the permissions correctly. A chown will solve this. I guess you won’t see such an error on Windows..

The other one was a [URLDeploymentScanner] Incomplete Deployment listing on jboss-xa-jdbc.rar.
I have no idea how to get rid of that one, but since I won’t be doing Distributed datasource there is actually no problem….I think.

[EDIT]

Got rid of that one also. Somehow a jboss-xa-jdbc.rar folder folder was inside the deploy folder of JBoss. Yes a folder with folder in the name. Removing that one solved the problem. (of course you have to keep the jboss-xa-jdbc.rar there)


Follow

Get every new post delivered to your Inbox.