Tag: ANT

Creating a JAXWS ComplexType WebService Using Top to Bottom Approach

Hi,

Jay SenSharma

Jay SenSharma

Based on the query of one of Our Magic Subscriber “Mauricio” we are going to see how we can create a JAXWS WebService using Contract First (from WSDL) mechanism.  So basically in Top to Bottom approach (Contract First Approach). We already have an existing WSDL and based on that we want to create a WebService.  WebLogic provides a best utility to achieve the same. The utility is called as  “weblogic.wsee.tools.anttasks.WsdlcTask” using this utility we can create any kind of WebService from a WSDL just by specifying type=”JAXWS”  or  type=”JAXRPC” as an attribute to the above ANT task.

Suppose we already have a contract (WSDL) like following  “ComplexImpl.wsdl” which internally can contain some Complex Data Types as well… The Following WSDL contains a Complex Datatype as “BasicStruct

==============>

Step1). Create a directory somewhere in your file system like :   “/demos/TopDown” and then place the above WSDL inside this directory.

<?xml version="1.0" encoding="UTF-8"?>
<s0:definitions name="ComplexServiceDefinitions" targetNamespace="http://example.org" xmlns="" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/">
  <s0:types>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://example.org" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="java:examples.webservices.complex"/>
      <xs:element name="echoComplexType">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="struct" type="java:BasicStruct" xmlns:java="java:examples.webservices.complex"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoComplexTypeResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="EchoStructReturnMessage" type="java:BasicStruct" xmlns:java="java:examples.webservices.complex"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoInt">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="IntegerInput" type="xs:int"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoIntResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="IntegerOutput" type="xs:int"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:examples.webservices.complex" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="BasicStruct">
        <xs:sequence>
          <xs:element minOccurs="1" name="IntValue" nillable="false" type="xs:int"/>
          <xs:element minOccurs="1" name="StringValue" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="StringArray" nillable="true" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </s0:types>
  <s0:message name="echoComplexType">
    <s0:part element="s1:echoComplexType" name="parameters"/>
  </s0:message>
  <s0:message name="echoComplexTypeResponse">
    <s0:part element="s1:echoComplexTypeResponse" name="parameters"/>
  </s0:message>
  <s0:message name="echoInt">
    <s0:part element="s1:echoInt" name="parameters"/>
  </s0:message>
  <s0:message name="echoIntResponse">
    <s0:part element="s1:echoIntResponse" name="parameters"/>
  </s0:message>
  <s0:portType name="ComplexPortType">
    <s0:operation name="echoComplexType" parameterOrder="parameters">
      <s0:input message="s1:echoComplexType"/>
      <s0:output message="s1:echoComplexTypeResponse"/>
    </s0:operation>
    <s0:operation name="echoInt" parameterOrder="parameters">
      <s0:input message="s1:echoInt"/>
      <s0:output message="s1:echoIntResponse"/>
    </s0:operation>
  </s0:portType>
  <s0:binding name="ComplexServiceSoapBinding" type="s1:ComplexPortType">
    <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <s0:operation name="echoComplexType">
      <s2:operation style="document"/>
      <s0:input>
        <s2:body parts="parameters" use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal"/>
      </s0:output>
    </s0:operation>
    <s0:operation name="echoInt">
      <s2:operation style="document"/>
      <s0:input>
        <s2:body parts="parameters" use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal"/>
      </s0:output>
    </s0:operation>
  </s0:binding>
  <s0:service name="ComplexService">
    <s0:port binding="s1:ComplexServiceSoapBinding" name="ComplexPortTypeSoapPort">
      <s2:address location="http://localhost:7001/ComplexImpl/ComplexImpl"/>
    </s0:port>
  </s0:service>
</s0:definitions>

Step2). Now write the following kind of ANT build script to use the WSDLC utility to create a dummy WebService with default implementation of Service Operations (Methods)

build.xml

<project name="GenerateWS" default="all">
<property name="build" value="output" />
<property name="adminurl" value="t3://localhost:7001" />
<property name="serverName" value="AdminServer" />
<property name="userName" value="weblogic" />
<property name="password" value="weblogic" />
<property name="ear.name" value="Complex_JAXWS_Ear" />

