2008-09-01

How to deploy Hudson on WebLogic ?

Hudson is an excellent continuous integration engine !

But if you have already tried to use it on WebLogic, you may have encoutered the following error :

 

hudson_ant


This error translated in English says :

"Your servlet container loaded its own Ant version, preventing Hudson to work.

Maybe you could try to fix that by either copying the Hudson lib in your container, or reversing the classloader tree with the child-delegation-first."

If you already read about the FilteringClassLoader mechanism article, it should ring a bell to you ! :)

Well, that's exactly what we are going to do here.

First, as Hudson is available only in WAR format, we are going to create an EAR (because the filteringClassLoader only applies to enterprise applications).

It's easy : just add a "META-INF" folder, like :

 

ROOT_Folder

----> META-INF

    ----> application.xml

    ----> Manifest.mf

    ----> weblogic-application.xml

----> hudson.war

 

Your weblogic-application.xml should look like :

 

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://www.bea.com/ns/weblogic/weblogic-application

http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<!-- server-version: 10.3 -->
    <wls:application-param>
        <wls:param-name>webapp.encoding.default</wls:param-name>
        <wls:param-value>UTF-8</wls:param-value>
    </wls:application-param>


    <wls:prefer-application-packages>
        <wls:package-name>org.apache.*</wls:package-name>
    </wls:prefer-application-packages>

</wls:weblogic-application>

 

In blue, we declared the org.apache package to be loaded from the application first.

Then after that, zip the content (and NOT your root folder) of your root folder such as :

 

image

 

Then deploy it on WebLogic and you should normally be able to access Hudson !

 

image

 

Mots clés Technorati : ,,,

15 comments:

Thomasv@mac.com said...

I am getting a Unable to access the selected application.
[J2EE Deployment SPI:260101]Parameter 'WebLogicDeployableObject' may not be null.
when I try to deploy on 9.2.3 . Any ideas?

Anonymous said...

Great article! Works perfectly. Thanks so much.

Anyone know where is $HUDSON_HOME defined when we deploy hudson this way?

Eric Jung said...

"Anyone know where is $HUDSON_HOME defined when we deploy hudson this way?"

On Windows, it appears to be the .hudson directory in C:\Documents and Settings\user\.hudson

Andy said...

Instead of:

<wls:prefer-application-packages>
<wls:package-name>org.apache.*</wls:package-name>
</wls:prefer-application-packages>

would you not rather restrict the loading of just the ANT classes as such:

<wls:prefer-application-packages>
<wls:package-name>org.apache.ant.*</wls:package-name>
</wls:prefer-application-packages>

and not preclude the loading of any other org.apache.* classes from the server's classpath?

Thanks in advance Max! :)

Andy said...

Also, do you really need the application.xml file since we're deploying to a JEE v5 container? I thought for JEE v5 the requirement for an EAR to have an application.xml file was dropped?

Maxence Button said...

Hi Andy,

Well, you may select only the ant package of the apache classes, but you may encounter some linkage errors. By using a FCL at "apache" level, you're sure that only the Apache classes you shipped within your archive will be loaded. But still, you've got the right to play with the packages :)

As for the application.xml, you're right, you can drop it, if you want, especially since there is no useful information in it. It was automatically created by Eclipse and I didn't remove it, that's all !

Regards.

Maxence Button said...

@Thomas, sorry I let you down. I'm afraid the FilteringClassLoader mechanism only apply to WLS 10 and above. It will not work on a 9.2.3.

You'll have to use the old-fashioned "prefer-web-inf-classes".

Go take a look at my post on filtering class loader : I'm explaining the differences between those two modes.

Regards.

Girish said...

@Thomas
just add an application.xml file under META-INF folder with the following content

<?xml version="1.0" encoding="UTF-8"?>
<application version="1.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>hudson</display-name>
<module>
<web>
<web-uri>hudson.war</web-uri>
<context-root>/hudson</context-root>
</web>
</module>
</application>

Girish said...

@Thomas
just add an application.xml file under META-INF folder with the following content

<?xml version="1.0" encoding="UTF-8"?>
<application version="1.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>hudson</display-name>
<module>
<web>
<web-uri>hudson.war</web-uri>
<context-root>/hudson</context-root>
</web>
</module>
</application>

Nilo Garcia said...

Hi,

I followed your article to try deploy Hudson 1.348 in WebLogic 10.3.2 but without sucess.
I got take that error:
java.lang.NoSuchMethodError: org.dom4j.io.HTMLWriter.setEnabled(Z)

So, I used your tip and I changed the weblogic-application.xml like that:



webapp.encoding.default
UTF-8


org.apache.*
org.dom4j.*



And, voilá. Now that's work fine.
Thank you for the tips.

Abhijeet Joshi said...

Success Story:
I tried deploying Hudson 1.373 on Weblogic 10.3.3 and got an error because of the DISPLAY attribute on Linux (64 bit). I simply unset the display variable on the machine using the linux command "unset DISPLAY" (check the set command before and after to see DISPLAY being cleared). Simply create a weblogic domain in development mode and drop hudson.war in the domain's autodeploy folder. Hudson is up!

Jay Meyer said...

I posted this info onto the Hudson wiki here : http://wiki.hudson-ci.org/display/HUDSON/Weblogic

It worked great for me, thanks for the help.

martib said...

For hudson 1.396 and Weblogic 10.3.4 I had to change the weblogic-application.xml like that:

org.apache.*
javax.xml.stream.*
org.dom4j.*

Unknown said...

Hi Maxence
I get the foolowing error do you have any comments

Error 500--Internal Server Error

org.apache.commons.jelly.JellyTagException: zip:/oracle/fmwhome/user_projects/domains/dev_soa_osb/servers/AdminServer/tmp/_WL_user/hudson/potqb8/war/WEB-INF/lib/hudson-core-3.2.1.jar!/org/eclipse/hudson/init/InitialSetup/index.jelly:20:55: org/dom4j/io/HTMLWriter.setEnabled(Z)V
at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:728)
at

Unknown said...

Error 500--Internal Server Error

org.apache.commons.jelly.JellyTagException: zip:/oracle/fmwhome/user_projects/domains/dev_soa_osb/servers/AdminServer/tmp/_WL_user/hudson/potqb8/war/WEB-INF/lib/hudson-core-3.2.1.jar!/org/eclipse/hudson/init/InitialSetup/index.jelly:20:55: org/dom4j/io/HTMLWriter.setEnabled(Z)V
at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:728)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:290)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:9