Tuesday, 2 September 2014

Hi Guys ,

Today I would like to discuss on deployment feature of maven. In these days maven has cover vast area in the field of Software Development.

If any of you guys don't know the basic knowledge of Maven , I would like to recommend you guys the below link:

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Maven has some basic feature like properties, Application packaging , and Dependency Management.Apart from all these basic feature Maven uses some plugin which help to deploy your application into the target WebServer. Among all of them , I would like to come up with the weblogic deployment plugin.

So prerequisites are:
1) Oracle Weblogic Server 11g.
2) Maven 3.x

Basis architecture of Maven needed here is

<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>
  <groupId>com.ashish.wm</groupId>
  <artifactId>mthread</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>mthread.example Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<server.user.name>root</server.user.name>
<wl.home>C:/Oracle/Middleware/wlserver_10.3</wl.home>
<weblogic.server.userName>xxxx</weblogic.server.userName>
<weblogic.server.protocol>t3</weblogic.server.protocol>
<warfileName>mthread</warfileName>
<java-version>1.6</java-version>
<warfileName>mthread</warfileName>
                <weblogic.wlfullclient-version>10.3.3</weblogic.wlfullclient-version>
</properties>

<dependencies>
------------------
--------
---
<dependency>
<groupId>weblogic.wlfullclient</groupId>
<artifactId>wlfullclient</artifactId>
<version>${weblogic.wlfullclient-version}</version>
<scope>provided</scope>
</dependency>
---
-----------
--------------------
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
 <profiles>
<profile>
<id>wmThread</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profilename>wmThread</profilename>
<weblogic.server.password>xxxx</weblogic.server.password>
<server.ip.address>localhost</server.ip.address>
<weblogic.server.port>7001</weblogic.server.port>
<weblogic.server.target>AdminServer</weblogic.server.target>
</properties>
</profile>
  </profiles>
  <build>
    <finalName>mthread</finalName>
    <plugins>
           <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
      <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
    <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>WEB-INF/weblogic.xml</include>
<include>WEB-INF/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.3-SNAPSHOT</version>
<executions>
<execution>
<id>undeploy</id>
<phase>install</phase>
<goals>
<goal>undeploy</goal>
</goals>
<configuration>
<adminServerHostName>127.0.0.1</adminServerHostName>
<adminServerPort>7001</adminServerPort>
<adminServerProtocol>${weblogic.server.protocol}</adminServerProtocol>
<name>${warfileName}</name>
<userId>${weblogic.server.userName}</userId>
<password>${weblogic.server.password}</password>
<upload>true</upload>
<remote>true</remote>
<verbose>true</verbose>
<debug>true</debug>
<targetNames>${weblogic.server.target}</targetNames>
<continueOnFailure>true</continueOnFailure>
<noExit>true</noExit>
</configuration>
</execution>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<adminServerHostName>${server.ip.address}</adminServerHostName>
<adminServerPort>${weblogic.server.port}</adminServerPort>
<adminServerProtocol>${weblogic.server.protocol}
</adminServerProtocol>
<name>${warfileName}</name>
<userId>${weblogic.server.userName}</userId>
<password>${weblogic.server.password}</password>
<upload>true</upload>
<remote>true</remote>
<verbose>true</verbose>
<debug>true</debug>
<targetNames>${weblogic.server.target}</targetNames>
<noExit>true</noExit>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>10.3</version>
<scope>system</scope>
<systemPath>${wl.home}/server/lib/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>webservices</artifactId>
<version>10.3</version>
<scope>system</scope>
<systemPath>${wl.home}/server/lib/webservices.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>webserviceclient</artifactId>
<version>10.3</version>
<scope>system</scope>
<systemPath>${wl.home}/server/lib/webserviceclient.jar</systemPath>
</dependency>
</dependencies>
</plugin>
    </plugins>
  </build>
</project>

After creating the required pom , we need to set some properties for weblogic server for that we need to create the
1) weblogic.xml , file.

<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN"

    "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">

<weblogic-web-app>

<session-descriptor>
<session-param>
<param-name>CookiesEnabled</param-name>
<param-value>true</param-value>
</session-param>

<session-param>
<param-name>URLRewritingEnabled</param-name>
<param-value>true</param-value>
</session-param>

<session-param>
<param-name>InvalidationIntervalSecs</param-name>
<param-value>60</param-value>
</session-param>

<session-param>
<param-name>TrackingEnabled</param-name>
<param-value>true</param-value>
</session-param>

<session-param>
<param-name>PersistentStoreType</param-name>
<param-value>replicated_if_clustered</param-value>
</session-param>

<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>3600</param-value>
</session-param>

<session-param>
<param-name>CookieName</param-name>
<param-value>JSESSIONID_DOMINO</param-value>
</session-param>
</session-descriptor>

<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>UTF-8</java-charset-name>
</input-charset>
</charset-params>

<context-root>${warfileName}</context-root>
</weblogic-web-app>

to maintain the session at application level for your app.

Please give a feedback on this content . So that this will helpful for me to create next blog.