<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask"/>
<target name="all" depends="generate-from-wsdl,wait"/>

<target name="generate-from-wsdl">
     <wsdlc srcWsdl="ComplexImpl.wsdl"
            destJwsDir="jarJws"
            destImplDir="." type="JAXWS"
            packageName="ws"/>
</target>

<target name="wait">
    <echo message=" Now you need to provide your own Implementation for sayHello() of [[[ ws/ComplexService_ComplexPortTypeSoapPortImpl.java ]]]" />
    <echo message=" then you need to run 'ant deploy' to rebuild your edited Service and to Deploy it on the Server..." />
</target>

<target name="build-service">
     <mkdir dir="${build}/${ear.name}" />
     <jwsc srcdir="." destdir="${build}/${ear.name}">
          <jws file="ws/ComplexService_ComplexPortTypeSoapPortImpl.java" compiledWsdl="jarJws/ComplexImpl_wsdl.jar" type="JAXWS"/>
     </jwsc>
</target>

<target name="deploy" depends="build-service">
     <wldeploy action="deploy"
               source="${build}/${ear.name}" user="${userName}"
               password="${password}" verbose="true"
               failonerror="yes"
               adminurl="${adminurl}"
               targets="${serverName}" />
</target>

<target name="redeploy">
     <wldeploy action="redeploy"
               source="${build}/${ear.name}" user="${userName}"
               password="${password}" verbose="true"
               failonerror="yes"
               adminurl="${adminurl}"
               targets="${serverName}" />
</target>
</project>

Step3). Now  Open a command prompt then run the “. ./setWLSEnv.sh”  to set the CLASSPATH and PATH properly.

Run the “setWLSEnv.sh” by adding two DOTs separated by a single space …..before the actual script like following : (use ‘cd’ command to move inside the <BEA_HOME>/wlserver_10.3/server/bin) then run the following command….
.  ./setWLSEnv.sh

Note: the first DOT represents that set the Environment in the current Shell, AND the second ./ represents execute the script from the current directory.

Step4). Now as soon as you will run the  command like “ant -buildfile build.xml  generate-from-wsdl”  it will generate all the artifacts for your WebService and a Dummy WebService implementation.

ant -buildfile build.xml
Buildfile: build.xml

generate-from-wsdl:
    [wsdlc] Download file [ComplexImpl.wsdl] to /tmp/_ckr59b
    [wsdlc] srcWsdl is redefined as [ /tmp/_ckr59b/ComplexImpl.wsdl ]
    [wsdlc] Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation
    [wsdlc] parsing WSDL...

    [wsdlc] [WARNING] src-resolve: Cannot resolve the name 'java:BasicStruct' to a(n) 'type definition' component.
    [wsdlc]   line 9 of file:/tmp/_ckr59b/ComplexImpl.wsdl#types?schema1

    [wsdlc] generating code...

    [wsdlc] compiling code...

    [wsdlc] Note: /demos/TopDown/jarJws/generated/ws/ComplexService.java uses unchecked or unsafe operations.
    [wsdlc] Note: Recompile with -Xlint:unchecked for details.
[AntUtil.deleteDir] Deleting directory /tmp/_ckr59b

wait:
     [echo]  Now you need to provide your own Implementation for sayHello() of [[[ ws/ComplexService_ComplexPortTypeSoapPortImpl.java ]]]
     [echo]  then you need to run 'ant deploy' to rebuild your edited Service and to Deploy it on the Server...

all:

BUILD SUCCESSFUL
Total time: 3 seconds

Step5). Inside “/demos/TopDown/ws” you will find a WebService implementation class is generated with some name like “ComplexPortTypeSoapPortImpl.java” this is actually our WebService like following:

NOTE: A JAR also will be generated inside “/demos/TopDown/jarJws/ComplexImpl_wsdl.jar” this JAR will basically contain all the required classes and the Complex Datatypes which is going to be used by the WebService.


package ws;

