ode-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Pereira <ricardo.sele...@gmail.com>
Subject Re: Process Deployment with DeploymentService (cont)
Date Wed, 05 Aug 2009 14:58:17 GMT
Thank you for your fast reply. I did what you said and it worked.

Now i'm using a simply 2 java classes:
1st that is the DeploymentConnection which includes the deploy function
(this class was proposed in a post by Alex Boisvert here:
http://www.mail-archive.com/user@ode.apache.org/msg02744.html)

2nd that is just a class which invokes the DeploymentConnection and specify
the location fo the zip file and the DeploymentService link. I think that
everything is correct but it returns this:

Exception in thread "main" java.lang.NullPointerException
        at
org.apache.axis2.description.ClientUtils.inferInTransport(ClientUtils.java:85)
        at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:163)
        at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579)
        at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
        at
org.apache.ode.axis2.service.ServiceClientUtil.send(ServiceClientUtil.java:69)
        at
org.apache.ode.axis2.service.ServiceClientUtil.send(ServiceClientUtil.java:48)
        at
org.apache.ode.axis2.management.DeploymentConnection.sendToDeployment(DeploymentConnection.java:80)
        at
org.apache.ode.axis2.management.DeploymentConnection.deploy(DeploymentConnection.java:61)
        at org.apache.ode.axis2.management.Main.main(Main.java:17)

What am i doing wrong?
I hope you can help me please.

Thanks
Ricardo

PS: to don't make an attach I paste here the files:

##################################### Main.java
#####################################

package org.apache.ode.axis2.management;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        DeploymentConnection con = new DeploymentConnection("
http://localhost:9090/ode/processes/DeploymentService");
        try {
            con.deploy(new File("C:\\temp\\DynPartner.zip"), "DynPartner");
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
        }}}



##################################### DeploymentConnection.java
#####################################

package org.apache.ode.axis2.management;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.util.Base64;
import org.apache.axis2.AxisFault;
import org.apache.ode.axis2.service.ServiceClientUtil;
import org.apache.ode.utils.Namespaces;

public class DeploymentConnection {
    private final String _url;
    private OMFactory _factory;
    private ServiceClientUtil _client;
    private final OMNamespace _pmapi;

    public DeploymentConnection(String url) {
        _url = url;
        _factory = OMAbstractFactory.getOMFactory();
        _client = new ServiceClientUtil();
        _pmapi = _factory.createOMNamespace("http://www.apache.org/ode/pmapi",
"pmapi");
    }

    public void deploy(File archive, String name) throws
FileNotFoundException, IOException {
        // Use the factory to create three elements
        OMElement root = _factory.createOMElement("deploy", _pmapi);
        OMElement namePart = _factory.createOMElement("name", null);
        namePart.setText(name);
        OMElement zipPart = _factory.createOMElement("package", null);
        OMElement zipElmt = _factory.createOMElement("zip", null);

        InputStream is = new FileInputStream(archive.getPath());
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(
(int) archive.length());
        byte[] buffer = new byte[4096];
        int len;
        while ((len = is.read(buffer)) >= 0) {
            outputStream.write(buffer, 0, len);
        }

        String base64Enc = Base64.encode(outputStream.toByteArray());
        OMText zipContent = _factory.createOMText(base64Enc,
"application/zip", true);
        root.addChild(namePart);
        root.addChild(zipPart);
        zipPart.addChild(zipElmt);
        zipElmt.addChild(zipContent);

        sendToDeployment(root);
    }

    public void undeploy(String packageName) throws IOException {
        // Prepare undeploy message
        OMNamespace pmapi = _factory.createOMNamespace(Namespaces.ODE_PMAPI,
"deployapi");
        OMElement root = _factory.createOMElement("undeploy", pmapi);
        OMElement part = _factory.createOMElement("packageName", null);
        part.setText(packageName);
        root.addChild(part);

        if (packageName != null) {
            part.setText(packageName);
            root.addChild(part);
            sendToDeployment(root);
        }
    }

    private OMElement sendToDeployment(OMElement msg) throws AxisFault {
        return _client.send(msg, this._url);
    }

}


On Wed, Aug 5, 2009 at 2:47 PM, Tammo van Lessen <tvanlessen@gmail.com>wrote:

> Ricardo,
>
> add Axis2 (a recent version) to the class path and get rid of any testng
> dependencies. If you only want to deploy a bundle, just look into the
> private deploy(String) method and adapt it to your needs.
>
> Currently there is no (and there aren't any plans yet to create a)
> remote deployment tool.
>
> HTH,
>  Tammo
>
> Ricardo Pereira wrote:
> > Hello,
> >
> > http://mail-archives.apache.org/mod_mbox/ode-user/200809.mbox/browser
> > I saw a post in the mailing list about the "Process Deployment with
> > DeploymentService" in September 2008. In this post Matthieu Riou said:
> >
> > The test cases can probably help you figure out what's missing/wrong
> > in your message:
> >
> >
> http://svn.apache.org/repos/asf/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
> >
> > That is just a java class and when I import it to an IDE to test, it
> returns
> > multiple errors due to the missing libraries
> >
> > Is there any simple way to test this class without the concerns about
> > libraries? I mean if you have any project where a user just have to
> specify
> > the path to the zip file and the DeploymentService link and it deploys on
> > the ODE server?
> >
> > Sorry but I really apreciate an answer as fast as you can due to my short
> > deadline.
> >
> > Thanks
> >
> > Ricardo
> >
>
>
> --
> Tammo van Lessen - http://www.taval.de
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message