• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JBoss WS client exception

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

@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.
 
James Hannoy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, i would recommend that you don't use injection in the standalone client.
 
James Hannoy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. I am able to resolve this problem.

Thanks!
James.
 
James Hannoy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting new exceptions now:



Will be thankful if you can get me some pointers.

-Thanks,
James.
 
James Hannoy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any pointers to resolve this please?

-Thanks,
JH.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, i dont have much experience with webservices
 
James Hannoy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved my exception by using JAX-WS instead of JAX-RPC.
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic