But it isn't so simple. In fact, it may be possible that you need to do some adaptations with specific deployments when you create a standard WAR or EAR file. One situation like that is the behavior of ClassLoader: Should it search classes first on web application classpath or application server classpath?
That and others issues had happened with me when I tried to deploy Apache Archiva 1.3 on Oracle WebLogic 11g R2 (10.3.2.0.0) with Oracle Database 11g. So, if it's useful for anybody, I followed these steps:
Create owner(s) on database
Create the owner(s) (user or schema, choose your option) on the Oracle Database (or any other RDBMS of your preference). You can create just one owner and create two datasources (we'll see that on next step) accessing the same one (I prefer that way). Or you may create two owners and create the datasources accessing theirs owners. On Oracle database, you need to give the grants of RESOURCE and CONNECT. See the following sample:
CREATE USER ARCHIVA IDENTIFIED BY ARCHIVA DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
-- ROLES
GRANT "CONNECT" TO ARCHIVA;
GRANT "RESOURCE" TO ARCHIVA;
-- SYSTEM PRIVILEGES
GRANT UNLIMITED TABLESPACE TO ARCHIVA;
Create two datasources on WebLogic connecting to database's owner(s)
Access WebLogic's console: http://<application_server_host>:<weblogic_http_port>/console
(like that: http://localhost:7001/console)
Click on: Services => JDBC => Data Sources
Create the first datasource with JNDI Name: jdbc/archiva (the name may be the same) and you fill in the rest of the fields. Test if the connection is rigth in the end. See the images:
The Name and JNDI Name:
Information about connection:
The connection test:
The target server of the datasource:
After that, you need to do the same with the other datasource, now with JNDI Name: jdbc/users.
Create a session Mail on WebLogic
On WebLogic's console, click on following option: Services => Mail Sessions
Create new mail session with JNDI Name: mail/Session. You have to fill in the information about server mail through Java properties of JavaMail API.
See the picture:
And select the server target for this new session mail:
Add weblogic.xml deployment on apache-archiva.war
To became visible the WebLogic session Mail to apache-archiva aplication, you have to add a weblogic.xml deployment into apache-archiva.war (inside WEB-INF folder). This file will map the session Mail resource with the aplication deployment. See a sample of this file:
<?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</res-ref-name>
<jndi-name>mail/Session</jndi-name>
</resource-description>
</weblogic-web-app>
Add weblogic-application.xml deployment and generate an EAR
After adding weblogic.xml deployment file to apache-archiva.war, you need to create an EAR file to add other deployment file which will report to WebLogic server the priority of load classpath. To do this task, create a folder META-INF and then create a weblogic-application.xml like that (thanks for Maxence Button on his blog: http://m-button.blogspot.com/2008/09/how-to-deploy-hudson-on-weblogic.html):
<?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>
<prefer-application-packages>
<package-name>org.springframework.*</package-name>
</prefer-application-packages>
</weblogic-application>
<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>
<prefer-application-packages>
<package-name>org.springframework.*</package-name>
</prefer-application-packages>
</weblogic-application>
It's better if you add the application.xml file together with weblogic-application.xml, see a sample:
<?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>Apache-Archiva</display-name>
<module>
<web>
<web-uri>apache-archiva.war</web-uri>
<context-root>/archiva</context-root>
</web>
</module>
</application>
<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>Apache-Archiva</display-name>
<module>
<web>
<web-uri>apache-archiva.war</web-uri>
<context-root>/archiva</context-root>
</web>
</module>
</application>
Then, compact META-INF folder (wich contains application.xml and weblogic-application.xml) and apache-archiva.war to create apache-archiva.ear.
Deploy the Apache Archiva on WebLogic
Ok, now you are ready to deploy Apache Archiva. So, access the WebLogic's console and deploy the apache-archvia.ear file like an application.
After that, you can access the Apache Archiva on the followed URL:
http://localhost:7001/archiva
Last step, create objtable on Oracle
Sorry, but if you are using Oracle Database you need one more step. When you logon with admin user on Apache Archiva, and when you click on Reports option, you see this error:
2010-03-15 14:49:52,166 [[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR JPOX.RDBMS - Error t
hrown executing CREATE TABLE ARCHIVA_REPOSITORY_PROBLEMS
(
ARCHIVA_REPOSITORY_PROBLEMS_ID NUMBER NOT NULL,
ARTIFACT_ID VARCHAR2(80) NULL,
GROUP_ID VARCHAR2(250) NULL,
MESSAGE VARCHAR2(4096) NOT NULL,
PROBLEM_ORIGIN VARCHAR2(20) NOT NULL,
REPO_PATH VARCHAR2(250) NOT NULL,
REPOSITORY_ID VARCHAR2(50) NOT NULL,
PROBLEM_TYPE VARCHAR2(50) NOT NULL,
VERSION VARCHAR2(50) NULL
) : ORA-00910: specified length too long for its datatype
java.sql.
hrown executing CREATE TABLE ARCHIVA_REPOSITORY_PROBLEMS
(
ARCHIVA_REPOSITORY_PROBLEMS_ID NUMBER NOT NULL,
ARTIFACT_ID VARCHAR2(80) NULL,
GROUP_ID VARCHAR2(250) NULL,
MESSAGE VARCHAR2(4096) NOT NULL,
PROBLEM_ORIGIN VARCHAR2(20) NOT NULL,
REPO_PATH VARCHAR2(250) NOT NULL,
REPOSITORY_ID VARCHAR2(50) NOT NULL,
PROBLEM_TYPE VARCHAR2(50) NOT NULL,
VERSION VARCHAR2(50) NULL
) : ORA-00910: specified length too long for its datatype
java.sql.
at oracle.jdbc.driver.
at oracle.jdbc.driver.
...
It happens because the application Apache Archiva tries to create a table with a column of type VARCHAR2 with lenght 4096. But the limit of VARCHAR2 type on Oracle Database it is 4000.
So, you need to change manually the file that specifies the structure of tables on database. There are 3 columns in this file that will fail when creating tables on Oracle database.
The file package.jdo contains the structure of database objects is inside of archiva-model-1.3.jar (you can find it inside the apache-archiva.war file, on folder WEB-INF/lib). See the complete path:
apache-archiva.war!/WEB-INF/lib/archiva-model-1.3.jar!/org/apache/maven/archiva/model/package.jdo
Then, edit the orignal file package.jdo in that following points:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC
"-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
"http://java.sun.com/dtd/jdo_2_0.dtd">
<jdo>
<package name="org.apache.maven.archiva.model">
...
<class name="ArchivaProjectModel" detachable="true" table="ARCHIVA_PROJECT" identity-type="application" objectid-class="org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey">
...
<field name="description">
<column length="8192"/>
</field>
...
</class>
...
<class name="License" detachable="true" table="ARCHIVA_LICENSES" identity-type="application" objectid-class="javax.jdo.identity.IntIdentity">
...
<field name="comments">
<column length="8192"/>
</field>
</class>
...
<class name="RepositoryProblem" detachable="true" table="ARCHIVA_REPOSITORY_PROBLEMS">
...
<field name="message" null-value="exception">
<column length="4096"/>
</field>
</class>
...
</package>
</jdo>
Change to be like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC
"-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
"http://java.sun.com/dtd/jdo_2_0.dtd">
<jdo>
<package name="org.apache.maven.archiva.model">
...
<class name="ArchivaProjectModel" detachable="true" table="ARCHIVA_PROJECT" identity-type="application" objectid-class="org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey">
...
<field name="description">
<column jdbc-type="CLOB"/>
</field>
...
</class>
...
<class name="License" detachable="true" table="ARCHIVA_LICENSES" identity-type="application" objectid-class="javax.jdo.identity.IntIdentity">
...
<field name="comments">
<column jdbc-type="CLOB"/>
</field>
</class>
...
<class name="RepositoryProblem" detachable="true" table="ARCHIVA_REPOSITORY_PROBLEMS">
...
<field name="message" null-value="exception">
<column length="4000"/>
</field>
</class>
...
</package>
</jdo>
Next, alter the file archiva-model-1.3.jar with the new version of package.jdo. Alter the file apache-archiva.war with the new version of archiva-model-1.3.jar.
After all that, I hope the tips written here have been useful for someone.