Skip to main content

Websphere server autodeploy using Maven plugin

After a long googling, I didn't find how to do auto deploy for webshpere application using maven. Finally I have done successfully.

Here is the pom.xml:


<?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>
        <artifactId>testwasEar</artifactId>
        <groupId>com.mycompany</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.mycompany</groupId>
    <artifactId>testwasEar-ear</artifactId>
    <packaging>ear</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>testwasEar-ear JEE5 Assembly</name>
    <url>http://maven.apache.org</url>
    <properties>
        <was6Home>C:\IBM\WebSphere\AppServer1</was6Home>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <version>5</version>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>was6-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsDefaultBindings</goal>
                            <goal>wsListApps</goal>
                            <goal>installApp</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wasHome>${was6Home}</wasHome>
                    <conntype>SOAP</conntype>
                    <host>localhost</host>
                    <port>8880</port>
                    <profileName>AppSrv02</profileName>
                    <verbose>true</verbose>
                    <user>admin</user>
                    <password>admin</password>
                    <username>admin</username>
                    <earFile>target\testwasEar-ear.ear</earFile>
                    <updateExisting>false</updateExisting> <!-- this needs to be false as we're reinstalling each time -->
                    <applicationName>MobileWeb</applicationName>
                </configuration>
            </plugin>
        </plugins>
        <finalName>testwasEar-ear</finalName>
    </build>
    <dependencies>
        <!--dependency>
            <groupId>com.mycompany</groupId>
            <artifactId>testwas-web</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>war</type>
        </dependency -->
        <dependency>
            <groupId>com.mycompany.testweb</groupId>
            <artifactId>TestWeb</artifactId>
            <version>trunk-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>
</project>

Run maven goals like below:

mvn clean install was6:wsDefaultBindings was6:wsUninstallApp was6:installApp was6:wsStartApp
clean --> clean the project
install --> build the project
was6:wsDefaultBindings  --> before install app this must to call, will create default files      and bindings for WAS
was6:wsUninstallApp --> If we need to install a fresh application, call this before install the application
was6:installApp --> this will install application 
was6:wsStartApp --> installApp will only do installation and not start the application. After successfully installed we need to call this.

Note:
We can't deploy only WAR, need to have EAR.

Comments

  1. hi , have you tried deploying ear to WAS ND from a remote machine - say build server? I am having hard time in deploying the ear to remote server where i need to mention cluster name and server name in the configuration.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

Running and debugging jetty maven plugin in Netbeans

Coding with Netbeans will make developer life simple. We don't need search for plugins and install different plugins from different places. Maven projects can opened as directly in Netbeans without any settings. Here is the way to run & debug using maven jetty plugin. We can't add Jetty server as servers in Netbeans. Run project: Right click on project and open the properties. click on "Actions" on left side. On right side there will be list of available actions.  To run jetty can be created a new action or override default "Run Project" Here I am overriding default one, Because I can run the project just by hitting "F6" key click on "Run Project" Enter the value "Execute Goals" as "jetty:run", If you want run as offline add "jetty:run -o" "Active Profiles" can be empty In "set Properties" field we can set like skip test. Here I am skipping test. Done, After setting y...

unlock the static files while jetty is running on windows.

When running a java maven web application  in jetty on windows. All static files are locked and not able edit and save those files while jetty is running. This will eat developers time beacuse each and every change in javascript & css files, jetty have to re-started. Depends on application's dependencies that build will take more than 5minutes. Why jetty is locking the static files? Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file Jetty provides a configuration switch in the  webdefault.xml  file for the  DefaultServlet  which enables or disables the use of memory mapped files. If you are running on Windows and are having file locking p...

Secure Coding Guidelines for the Java Programming Language

http://www.oracle.com/technetwork/java/seccodeguide-139067.html Secure Coding Guidelines for the Java Programming Language, Version 3.0 Introduction 0 Fundamentals Guideline 0-1 Prefer to have obviously no flaws than no obvious flaws Guideline 0-2 Design APIs to avoid security concerns Guideline 0-3 Avoid duplication Guideline 0-4 Restrict privileges Guideline 0-5 Establish trust boundaries Guideline 0-6 Contain sensitive data Guideline 0-7 Particular data format and API issues Guideline 0-7a Avoid dynamic SQL Guideline 0-7b XML and HTML generation requires care Guideline 0-7c Restrict XML inclusion Guideline 0-7d Take care interpreting untrusted code 1 Accessibility and Extensibility Guideline 1-1 Limit the accessibility of classes,interfaces, methods, and fields Guideline 1-1a Limit the accessibility of packages Guideline 1-1b Isolate unrelated code Guideline 1-2 Limit the extensibility of classes and methods Guideline 1-3 Understand how a su...