Skip to main content

Deploy apache archiva 1.3.3 on Oracle Weblogic server

Deploy Apache Archiva web application archive (war) is not straight forward on WebLogic, although on apache site it declared that, it should be deploy on any J2ee server. This week we decided to upgrade our Archiva version from 1.3 to 1.3.3 and locate some interesting facts which should be fix to deploy on WebLogic server. In this following blog post you can get some useful information to deploy version 1.3 on WebLogic server. In this current post i am going to explain the maven way to fix all the problems among with Jpox ORM (we have oracle DB 10.3.1 as external database) and mailSession of Archiva to deploy on WebLogic. Most of all configuration you will get from the Apache Archiva site.
At first we have to download the source code of the Apache Archiva. You could found it here.Unzip the archive file and run mvn clean install -Dmaven.test.skip=true, it will download a few more plugin and dependency libraries to compile and install the artifact on you local machine (Assume that you already have mvn installed on your system).
Our aim is to add one weblogic.xml descriptor file to archiva-webapp/src/main/webapp/WEB-INF, add one maven ear module on archiva-web module to get ear artifact and edit archiva-base.xml file to change the column length.
First of all we will add following weblogic.xml in the \src\apache-archiva-1.3.3-src\archiva-modules\archiva-web\archiva-webapp\src\main\webapp\WEB-INF directory.
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"
                  xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
  <resource-description>
    <res-ref-name>mail/Session
    <jndi-name>mail/Session
  </resource-description>
</weblogic-web-app> 
Which will active resource location by jndi
Next we have to make some change on archive-base.xml located on \src\apache-archiva-1.3.3-src\archiva-modules\archiva-base\archiva-model\src\main\mdo . By default Archiva released with Jpox orm which data base object mapping is not supported for Oracle data types. Change the mapping for column named "message" for table  REPOSITORY_PROBLEMS as follows:
 <field stash.maxSize="4000">
  <name>message</name>
  <identifier>false</identifier>
  <version>1.0.0+</version>
  <required>true</required>
  <type>String</type>
  <description>
    The origin of the health problem.
  </description>
</field> 
Change the length of the field named "message" for table LICENSES as follows:
 <field stash.maxSize="4000">
  <name>comments</name>
  <version>1.0.0+</version>
  <type>String</type>
  <description>
    Addendum information pertaining to this license.
  </description>
</field> 
Edit the length of the field named "description"for tables PROJECT as follows:
 <field stash.maxSize="4000">
  <name>description</name>
  <identifier>false</identifier>
  <version>1.0.0+</version>
  <required>false</required>
  <type>String</type>
  <description>
    The description of this project.
  </description>
</field> 

You could also set the data type to Clob in order to String. The above fixes is enough to get rid of the following errors on weblogic:
java.sql.SQLSyntaxErrorException: ORA-00910: specified length too long for its datatype
You can compile and build the artifact to deploy it to WebLogic, it will set the context root to archiva-web-1.3.3. In order to change the context root of the Archiva web application we can create a maven ear module on archiva-web directory as follows:
\src\apache-archiva-1.3.3-src\archiva-modules\archiva-web\
|--archiva-ear
|--archiva-xmlrpc
|--archiva-webapp

add the module in the archive-web pom.xml as follows:
<modules>
    <module>archiva-applet</module>
    <module>archiva-security</module>
    <module>archiva-webapp</module>
    <module>archiva-webdav</module>
    <module>archiva-rss</module>
    <module>archiva-xmlrpc</module>
    <module>archiva-ear</module>
</modules> 
archiva-ear module will have the following structure:
archiva-ear
|----src\main\resources\META-INF\
|----pom.xml
pom.xml will have the following content:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.archiva</groupId>
        <artifactId>archiva-web</artifactId>
        <version>1.3.3</version>
    </parent>
    <artifactId>archiva-ear</artifactId>
    <packaging>ear</packaging>
    <name>Archiva Ear :: Application</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.archiva</groupId>
            <artifactId>archiva-webapp</artifactId>
            <version>1.3.3</version>
            <type>war</type>    
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <configuration>
                    <earSourceDirectory>src/main/resources</earSourceDirectory>
                    <version>5</version>
                    <modules>
                        <webModule>
                            <groupId>org.apache.archiva</groupId>
                            <artifactId>archiva-webapp</artifactId>
                            <contextRoot>/archiva</contextRoot>
                        </webModule>
                    </modules>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>                        
                </configuration>
            </plugin>
        </plugins>
    </build>  
</project> 
Add the following weblogic-application.xml into the archiva-web\archiva-ear\src\main\resources\META-INF directory
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-application">
  <application-param>
    <param-name>webapp.encoding.default</param-name>
    <param-value>UTF-8</param-value>
  </application-param>
</weblogic-application>
Now the code is complete and you can build and deploy to Weblogic server.
Happy coding & happy new year.

Comments

Popular posts from this blog

8 things every developer should know about the Apache Ignite caching

Any technology, no matter how advanced it is, will not be able to solve your problems if you implement it improperly. Caching, precisely when it comes to the use of a distributed caching, can only accelerate your application with the proper use and configurations of it. From this point of view, Apache Ignite is no different, and there are a few steps to consider before using it in the production environment. In this article, we describe various technics that can help you to plan and adequately use of Apache Ignite as cutting-edge caching technology. Do proper capacity planning before using Ignite cluster. Do paperwork for understanding the size of the cache, number of CPUs or how many JVMs will be required. Let’s assume that you are using Hibernate as an ORM in 10 application servers and wish to use Ignite as an L2 cache. Calculate the total memory usages and the number of Ignite nodes you have to need for maintaining your SLA. An incorrect number of the Ignite nodes can become a b...

Analyse with ANT - a sonar way

After the Javaone conference in Moscow, i have found some free hours to play with Sonar . Here is a quick steps to start analyzing with ANT projects. Sonar provides Analyze with ANT document to play around with ANT, i have just modify some parts. Here is it. 1) Download the Sonar Ant Task and put it in your ${ANT_HOME}/lib directory 2) Modify your ANT build.xml as follows: <?xml version = '1.0' encoding = 'windows-1251'?> <project name="abc" default="build" basedir="."> <!-- Define the Sonar task if this hasn't been done in a common script --> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath path="E:\java\ant\1.8\apache-ant-1.8.0\lib" /> </taskdef> <!-- Out-of-the-box those parameters are optional --> <property name="sonar.jdbc.url" value="jdbc:oracle:thin:@xyz/sirius.xyz" /> <property na...

Writing weblogic logs to database table

By default, oracle weblogic server logging service uses an implementation, based on the Java Logging APIs by using the LogMBean.isLog4jLoggingEnabled attribute. With a few effort you can use log4j with weblogic logging service. In the Administration Console, you can specify Log4j or keep the default Java Logging implementation. In this blog i will describe how to configure log4j with weblogic logging service and writes all the logs messages to database table. Most of all cases it's sufficient to writes log on files, however it's better to get all the logs on table to query on it. In our case we have 3 different web logic servers in our project and our consumer need to get all the logs in one central place to diagnose if something goes wrong. First of all we will create a simple table on our oracle database schema and next configure all other parts. Here we go: 1) CREATE TABLE LOGS (USER_ID VARCHAR2(20), DOMAIN varchar2(50), DATED DATE NOT NULL, LOGGER VARCHAR2(500) NOT...