import javax.jws.WebService;
import javax.xml.ws.BindingType;

/**
 * This class was generated by the JAX-WS RI.
 * Oracle JAX-WS 2.1.3-06/19/2008 07:03 PM(bt)
 * Generated source version: 2.1
 *
 */
@WebService(portName = "ComplexPortTypeSoapPort", serviceName = "ComplexService", targetNamespace = "http://example.org", wsdlLocation = "/wsdls/ComplexImpl.wsdl", endpointInterface = "ws.ComplexPortType")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class ComplexService_ComplexPortTypeSoapPortImpl
    implements ComplexPortType
{

    public ComplexService_ComplexPortTypeSoapPortImpl() {
    }

    /**
     *
     * @param struct
     * @return
     *     returns ws.BasicStruct
     */
    public BasicStruct echoComplexType(BasicStruct struct) {
        //replace with your impl here
        return null;
    }

    /**
     *
     * @param integerInput
     * @return
     *     returns int
     */
    public int echoInt(int integerInput) {
        //replace with your impl here
        return 0;
    }

}

Step6).Now We need to just add our Business implementation according to our requirement inside the methods present inside the WebService “ComplexPortTypeSoapPortImpl.java”  like following:

package ws;
import javax.jws.WebService;
import javax.xml.ws.BindingType;

/**
 * This class was generated by the JAX-WS RI.
 * Oracle JAX-WS 2.1.3-06/19/2008 07:03 PM(bt)
 * Generated source version: 2.1
 *
 */
@WebService(portName = "ComplexPortTypeSoapPort", serviceName = "ComplexService", targetNamespace = "http://example.org", wsdlLocation = "/wsdls/ComplexImpl.wsdl", endpointInterface = "ws.ComplexPortType")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class ComplexService_ComplexPortTypeSoapPortImpl
    implements ComplexPortType
{

    public ComplexService_ComplexPortTypeSoapPortImpl() {
          System.out.println("nt ComplexPortTypeSoapPortImpl  Instentiated...");
    }

    /**
     *
     * @param struct
     * @return
     *     returns ws.BasicStruct
     */
    public BasicStruct echoComplexType(BasicStruct struct) {
        //replace with your impl here
          System.out.println("nt ComplexPortTypeSoapPortImpl  echoComplexType method called...Got struct  = "+struct);
        return struct;
    }

    /**
     *
     * @param integerInput
     * @return
     *     returns int
     */
    public int echoInt(int integerInput) {
          System.out.println("nt ComplexPortTypeSoapPortImpl  echoInt method called...Got integerInput  = "+integerInput);
        return integerInput;
    }

}

Step7). Now just run the ANT build again to build and deploy the WebService as following “ant -buildfile build.xml  deploy

ant deploy
Buildfile: build.xml

build-service:
    [mkdir] Created dir: /demos/TopDown/output/Complex_JAXWS_Ear
     [jwsc] JWS: processing module /ws/ComplexService_ComplexPortTypeSoapPortImpl
     [jwsc] Parsing source files
     [jwsc] Parsing source files
     [jwsc] 1 JWS files being processed for module /ws/ComplexService_ComplexPortTypeSoapPortImpl
     [jwsc] JWS: /demos/TopDown/ws/ComplexService_ComplexPortTypeSoapPortImpl.java Validated.
     [jwsc] Processing 1 JAX-WS web services...
     [jwsc] Compiling 1 source file to /tmp/_4ixn4v
     [jwsc] Building jar: /demos/TopDown/output/Complex_JAXWS_Ear/ws/ComplexService_ComplexPortTypeSoapPortImpl.war
     [jwsc] Created JWS deployment outputFile: /demos/TopDown/output/Complex_JAXWS_Ear/ws/ComplexService_ComplexPortTypeSoapPortImpl.war
     [jwsc] [EarFile] Application File : /demos/TopDown/output/Complex_JAXWS_Ear/META-INF/application.xml
[AntUtil.deleteDir] Deleting directory /tmp/_4ixn4v

