wood burning stoves 2.0*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes @WebServiceRef in Tomcat 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "@WebServiceRef in Tomcat 7" Watch "@WebServiceRef in Tomcat 7" New topic
Author

@WebServiceRef in Tomcat 7

Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1190
    
    1

I am trying to run Web Servlet which inject a webs service using @WebServiceRef annotation.
I created a Math Service .. published it .. generated files using wsimport command on WSDL .. added all generated artifacts in web application... deployed app on Tomcat 7. I am getting below shown application.


Error is



How to resolve this error in Tomcat 7?

Some where on web I read that Tomcat do not support JAX-WS annotations. Is that correct ?


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 781
Maybe, your TestClient is a standalone client and you cannot do injection from there.
How about deploying your client from Glassfish?

If you want to deploy your client using Tomcat, I think you can do this :
1. Create WEB-INF/classes folder, and put the class file there, like this, WEB-INF/classes/TestClient.class
2. Put the following web.xml file in WEB-INF/, like this WEB-INF/web.xml
3. jar -cvf testclient.war WEB-INF
4. put testclient.war to {Tomcat_directory}/webapps
5. start Tomcat and see ...
The web.xml may look like this:
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1190
    
    1

Hi Himai

Thanks for the reply.
I did deployed this TestClient as web application on Tomcat (as you can notice in my previous post that TestClient extends HTTPServlet class) but I am getting error.
GlassFish is a Web and EJB container both. Moreover, documentation says that GlassFish server contains JAX-WS and JAX-RI support.
So I wanted to know whether Tomcat support JSR 224 [ JAX-WS], JSR 181 [ Web Service Annotation] and JAX-RI implementation or not.
I searched Tomcat documentation but could not find this information. As per JSR 224, Web service can be now deployed as Standalone OR in Web container.
So is this a special case where deployment of Web Service (or reference to Web service) will not work in Tomcat ?

Thanks
Abhay Agarwal






Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 781
Yes. Tomcat can support JAX-WS annotations.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 781
I tried to deploy a similar application in Tomcat and ran into the same problem as yours.
I think Tomcat does not recognize @WebServiceRef annotation. If you create an instance of the service, it will work.
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1190
    
    1

Hi

Thanks for trying my code at your end.
I did found this link today
http://tomcat.apache.org/tomcat-7.0-doc/extras.html#Web_Services_support_%28JSR_109%29
Here, it is mentioned that Tomcat 7 support JSR 109.
@WebServiceRef annotation is present in JSR 224.

May be this the reason why Tomcat 7 do not support @WebServiceRef annotation.

Thanks
Abhay
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
Abhay Agarwal wrote:
May be this the reason why Tomcat 7 do not support @WebServiceRef annotation.

I've had trouble with @WebServiceRef and embedded Jetty in the past. What happens if you deploy the same code in a JAVA EE container, like GlassFish?
Also, try adding wsdlLocation to the annotation and see if that makes a difference.


Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 781
I tried my client with @WebServiceRef (value=xxxService.class) in GlassFish. It works.
But this client does not work with Tomcat.

Like what you suggest , I tried again with @WebServiceRef(value=xxxService.class, wsdlLocation="http://....wsdl"). I deploy this client on Tomcat. I ran into the same issue.
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
Himai Minh wrote:I tried my client with @WebServiceRef (value=xxxService.class) in GlassFish. It works.
But this client does not work with Tomcat.

The spec says that @WebServiceRef is guaranteed to work in Java SE environment only if the class that uses the annotation is a Web Service implementation endpoint. I can't recall of the top of my head if that's also applicable for a Servlet Container like Tomcat and at this point, I don't have the time to go digging.
I think you've proven that @WebServiceRef works the way you'd expect in a Java EE container. If it doesn't in Tomcat, I'd not get hung up on it unless your primary objective is to test Tomcat compliance with the JSR 224.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 781
Thanks for your clarification Sarkar.
That answers the question of the OP.
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
If you're satisfied with the answer, please mark it resolved by clicking on the similarly named button on top of the original question. A +1 is also helpful so that the people answering know that you appreciate their time.
Jurica Krizanic
Ranch Hand

Joined: Dec 11, 2008
Posts: 38

I can't make it work on Tomcat 7. Getting that name is not bound in context, tried all combinations.

Anyone managed to make it work on Tomcat 7 or trying on Glassfish is the only solution?

Sorry if I missed how to make it work on Tomcat!


Jurica Krizanic - Java developer, OCPJP6, Spring Core certified developer!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

Jurica Krizanic wrote:I can't make it work on Tomcat 7. Getting that name is not bound in context, tried all combinations.

Anyone managed to make it work on Tomcat 7 or trying on Glassfish is the only solution?

Sorry if I missed how to make it work on Tomcat!

Nope, very high chance that it doesn't work. Go for Glassfish or Jboss.
Jurica Krizanic
Ranch Hand

Joined: Dec 11, 2008
Posts: 38

Frits Walraven wrote:
Nope, very high chance that it doesn't work. Go for Glassfish or Jboss.


Glassfish will be! Thank you for the info.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @WebServiceRef in Tomcat 7