Skip to main content
Known Participant
February 8, 2010
Question

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

  • February 8, 2010
  • 3 replies
  • 2459 views

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

... 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!

This topic has been closed for replies.

3 replies

Participant
July 29, 2010

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

Inspiring
February 8, 2010

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.

Known Participant
February 8, 2010

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!

Known Participant
February 12, 2010

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.jar";
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.jar";
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!

BKBK
Community Expert
Community Expert
February 8, 2010

Could we see how you make the call?


Known Participant
February 8, 2010

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).