deploy:
 [wldeploy] weblogic.Deployer -verbose -noexit -source /demos/TopDown/output/Complex_JAXWS_Ear -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -password ******** -deploy
 [wldeploy] weblogic.Deployer invoked with options:  -verbose -noexit -source /demos/TopDown/output/Complex_JAXWS_Ear -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -deploy
 [wldeploy] <May 4, 2011 3:55:10 PM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, Complex_JAXWS_Ear [archive: /demos/TopDown/output/Complex_JAXWS_Ear], to AdminServer .>
 [wldeploy] Task 0 initiated: [Deployer:149026]deploy application Complex_JAXWS_Ear on AdminServer.
 [wldeploy] Task 0 completed: [Deployer:149026]deploy application Complex_JAXWS_Ear on AdminServer.
 [wldeploy] Target state: deploy completed on Server AdminServer

 [wldeploy] Target Assignments:
 [wldeploy] + Complex_JAXWS_Ear  AdminServer

BUILD SUCCESSFUL
Total time: 5 seconds

Step8). Once the Service is deployed you can login to AdminConsole and then you can test it.

TestingWebService_FromConsol

.

.

Thanks

Jay SenSharma


Changing the context-param values of web.xml using plan.xml

Ravish Mody

Here we are going to see how we can change the “<context-param>”  child tag values using plan.xml file. Many times we see that the values are not getting changed or reflected by plan.xml file updates even if every step looks correct.

NOTE: The plan.xml feature works on Xpath and which is applicable on the XSD based xml files. So it would not work for DTD based web.xml file.  So make sure that you use the weblogic.DDConverter utility to convert the web.xml to use the latest XSD based deployment descriptors. To get more information on it do have a look at this post How to use the weblogic.DDConverter tool ?

Steps To change the context-param values of web.xml using plan.xml

Step1).  Create a web application  in some location like: (C:/DemoPlan/SampleWebApp)

Step2).  Now create a “web.xml” file like following inside “C:/DemoPlan/SampleWebApp/WEB-INF” directory:

<!---------------- DO NOT use the DTDs inside your XML file if you want to use plan.xml------------------
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <context-param id="one">
        <param-name>TokenGroup</param-name>
        <param-value>oldvalue</param-value>
    </context-param>
</web-app>
-----------------------Please ignore the above web.xml content -------------------------------------------->

<?xml version='1.0' encoding='WINDOWS-1252'?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <context-param id="one">
    <param-name>TokenGroup</param-name>
    <param-value>oldvalue</param-value>
  </context-param>
</web-app>

Step3).  Now we need to create a “index.jsp” inside “C:/DemoPlan/SampleWebApp” like following to read the context-param values defined inside the “web.xml” file.

<html>
<head><title>Hi</title><head>
<body bgcolor=maroon text=white>

<%
     String param = application.getInitParameter("TokenGroup");
     out.println("<h3>TokenGroup : "+param);
     System.out.println("ntTokenGroup : "+param);
%>

</body>
</html>

Step4).  Now write the following kind of “plan.xml” file inside any directory like “C:/DemoPlan/”
NOTE: you need to make sure that the  <config-root>Should contain a valid directory path which contains the plan.xml file.</config-root>

<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://www.bea.com/ns/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
  <application-name>SimpleWebApp</application-name>

  <variable-definition>
      <variable>
          <name>newVariable</name>
          <value>Key123456</value>
      </variable>
  </variable-definition>

  <module-override>
    <module-name>SimpleWebApp</module-name>
    <module-type>war</module-type>

    <module-descriptor external="false">
      <root-element>web-app</root-element>
      <uri>WEB-INF/web.xml</uri>
      <variable-assignment>
         <name>newVariable</name>
         <xpath>/web-app/context-param/[param-name="TokenGroup"]/param-value</xpath>
         <operation>add</operation>
      </variable-assignment>
    </module-descriptor>

  </module-override>
  <config-root>C:/DemoPlan/</config-root>
</deployment-plan>

Step5). Now just to simplify the deployment and un-deployment task we can write the build.xml file  to make the things automated.

