Saturday, November 17, 2012

Running JSPWiki on Weblogic 11g

JSPWiki (http://www.jspwiki.org/) is a simple Wiki engine, that can be used to power a small Wiki to share knowledge on your project. If you have Oracle Weblogic infrastructure running (including e.g. Oracle SOA Suite), you can set up JSPWiki on one of your servers.
Small problem though ... JSPWiki does not play very well with Weblogic, mainly because Weblogic tries to insert its classes into your web application to reuse them. I was receiving couple NullPointerExceptions and ClassNotFoundException, and other Class Loader problems. So here are my instructions to run JSPWiki on Weblogic

Used software:
  • JSPWiki 2.8.4 (latest stable version at the time of writing)
  • Oracle Weblogic 12.1.1.0, or Oracle SOA Suite 11g
Instructions: 

1. Download and extract the JSPWiki distribution

2. Extract JSPWiki.war

3. Create a weblogic.xml file as WEB-INF/weblogic.xml 

4. Paste the following content into the file:

<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
  <wls:context-root>JSPWiki</wls:context-root>
  <wls:container-descriptor>
    <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
  </wls:container-descriptor>
</wls:weblogic-web-app>


This is to tell Weblogic to use classes deployed in the archive, and not to force its own libraries for the application.

5. Locate $WL_SERVER/modules/org.apache.ant_1.7.1/lib folder and copy the following libraries into the WEB-INF/lib folder of JSPWiki:
  • xml-apis.jar
  • xercesImpl.jar
You can get these libraries from other sources too (e.g. Maven repository), these from Ant were working with JSPWiki. Otherwise JSPWiki will try to use classes from Weblogic, which are not compatible with JDom.

At this moment you can also modify the JSPWiki configuration files (jspwiki.properties, jspwiki.policy) for your deployment. You can find the instructions on JSPWiki web site.

6. Repackage the JSPWiki back into the war file.

7. Create a new folder for JSPWiki EAR archive and with the following structure:
  • META-INF
    • application.xml
    • weblogic-application.xml
  • JSPWiki.war
8. Paste the following into the META-INF/application.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
  "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
  "http://java.sun.com/dtd/application_1_3.dtd">
<application>
   <display-name>JSPWiki</display-name>
  <module>
    <web>
      <web-uri>JSPWiki.war</web-uri>

      <context-root>/JSPWiki</context-root>
    </web>
  </module>
</application>


9. Paste the following into the META-INF/weblogic-application.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/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://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.3/weblogic-application.xsd">
  <wls:xml>
    <wls:parser-factory>
      <wls:saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</wls:saxparser-factory>
      <wls:document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</wls:document-builder-factory>
    </wls:parser-factory>
  </wls:xml>
  <wls:prefer-application-packages>
    <wls:package-name>org.apache.xerces.*</wls:package-name>
  </wls:prefer-application-packages>
</wls:weblogic-application>


This is because Weblogic on SOA Suite still tries to use internal XML Parsing classes for the application, and fail on exceptions. These settings cannot be applied on WAR level, that's why we had to create an enterprise application.

10. Package the ear archive for JSPWiki and deploy on Weblogic. 

And good luck on using JSPWiki.

Final Note:
At the moment, the JSPWiki site does not allow to add or modify content due to migration to ASF infrastructure. For these reasons I've used a blog entry. I will try to contribute the content back to JSPWiki site, when it is again possible.

No comments:

Post a Comment