11 Replies Latest reply on Aug 2, 2010 7:44 AM by Jill of all trades

    Calling a Java component that calls (consumes) a web service

    Jill of all trades

      We are having a problem calling a Java component that calls (consumes) a web service. The component has a stand alone test facility, and when run stand alone it always succeeds. When we call the component from within ColdFusion (same parameters are being used as in the stand alone case) it dies at the point where it tries to instantiate the web service object. The stack trace is:

       

      Caused by: java.lang.NullPointerException

      at org.apache.axis.client.Service.getEngineConfiguration(Service.java:801)

      at org.apache.axis.client.Service.getAxisClient(Service.java:143)

      at org.apache.axis.client.Service.<init>(Service.java:152)

      at soapapi.TokServiceLocator.<init>(TokServiceLocator.java:12)

      at com.*******.viewlinkApp.rip.RipQueryProvider.executeIndexRequest(RipQueryProvider.java:20 7)

      ... 40 more

       

      Apache Axis is the web services implementation that is being called by our java component.

       

      Our investigation of this has found that the NullPointerException is being thrown when Apache Axis is initializing itself and has been unable to find an EngineConfiguration class. We suspect that this is because ColdFusion has altered the web service configuration mechanisms to support consuming web services directly from CF. Unfortunately we need to call the web service from within the Java component. Does anyone have information on how to do this? We don't have any need to consume any web services directly from ColdFusion so a loss of that ability is a non-issue.

       

      Thanks!

        • 1. Re: Calling a Java component that calls (consumes) a web service
          BKBK Adobe Community Professional & MVP

          Could we see how you make the call?


          • 2. Re: Calling a Java component that calls (consumes) a web service
            Jill of all trades Level 1

            In the cf code, I call java classes that are located in a .jar file in the D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib folder.

             

            This is the reply from the person who is coding the java:

             

             

            We just call the parameterless constructor of the API that was generated for us from the WSDL file:

            TokServiceLocator tokServiceLoc = new TokServiceLocator();

            Inside the generated code is:

            public TokServiceLocator() {

            }

            This would do nothing execpt the generated class is a subclass:

            class TokServiceLocator extends org.apache.axis.client.Service ...

            and it is within the parameterless Service constructor that our problems are occurring (see stack trace).

            • 3. Re: Calling a Java component that calls (consumes) a web service
              Jochem van Dieten Level 4

              Let e guess: the component you are using has been built against Axis 2.0. ColdFusion uses Axis 1.3 and you are most likely running into a classloader issue.

              • 4. Re: Calling a Java component that calls (consumes) a web service
                Jill of all trades Level 1

                 

                 

                It's 1.3. The .jar we are building against shows the following in its META-INF/MANIFEST.MF file:

                Manifest-Version: 1.0

                Ant-Version: Apache Ant 1.5.3

                Created-By: 1.4.2_05-b04 (Sun Microsystems Inc.)

                Name: org/apache/axis

                Implementation-Title: Apache Axis

                Implementation-Version: 1.3 2244 October 5 2005

                Implementation-Vendor: Apache Web Services

                This is also the .jar that we are running with on the server (just checked) when we succesfully run the component stand-alone.

                 

                Thanks for your help!

                • 5. Re: Calling a Java component that calls (consumes) a web service
                  Jill of all trades Level 1

                  We have found that the CF webservice.jar contains the org.apache.axis classes we need to use in our java component.  The webservice.jar is overriding the axis.jar classes.  We are trying to use javaloader.cfc but once you start "naming" the classes you want to load there are always some missing and/or they are not getting loaded in the right sequence/combination.

                   

                  this is the latest in a long list of errors we have been getting:

                   

                  An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. If the class has a constructor that accepts an argument, you must call the constructor explicitly using the init(args) method. Error : org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory

                   

                  paths[1]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\axis.jar";
                  paths[2]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\cfmx_bootstrap.jar" ;
                  paths[3]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\cfx.jar";
                  paths[4]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\commons-beanutils-1 .8.0.jar";
                  paths[5]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\commons-collections -2.1.jar";
                  paths[6]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\commons-discovery.j ar";
                  paths[7]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\commons-logging.jar ";
                  paths[8]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\dom4j.jar";
                  paths[9]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\javax.activation.ja r";
                  paths[10]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\javax.mail.jar";
                  paths[11]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jaxen.jar";
                  paths[12]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jaxrpc.jar";
                  paths[13]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jdom.jar";
                  paths[14]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jmc.jar";
                  paths[15]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\js.jar";
                  paths[16]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jsafeFIPS.jar";
                  paths[17]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jsafeJCEFIPS.jar";
                  paths[18]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\jtds-1.2.4.jar";
                  paths[19]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\log4j.jar";
                  paths[20]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\oncrpc.jar";
                  paths[21]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\portlet-proxy.jar" ;
                  paths[22]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\saaj.jar";
                  paths[23]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\servlet.jar";
                  paths[24]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\vbjclientorb.jar";
                  paths[25]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\***our custom****.jar";
                  paths[26]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\wsdl4j-1.5.1.jar";
                  paths[27]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\xercesImpl.jar";
                  paths[28]="D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\xmlParserAPIs.jar" ;

                   

                  Seems a little excessive to me, too.  Any ideas would be very appreciated!

                   

                  Thanks!

                  • 6. Re: Calling a Java component that calls (consumes) a web service
                    lance.saldanha

                    Anyone have a solution to this problem?

                    • 7. Re: Calling a Java component that calls (consumes) a web service
                      -==cfSearching==- Level 4

                      Class loader conflicts are sometimes very hard to troubleshoot. (It is called jar hell for good reason).  Since you mentioned using the javaLoader, is there a reason for using it here? Have you tried simply placing the jar in your class path and using createObject(...) instead?

                      • 8. Re: Calling a Java component that calls (consumes) a web service
                        Jill of all trades Level 1

                        We had a conflict with a version of axis that CF uses.  We had to unload the CF jar files, call  the custom jar to access the version of axis that we needed for the web service and then reload the cf jar files.

                        • 9. Re: Calling a Java component that calls (consumes) a web service
                          lance.saldanha Level 1

                          We were able to resolve this by adding the following to our JVM arguments:

                           

                          -Dcoldfusion.classPath={application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/ cfusion/lib,C:/jars

                          • 10. Re: Calling a Java component that calls (consumes) a web service
                            -==cfSearching==- Level 4

                            It's 1.3. The .jar we are building against shows the following in its

                            Implementation-Version: 1.3 2244 October 5 2005

                            ...

                            We had a conflict with a version of axis that CF uses.  We

                            had to unload the CF jar files, call  the custom jar to

                            access the version of axis that we needed for the web

                            service and then reload the cf jar files.

                             

                            Then I am not sure how you are successfully building against axis 1.3 if the custom jar requires a later version of axis.

                             

                            From what little I know about it, you either have to upgrade the axis jar or ensure that the desired version is loaded first by the class loader. Though I have no idea what CF features that might break in the process ...

                            • 11. Re: Calling a Java component that calls (consumes) a web service
                              Jill of all trades Level 1

                              This was a while ago and I am no longer on contract at this company so bear with me while I try to remember...  I believe we used trial and error until we got the right combination for axis and I believe log4j.  Check out the documentation for cfloader.  This is the component we used to accomplish this.  Other people have ran across this issue and I found this solution searching on the internet.