<project name="webservices-hello_world" default="deploy">
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="10.10.10.10" />
<property name="wls.port" value="7001" />
<property name="admin.server.name" value="AdminServer" />
<property name="deploy.target" value="AdminServer" />

<property name="deploy.name" value="SimpleWebApp" />
<property name="deploy.source" value="SimpleWebApp" />
<property name="plan.xml.path" value="C:/DemoPlan//plan.xml" />

<!-- Setting TaskDefinition -->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="C:/bea103/wlserver_10.3/server/lib/weblogic.jar"/>
</classpath>
</taskdef>

<!-- Deploying Applications  -->
<target name="deploy">
<wldeploy action="deploy"
          name="${deploy.name}"
          source="${deploy.source}"
          user="${wls.username}"
          nostage="true"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<target name="redeployWithPlan">
<wldeploy action="redeploy"
          name="${deploy.name}"
          plan="${plan.xml.path}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Redeploying Applications  -->
<target name="redeploy">
<wldeploy action="redeploy"
          name="${deploy.name}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Uneploying Applications  -->
<target name="undeploy">
<wldeploy action="undeploy"
          name="${deploy.name}"
          failonerror="false"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>
</project>

Step6). Now deploy your application after running the setWLSEnv.cmd in the command prompt like following:

ant deploy

Step7). Now access the application like http://hostName:port/SampleWebApp/index.jsp   you will notice that the  page displays the value of TokenGroup as “oldvalue” which is defined in the web.xml .

Step8). Now again redeploy your application using the plan.xml file  which is specified in the  “build.xml” file as following:

ant redeployWithPlan

Step9).  Now as soon as you will hit your application “http://hostName:port/SampleWebApp/index.jsp” you will see that the page displays the value of TokenGroup as “Key123456

Thanks
Ravish Mody

Comments Off on Changing the context-param values of web.xml using plan.xml more...

Deploy Multiple Applications Remotely Using ANT

Ravish Mody

Today, one of our subscriber Kiran using comment asked us that how can he deploy more then one application remotely that to using ANT script. Thus we create this script which would do the same job very easily.

The logic behind this script is the that, we have used upload and depends. To cut the story sort the value of default which is on the line-1 is given as deploy3 and the target name for deploy2 has dependency on the deployment of application-1 same way the target name for deploy3 has dependency on the deployment of application-2. Thus till the application-1 is not deployed other applications would not deploy, this way all the application are been deployed one by one.

Steps To Create An ANT Script to Deploy Multiple Applications Remotely:

Step1) Create a “build.xml” file with the following details in it (i.e just copy the below snip-code).

<project name="webservices-hello_world" default="deploy3">
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="10.10.10.10" />
<property name="wls.port" value="7001" />
<property name="admin.server.name" value="AdminServer" />

<!-- Deploying Target -->
<property name="deploy.target" value="AdminServer" />

<!-- Details for Application-1 -->
<property name="deploy.name.1" value="TestApp1" />
<property name="deploy.source.1" value="TestApp1.war" />

<!-- Details for Application-2 -->
<property name="deploy.name.2" value="TestApp2" />
<property name="deploy.source.2" value="TestApp2.war" />

<!-- Details for Application-3 -->
<property name="deploy.name.3" value="TestApp3" />
<property name="deploy.source.3" value="TestApp3.war" />

<!-- Setting TaskDefinition -->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="C:/bea103/wlserver_10.3/server/lib/weblogic.jar"/>
</classpath>
</taskdef>

<!-- Deploying Applications  -->
<target name="deploy1">
<wldeploy action="deploy"
	  upload="true"
          name="${deploy.name.1}"
          source="${deploy.source.1}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Deploying Applications-2 DEPENDS on Deployment of Applications-1 -->

<target name="deploy2" depends="deploy1">
<wldeploy action="deploy"
	  upload="true"
          name="${deploy.name.2}"
          source="${deploy.source.2}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Deploying Applications-3 DEPENDS on Deployment of Applications-2 -->

<target name="deploy3" depends="deploy2">
<wldeploy action="deploy"
	  upload="true"
          name="${deploy.name.3}"
          source="${deploy.source.3}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>
