File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes JBoss WS client exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBoss WS client exception" Watch "JBoss WS client exception" New topic
Author

JBoss WS client exception

James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Hi,

I've trying to call a deployed WS from my client code. Which looks like the following:



However, I am getting the following exception at line
service = Service.create(url, qname);



Will appreciate your help alot.

-Thanks,
JH.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

@WebServiceRef(wsdlLocation = "http://127.0.0.1:8080/project/NewService?wsdl")
static Service service;

Are you running this as a standalone java client? I think, the webservice injection is not available in a standalone client.


[My Blog] [JavaRanch Journal]
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Thanks for your reply Jaikiran.

Actually I'm using the following build xml to run this (fragment given) with the classpath set to point the JBoss client jars:


<target name="run.wsclient" depends="ejbjar">
<java classname="testcases.WSClient" fork="yes" dir=".">
<classpath refid="classpath" />
</java>
</target>


So, do you think that I should use the factory approach instead?

-Thanks,
James.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Yes, i would recommend that you don't use injection in the standalone client.
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
I've made the following changes in the doTest() method:


public void doTest(String[] args) {
try {
System.out.println("Calling Service...");
URL url = new URL("http://127.0.0.1:8080/project/NewService?wsdl");
QName qname = new QName("urn:session", "NewService");

[B]
/* Changes made: commented */
//service = Service.create(url, qname);

/* Changes made: added */
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(url, qname);
[/B]System.out.println(service.getServiceName());
System.out.println("Retrieving port from the service " + service);

NewService newService = service.getPort(qname, NewService.class);
System.out.println(" Invoking create operation on the NewService port");
SomeObj so = newService.create("Hello");
System.out.println("Created: " + so.toString());
} catch (Exception e) {
e.printStackTrace();
}
}



However still getting the following:


run.wsclient:
[java] Calling Service...
[java] java.lang.NullPointerException
[java] at java.lang.System.arraycopy(Native Method)
[java] at org.apache.xerces.impl.xs.XSModelImpl.getAnnotations(Unknown Source)
[java] at org.jboss.ws.metadata.wsdl.xmlschema.WSSchemaUtils.copyXSModel(WSSchemaUtils.java:730)
[java] at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:202)
[java] at org.jboss.ws.tools.wsdl.WSDL11Reader.processTypes(WSDL11Reader.java:391)
[java] at org.jboss.ws.tools.wsdl.WSDL11Reader.processDefinition(WSDL11Reader.java:172)
[java] at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:128)
[java] at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:321)
[java] at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:115)
[java] at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:86)
[java] at org.jboss.ws.core.jaxrpc.client.ServiceImpl.<init>(ServiceImpl.java:111)
[java] at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
[java] at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128)
[java] at testcases.WSClient.doTest(WSClient.java:39)
[java] at testcases.WSClient.main(WSClient.java:82)


Any other pointers please?

-Thanks,
James.
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Got a reference of this under the following FAQ:

http://jbws.dyndns.org/mediawiki/index.php?title=FAQ

Which says under section "Why do I get a NullPointerException when using wstools?" that this is a ANT bug. So I have copied xercesImpl.jar and xml-apis.jar files of xerces-2_9_0 version to my ANT/lib folder.

But still no luck and getting the same exception

-Thanks,
JH.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Originally posted by James Hannoy:
Got a reference of this under the following FAQ:

http://jbws.dyndns.org/mediawiki/index.php?title=FAQ

Which says under section "Why do I get a NullPointerException when using wstools?" that this is a ANT bug.


Good find

Originally posted by James Hannoy:
So I have copied xercesImpl.jar and xml-apis.jar files of xerces-2_9_0 version to my ANT/lib folder.

But still no luck and getting the same exception


Did you copy the xercesImpl.jar too? If so which version did you copy. And just to make sure that the right version is being picked up, add the following statement to the main() method in your client (at the beginning of the method):

James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Thanks Jaikiran to point that out.

I'll post my feedback as soon as I get a chance to test it again. But what version of that jar should I use?

-Thanks,
James.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

The FAQ that you pointed mentions:

This is a xerces bug that was fixed in 2.7.0. Unfortunately, the latest version of ant comes with 2.6.2. You need to update the xerces jars in your ANT_HOME/lib directory to be at least 2.7.0


So any version above 2.7.0 (inclusive) should be fine.
[ January 09, 2008: Message edited by: Jaikiran Pai ]
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
In that case, it must be something else and not the version issue

The Meta-INF version info for the xercesimpl is as follows:

Name: org/apache/xerces/impl/Version.class
Comment: Xerces-J 2.9.0Implementation-Title: org.apache.xerces.impl.Version
Implementation-Version: 2.9.0


And I have copied the same under my ANT 1.7.0/lib!

So don't think that this could be the issue. Must be missing something else.

-Thanks,
James.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Did you add the System.out.println statement in your code to see which version is being picked up. Just wanted to make sure that some other jar file from the classpath is not being picked up.
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Hi,

You were absolutely right man

I got the chance to test it and it produces the following output:


I think I have to check from where it is getting that 2.6.2

-Thanks,
JH.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Originally posted by James Hannoy:
I think I have to check from where it is getting that 2.6.2



One way of figuring out which jar file is being used for org.apache.xerces.impl.xs.XSModelImpl is to enable verbose logs for classloading. You can do this by adding -verbose:class as a JVM parameter. This will print out which class is being loaded from which jar. The logs will be written out to STDOUT.

Note: Once you have debugged the issue, i would recommend to remove the -verbose:class parameter from the JVM, because it slows down the performance of the application
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Thanks for the tip. I am able to resolve this problem.

Thanks!
James.
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
I am getting new exceptions now:



Will be thankful if you can get me some pointers.

-Thanks,
James.
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Hi,

Any pointers to resolve this please?

-Thanks,
JH.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Sorry, i dont have much experience with webservices
James Hannoy
Greenhorn

Joined: Dec 26, 2007
Posts: 24
Never mind, I resolved this and client is running fine.
Also, just for your information, the @WebServiceRef(wsdlLocation = "http://127.0.0.1:8080/project/NewService?wsdl") is not any problem.

I only had some jar mismatches. This works alright now.

Many thanks for your kind help,
James.
Johannes Koch
Greenhorn

Joined: Dec 25, 2005
Posts: 11
James,
which JAR mismatches did you have exactly? I keep getting the same exception, and so do many other people. All kinds of forums are crowded with people asking because of "org.jboss.ws.WSException: Cannot obtain java type mapping for..." errors, but I can't find a final solution for this issue anywhere.
Please, let us know how you resolved this!
Thanks, Johannes
Johannes Koch
Greenhorn

Joined: Dec 25, 2005
Posts: 11
I solved my exception by using JAX-WS instead of JAX-RPC.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBoss WS client exception