6 Replies Latest reply on Jun 17, 2014 6:41 AM by Ankit kalanoria

    Java callout in OSB returning error

    Ashish Rane



      I am receiving the below error when having java call out to JAR from OSB proxy.

      Input is JSON request and output is XML.


      Callout to java method "public static java.lang.String XMLJSONConverter.json2XMLConverter(java.lang.String)" resulted in exception: null


      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:183)

      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)

      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)

      at weblogic.security.Security.runAs(Security.java:61)

      at stages.transform.runtime.JavaCalloutRuntimeStep.processMessage(


      Can you please suggest any solution to resolve this.

        • 1. Re: Java callout in OSB returning error

          it seems that Java class is throwing the runtime excpetion,can you put try and catch in java class and log the exception.



          • 2. Re: Java callout in OSB returning error
            Richa Juneja

            Copy your java code and run it in eclipse to find the exact error with line#.



            • 3. Re: Java callout in OSB returning error
              Ankit kalanoria

              You need to use XMLSerializer and JSONSerializer classes.


              Key point to remember will be:

              • You are passing JSON string as input
              • You need to parse this JSON string into JSON object first using JSONSerializer object
              • JSON object will be assigned to XML string using XMLSerializer object
              • In response of Java callout, you will receive XML string. So within proxy, you will have to use InlinedXML function to convert it into XML object.


              In eclipse create maven project. you can use code and pom snippet from link mentioned below. Once you will build project in eclipse, it will download required and dependent jar files mentioned in below link. Now that code will work in your local machine. In order to put this code running in OSB server, eaisiest way which i think will be to copy those downloaded jar from your eclipse workspace into <Domain_Home>/lib directory of osb server. That is how imported class in java code will be made available at runtime to OSB. Then just import the java snippet jar from eclipse and import it in your osb project.




              Hope this helps.




              • 4. Re: Java callout in OSB returning error

                I think there is a unhandled null pointer exception. You could put exception handler for that and get stacktrace to get the exact location



                • 5. Re: Java callout in OSB returning error
                  Ashish Rane

                  Thank you all. I was able to resolve this by referring http://www.rubix.nl/blogs/converting-json-xml-osb-when-consuming-rest-service as the java code I was referring resembled the code from this link.

                  As mentioned in this link, some of the dependent jars had to be placed at $Domain/lib

                  Though the issue is resolved, still want to know how to determine which of the depending jars need to be placed at $Domain/lib. There are many dependent jars, but placing only few of them resolved the issue.

                  • 6. Re: Java callout in OSB returning error
                    Ankit kalanoria

                    When you build maven project then it downloads any jar which are referred directly in POM and also the jars which are referred by classes within those jars.


                    When we say jars, then those are nothing but having specific java libraries. Eclipse workspace where you created project, was vanilla so it needed everything.


                    While when you talk about Oracle service bus then it already consist of many jars like oracle-common etc.. I don't remember exact name of the directory but i think it was in "<Server_Home>/bin/". You can search that by exploring installed directory of oracle service bus.


                    When server is started then all these classes are made available to weblogic server and that is how after that OSB understands if any of its unerlying code is referring to any of those classes. For this to happen, all it needs is those jars to be present in classpath whether it is <Domain_Home>/lib or <Server_Home>/bin or something else.


                    You need to have surface knowledge of typically what kind of jars are already present in weblogic server classpath by exploring file structure of your installed directory. Ofcourse it is huge so even if you do, it will be difficult to remember. So you can try by putting all the jars first then start removing generic ones and verify if it is working. If it is then that jar or advanced version of that jar wil already be present somewhere in classpath.


                    Hope this helps.