</project>

Step2) Open a prompt and then run (setWLSenv.cmd/sh  or setDomainEnv.sh/cmd)

Step3) To deploy the applications move to the current directory where ever you have placed both “build.xml” and all the application “TestApp1.war” ,“TestApp2.war” and “TestApp3.war” and then run the following command.

ant

Step4) The output would be like follows

ant
Buildfile: build.xml

deploy1:
 [wldeploy] weblogic.Deployer -verbose -upload -noexit -name TestApp1 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp1.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -password ******** -deploy
 [wldeploy] weblogic.Deployer invoked with options:  -verbose -upload -noexit -name TestApp1 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp1.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -deploy
 [wldeploy] <Feb 11, 2011 6:12:53 PM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, TestApp1 [archive: /home/rmody/JBoss_Data/Samples/WLS/TestApp1.war], to AdminServer .>
 [wldeploy] Task 0 initiated: [Deployer:149026]deploy application TestApp1 on AdminServer.
 [wldeploy] Task 0 completed: [Deployer:149026]deploy application TestApp1 on AdminServer.
 [wldeploy] Target state: deploy completed on Server AdminServer

 [wldeploy] Target Assignments:
 [wldeploy] + TestApp1  AdminServer

deploy2:
 [wldeploy] weblogic.Deployer -verbose -upload -noexit -name TestApp2 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp2.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -password ******** -deploy
 [wldeploy] weblogic.Deployer invoked with options:  -verbose -upload -noexit -name TestApp2 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp2.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -deploy
 [wldeploy] <Feb 11, 2011 6:12:54 PM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, TestApp2 [archive: /home/rmody/JBoss_Data/Samples/WLS/TestApp2.war], to AdminServer .>
 [wldeploy] Task 1 initiated: [Deployer:149026]deploy application TestApp2 on AdminServer.
 [wldeploy] Task 1 completed: [Deployer:149026]deploy application TestApp2 on AdminServer.
 [wldeploy] Target state: deploy completed on Server AdminServer

 [wldeploy] Target Assignments:
 [wldeploy] + TestApp2  AdminServer

deploy3:
 [wldeploy] weblogic.Deployer -verbose -upload -noexit -name TestApp3 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp3.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -password ******** -deploy
 [wldeploy] weblogic.Deployer invoked with options:  -verbose -upload -noexit -name TestApp3 -source /home/rmody/JBoss_Data/Samples/WLS/TestApp3.war -targets AdminServer -adminurl t3://10.10.10.10:7001 -user weblogic -deploy
 [wldeploy] <Feb 11, 2011 6:12:56 PM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, TestApp3 [archive: /home/rmody/JBoss_Data/Samples/WLS/TestApp3.war], to AdminServer .>
 [wldeploy] Task 2 initiated: [Deployer:149026]deploy application TestApp3 on AdminServer.
 [wldeploy] Task 2 completed: [Deployer:149026]deploy application TestApp3 on AdminServer.
 [wldeploy] Target state: deploy completed on Server AdminServer

 [wldeploy] Target Assignments:
 [wldeploy] + TestApp3  AdminServer

BUILD SUCCESSFUL
Total time: 5 seconds

That it, now if you check in your remote box under the server on which you have deployed the applications it would have the following directory structure and then check you console under deployments you would notice that all the applications are been deployed.

Path:

Application-1

<BEA_HOME>user_projects/domains/<YOUR_DOMAIN>/servers/AdminServer/upload/TestApp1/app/TestApp1.war

Application-2

<BEA_HOME>user_projects/domains/<YOUR_DOMAIN>/servers/AdminServer/upload/TestApp2/app/TestApp2.war

Application-3

<BEA_HOME>user_projects/domains/<YOUR_DOMAIN>/servers/AdminServer/upload/TestApp3/app/TestApp3.war

========================================

Issues:

