ALSB - Java Callout (.jar using commons-httpclient-3.1)

Hello everyone,
I'm having a not so funny problem.
I made a Java class, that will be called by a Proxy Service (Java callout). I'm using the commons.httpclient-3.1.jar (+ codec and logging).
Here's the code:
package util.http;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.*;
public class UtilitaireHTTP {
// method used by the Proxy Service
public static String getLastModified (String url){
return getHeader(url,"last-modified");
private static String getHeader(String url, String header){
HttpClient client = new HttpClient();
String lastModified = "404";
HeadMethod head = new HeadMethod(url);
try {
//not working
/*int statusCode = client.executeMethod( head );
if (statusCode == 200){
     lastModified = head.getResponseHeader(header).getValue();
//working
lastModified = "200";
catch(Exception e){
     System.out.println(e);
finally {
// release any connection resources used by the method
head.releaseConnection();
return lastModified;     
Here's the problem: Whenever I remove the comment block, test it (it's going to work with JUnit), create a JAR. Import it into ALSB jar resources folder. When I do a Java Callout in a Proxy Service I won't be able to see my method getLastModified. If I put that block in comment, re-do all the export import, I'll see the method in the list.
//not working
/*int statusCode = client.executeMethod( head );
if (statusCode == 200){
     lastModified = head.getResponseHeader(header).getValue();
//working
lastModified = "200";
Anyone knows the solution or problem.
Thank you!
Van

While playing with java callouts i've built working "groovy callout" sample. This way you can keep logic in your alsb proxy service rather than in jar file. Have a look. http://blog.aujava.com/?p=64

Similar Messages

  • Difference between common-httpclient 3.0 and httpclient 4.0

    Hi,
    I am using SSL communicaiton between client and server machine.The JDK version is 1.6.0_19.I am using HttpClient 4.0 now.I used common-Httpclient 3.0 earlier. The client and the server both are having the certificate.Here we are doing mutual authentication sending the certificate to each other.
    If I use the command -Djavax.net.debug=all command I am able to see the detail client and server communicaiton.I wanted to know, what are the destination server it is reaching and that's why I have used wireShark.I have seen a difference here.If I use common-httpclient 3.0 component then it is reaching the verisign site to import the CRL.But if I use httpclient 4.0 then it is not reaching the verisign site.It might be reaching the verisign site for the CRL check.
    I know internally it is using the JSSE component.
    Here are my questions :
    I like to know why this difference is happening?
    Is the httpclient initiate CRL checking?
    Howcan I initiate the OCSP  instead of CRL check using the httpclient and the JSSE?
    how could I check the detail log?
    I like to know based on what condition the application is reaching the verisign site(means CRL checking).
    Please help me out.

    Hi Subba reddy,
    Check this link for PI differencess
    https://wiki.sdn.sap.com/wiki/display/XI/PI%207.1%20Components%20and%20its%20features%20over%20XI%202.0,XI%203.0,PI%207.0
    Regards
    Ramesh

  • How to use common resource bundle across all the development components ?

    Hi,
    I am working on SAP NetWeaver Developer Studio - JAVA
    How to use common resource bundle across all the development components ?
    Description :
    I have a requirement of creating a resource bundle (resource.properties) and use that common resource bundle in all the development components.
    Can we create a  development component (war and ear both) and create only resource.properties in this development component( DC ) and create the dependency of the same DC  in all the other DCs ?
    Thanks,
    Neha

    Hello Neha 
    This question is more NWDS related.
    You may have a better chance of someone answering the thread under
    SAP Netweaver -> SAP NetWeaver Development Infrastructure (NWDI, formerly known as JDI) forum
    Thanks
    Kenny

  • Invoke DBAdapter from Java Callout

    Hello,
    in OSB I need to invoke a DB-Adapter from a Java Callout. How can I achieve this?
    I cound not find any documentation about this (javadoc etc).
    Horst

    Ideally you should not need to access DB adapter from a Java callout. Use java callout for transformations, get back the transformed data, and call a business service based on DB Adapter.
    Alternatively, call java callout and make write code in Java to access DB directly using Weblogic datasource and connection pool.
    And if you dont want to do it any other way, create a business service based on the said DB Adapter, create a wrapper proxy(which internally calls the DB adapter based business service) of Any XML type with HTTP transport or even a WSDL based webservice, and call this from your Java code.

  • Using Apache Commons HTTPClient to create a custom socket for Java mail

    Does anyone know how to use Apache Commons HTTPClient to create a custom socket for Java mail. This is necessary for me to use NTLM authentication

    JavaMail doesn't use HTTP.
    If you want to add support for NTLM authentication to one of the standard protocols,
    your best bet is to create a SASL provider, although note that only JavaMail's IMAP
    provider uses SASL currently. The other protocols should add SASL support, but that
    hasn't been done yet.

  • ServiceBus java callout - how to pack the JAR file with libraries?

    Hello
    I want to use a Java Callout from a Service Bus flow.
    What is the correct way to pack the JAR file with its nessecary libraries?
    I tried different methods to pack my JAR, but yet, as though the Java runs perfectly from the Workshop (Eclipse) , when I am trying to use the exported Jar on the ServiceBus flow, it fails with an ClassNotFoundException.
    I would really appreciate your advice here.
    Thanks
    Koby

    Well.. Looking inside my exported JAR file, I got all of the files there inside, including the jar file containing the library.
    What I'm trying to do is run a simple java program that connect through SSH and therefore use an SSH library.
    On the workshop I got it as an imported library JAR. And it works perfectly there.
    Any idea?
    Here's the complete error I get:
    <BEA-382515> <Callout to java method "public static java.lang.String sshpackage.SshProg.remoteScriptInvoke(java.lang.String,java.lang.String,java.lang.String,java.lang.String)" resulted in exception: null
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at stages.transform.runtime.JavaCalloutRuntimeStep$1.run(JavaCalloutRuntimeStep.java:158)
    Truncated. see log file for complete stacktrace
    java.lang.NoClassDefFoundError: ch/ethz/ssh2/Connection
    at sshpackage.SshProg.remoteScriptInvoke(SshProg.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    Truncated. see log file for complete stacktrace
    java.lang.ClassNotFoundException: ch.ethz.ssh2.Connection
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at com.bea.wli.sb.resources.archive.HookedJarClassLoader.loadClass(HookedJarClassLoader.java:251)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    Truncated. see log file for complete stacktrace
    Edited by: kobyssh on 04:12 01/02/2010

  • OSB JAR Resources for Java callout in Cluster

    Hi,
    I have a JAR Resource, which has one simple java class with one static method. I invoke this method using Java Callout in my proxy service.
    This all works fine if I am in single node environment, when I move to Cluster two node environment, I export the current single node config and import in cluster config, all services work fine except that JAR is available but I cannot access any methods and when I click on this JAR Resource it says "JAR Resource not found". Is there a special consideration for moving custom JARs to OSB Cluster.
    Please can someone provide some details on this, greatly appreciate.
    thanks
    KD

    Here are some more details, basically I have a JAR which has methods, so I created a JAR resource in cluster, and it uploads my jar successfully. I see a resource name now, when I click on this resource it says "resource not found".
    If I do the same exact steps in non-clustered environment, it just works fine without problems.
    In cluster configuration I went to each node including admin and verified that .ar file is there.
    If I export now what I have in cluster, the exported configuration JAR does have a mycustomjar.Archive file. But I am not able to access it in console.
    Also I want to say thanks for helping me, please let me know what I can verify more.
    thanks
    KD

  • Java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpException

    Test.java NoClassDefFoundError java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpException
    Can any one explain what is the cause of this error?? not able to understand what jar file to be uploaded??

    http://forum.java.sun.com/thread.jspa?threadID=5156615&tstart=0
    Duplicate post!

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • Problems with the ActiveX bridge for Java beans when using third-party .jar

    I encountered the following problem when using the ActiveX bridge for a java bean:
    I am using JDK 1.4.2_09 and MS Visual Basic 6.0 (SP6). I wrote a java bean called ProcessViewer (my class ProcessViewer inherits from JComponent and implements the interfaces Serializable and AdjustmentListener) which I would like to use within a VB 6.0 application. I used the ActiveX bridge (packager.exe) to generate a DLL (ProcessViewer.dll) and registered it successfully. The java bean GUI-control works fine within my VB 6.0 application unless my java bean (ProcessViewer.jar) uses any third-party .jar files.
    But when I tried to add a reference to some third-party class (com.sap.xxx.xxx....) I got some problems. I could solve the problem with packager.exe by setting the correct CLASSPATH. But at runtime my VB 6.0 application does not work. It crashes or it reports an error like this: "The control ... could not be loaded from axbridge.dll" (although I deployed my .jar file correctly to the directory C:\Programme\Java\j2re1.4.2_09\axbridge\bin and lib). Setting the CLASSPATH environment variable before calling my VB 6.0 application (exe) did not solve the problem.
    How can I teach my VB 6.0 application (containing the Java bean ActiveX control) where to find the third-party .jar file? Copying the third-party .jar file to the JRE lib-folder or to the axbridge\lib folder did not solve the problem either.
    I studied the documentation about the ActiveX bridge given at:
    http://java.sun.com/j2se/1.4.2/docs/guide/beans/axbridge/developerguide/index.html
    but I am missing informations on how the third-party .jar files can be found during runtime of the ActiveX container (e. g. a VB 6.0 application).

    See how to solve your problem with JNI:
    http://codeproject.com/cpp/OOJNIUse.asp
    More examples (for SWING) in tools setup:
    http://www.simtel.net/product.php[id]95126[SiteID]simtel.net
    http://www.simtel.net/product.php[id]94368[SiteID]simtel.net
    http://www.simtel.net/product.php[id]93174[SiteID]simtel.net

  • Modifying JAR file using java.util.jar package  over the network

    Hello,
    I am modifying a JAR file programmatically using java.util.jar package. The time taken to save the contents to a local disk is very less (around 1 sec) . When I tried modifying the JAR from a remote machine over the network (from mapped drive or shared folder of WIN NT), the time taken to save is 15-20 times more.
    I am recreating the whole JAR while modifying. Is there any way to improve the performance. Or is it possible to write only the changed files?
    Thanks,
    Prasad Y S.

    When you "update" a jar file, you must always recreate it from scratch.

  • Help:how to use java.util.jar to zip or unzip a binary file.

    how to use java.util.jar to zip or unzip a binary file or a file contain native code.

    It may help you to know how I add JARs
    1. I open my Project (myProject)
    2. I Mount the JAR to the FileSystem (like mypackages.jar = which includes com.mus.de.myClass.java)
    3. I Mount the File to the FileSystem (like c:\..myfiles..\myProject)
    3.1 I add the File to my Project
    4. I select File | New -> Classes | Main
    4.1 I typed "import com.mus.de.myClass.java" to refer to this package.
    4.2 I called some of the public methods
    thats it
    Andreas

  • JAVA Application speed using JARs

    Good day guys,
    I have a quick question about the perfomance.
    When I write Java application that uses other third party JARs, do I have to remove all the
    classes from those jars that I dont use to make application run faster or it does not metter?
    Thank you very much

    Ajaxian wrote:
    Good day guys,
    I have a quick question about the perfomance.
    When I write Java application that uses other third party JARs, do I have to remove all the
    classes from those jars that I dont use to make application run faster or it does not metter?
    Thank you very muchLet's take that to another level. Suppose this is on Windows, and that none of the apps running on it will ever use some DLL(s) or some APIs in those DLLs, which are already installed on the box. Do you really think you should worry about trimming them down?
    And surely none of the java specific apps you will write will use ALL of the classes and methods in the whole java library, so should you whack those too?

  • ALSB / OSB Java callout to gunzip

    We have an input file which is in a gz format, which we need to gunzip before passing onto our business service.
    We're writing a simple Java callout component to do this - taking an input stream and returning an output stream.
    What variable should I pass into my input stream from the callout in the proxy service message flow?
    I've tried $body and $input, but neither of these work.
    Thanks in advance
    Phil Riley

    Have tried logging to output, and this is what I get:
    $attachments[0]/ctx:attachment/ctx:body - empty
    $body
    <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <con:binary-content ref="cid:2a96c6b3:12da3c4b844:-7f3c" xmlns:con="http://www.bea.com/wli/sb/context"/>
    </soapenv:Body>
    $inbound
    <con:endpoint name="ProxyService$FredhopperExtract$ProxyServices$Test GZip" xmlns:con="http://www.bea.com/wli/sb/context">
    <con:service/>
    <con:transport>
    <con:uri>file:////apps/bea/dp_tmp</con:uri>
    <con:mode>request</con:mode>
    <con:qualityOfService>best-effort</con:qualityOfService>
    <con:request xsi:type="file:FileRequestMetaData" xmlns:file="http://www.bea.com/wli/sb/transports/file" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <tran:headers xsi:type="file:FileRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
    <file:fileName>/apps/bea/dp_tmp/test.txt.gz</file:fileName>
    </tran:headers>
    <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
    <file:isFilePath>false</file:isFilePath>
    </con:request>
    </con:transport>
    <con:security>
    <con:transportClient>
    <con:username>&lt;anonymous></con:username>
    </con:transportClient>
    </con:security>
    </con:endpoint>
    None of these actually have the contents of the message - the $body is the closest which tells me that it is binary and has a ref.

  • Java Callout on Eclipse Workshop

    Guys,
    It seems to be impossible to design a Proxy Service that uses a Java Callout on Oracle Workshop for WebLogic Version: 10.3 (Eclipse).
    It deppends of a Jar Resouce File. The problem is to make available this jar to Eclipse Workshop. When using the web console it goes fine, but with Workshop it seems to have this limitation.
    Does anyone know a workaround?
    I have only one, not tested yet. To export the project deployed and import it back to Eclipse. Does anyone knows a better way?

    I experienced a similar problem when opening a OSB Project developed by another user. He was using the windows version of Workshop/Eclipse while I used a unix-version.
    Opening projects in workshop with error is quite common, so I did not reflect on the error on two of the proxy services that appeared on this one before the regular steps "build/clean..", close and reopen project, close workshop, reinstall workshop etc. did not work at all. Always the same error: Archive resource [my resource] does not exist.
    Investigating the error showed that workshop did not manage to find the class needed for the JavaCallout. Even when I opened the JavaCallout action and tried to tell it where to look workshop could not find it.
    After starting workshop from the command line shell a root cause appeared as a java.io.IOException: Permission denied.
    To shorten the story a bit, it appeared that the java.io.tmpdir was write protected. In fact it was created by root. After a quick sudo, rm -rf /tmp/alsbTempJars and a workshop restart and a build clean I could proceed with development.
    Edited by: Helge Aarstein on Oct 1, 2010 5:49 AM

Maybe you are looking for

  • IMac wont start

    wheneve I start up the iMac G3, it just shows a gray screen. After awhile it shows a folder with the 2-faces-in-one logo on it in the center of the screen. it doesn't let me click on it or anything, and I dont know what its for. Also, if i start it u

  • Use of pl/sql tables in bulk binding

    DECLARE TYPE idtab IS TABLE OF NUMBER(4) INDEX BY BINARY_INTEGER; vid idtab; --:=idtab(3,4,56,8,53); BEGIN vid := idtab(3,4,56,8,53); FORALL i IN vid.first .. vid.last        INSERT INTO TEST VALUES (vid(i)); END;when executing this code it gives me

  • BP by Sales Area Data

    Hello, Could any one help me with the table where the Sales Area, Sales Org, Sales group and Sales District are stored for a BP. Importantly I would be looking for a table where I can find a Sales district of BP. Any inputs would be highly appreciate

  • How to set software updates back to Apples server?

    Hi, I just started using OSX Server. I will be using it to perform hundreds of netboot installs of Leopard which I have working. I also want to use it to serve software updates which I also have working on one machine using the defaults write com.app

  • I recently purchased new Mac Mini with Lion installed. Now I can't get iTunes to sync iCal from my iPod Touch (3rd gen) to my Mini.

    I recently purchased a new Mac Mini with Lion installed. I downloaded the latest version of iTunes. Now I can't get iTunes to sync iCal from my iPod Touch (3rd gen) to my Mini. Everything else syncs great, and iCal syncs from my Mini to my Touch. My