Suppose if you get following kind of error while deploying from a remote machine:
Caused by: javax.naming.NamingException: Couldn’t connect to any host [Root exception is org.omg.CORBA.OBJECT_NOT_EXIST: Unknown object in LOCATE_REQUEST vmcid: 0x0 minor code: 0

[wldeploy] Caused by: weblogic.deploy.api.spi.exceptions.ServerConnectionException: [J2EE Deployment SPI:260010]Unable to connect to 't3://he3unxd189v01:9100' as user, 'weblogic'. Error received: Couldn't connect to any host
[wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getMBeanServer(ServerConnectionImpl.java:251)
[wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getMBeanServerForType(ServerConnectionImpl.java:191)
[wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.init(ServerConnectionImpl.java:147)
[wldeploy] at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.getNewConnection(WebLogicDeploymentManagerImpl.java:148)
[wldeploy] at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.<init>(WebLogicDeploymentManagerImpl.java:118)
[wldeploy] ... 32 more
[wldeploy] Caused by: java.io.IOException: Couldn't connect to any host
[wldeploy] at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProviderBase.java:156)
[wldeploy] at weblogic.management.remote.common.ClientProviderBase.newJMXConnector(ClientProviderBase.java:79)
[wldeploy] at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:338)
[wldeploy] at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
[wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getMBeanServer(ServerConnectionImpl.java:240)
[wldeploy] ... 36 more
[wldeploy] Caused by: javax.naming.NamingException: Couldn't connect to any host [Root exception is org.omg.CORBA.OBJECT_NOT_EXIST: Unknown object in LOCATE_REQUEST vmcid: 0x0 minor code: 0 completed: No]
[wldeploy] Caused by: javax.naming.NamingException: Couldn't connect to any host [Root exception is org.omg.CORBA.OBJECT_NOT_EXIST: Unknown object in LOCATE_REQUEST vmcid: 0x0 minor code: 0 completed: No]
[wldeploy] at weblogic.corba.j2ee.naming.Utils.wrapNamingException(Utils.java:83)
[wldeploy] at weblogic.corba.j2ee.naming.ORBHelper.getORBReferenceWithRetry(ORBHelper.java:590)
[wldeploy] at weblogic.corba.j2ee.naming.ORBHelper.getORBReference(ORBHelper.java:547)
[wldeploy] at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:85)
[wldeploy] at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:31)
[wldeploy] at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
[wldeploy] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
[wldeploy] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
[wldeploy] at javax.naming.InitialContext.init(InitialContext.java:223)
[wldeploy] at javax.naming.InitialContext.<init>(InitialContext.java:197)
[wldeploy] at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProviderBase.java:143)
[wldeploy] ... 40 more
[wldeploy] Caused by: org.omg.CORBA.OBJECT_NOT_EXIST: Unknown object in LOCATE_REQUEST vmcid: 0x0 minor code: 0 completed: No
[wldeploy] at weblogic.iiop.LocateReplyMessage.needsForwarding(LocateReplyMessage.java:171)
[wldeploy] at weblogic.iiop.IORManager.locateInitialReference(IORManager.java:254)
[wldeploy] at weblogic.corba.orb.ORB.resolve_initial_references(ORB.java:258)
[wldeploy] at weblogic.corba.client.naming.ClientORBInfo.<init>(ClientORBInfo.java:34)
[wldeploy] at weblogic.corba.client.naming.ClientORBHelper.createORBInfo(ClientORBHelper.java:42)
[wldeploy] at weblogic.corba.j2ee.naming.ORBHelper.cacheORB(ORBHelper.java:314)
[wldeploy] at weblogic.corba.j2ee.naming.ORBHelper.cacheORBAndCreateURL(ORBHelper.java:323)
[wldeploy] at weblogic.corba.j2ee.naming.ORBHelper.getORBReferenceWithRetry(ORBHelper.java:583)

Then please make sure to add “wlfullclient.jar” at the beginning of the CLASSPATH in your ANT Script…Also please refer to http://forums.oracle.com/forums/thread.jspa?threadID=2188580&tstart=0

And to khow to make wlfullclient.jar in weblogic please refer to: http://middlewaremagic.com/weblogic/?p=558


Copyright © 2010-2012 Middleware Magic. All rights reserved. |