Question

javax.xml.rpc.ServiceException: Provider com.sun.xml.rpc.client.ServiceFactoryImpl not found

Asked by: jrwalker2

I am attempting call a simple webservice through a client, but I continue to get the following exception. I am using JBoss as my application server. Everything compiles in Eclipse (Note I am using java 6).

1. Am I supposed to change the .classpath file so that the client knows about the ServiceFactoryImpl?
2. What jar inside of Jboss contains this class and how do I make this work?

Please help! Thanks!


Exception within Eclipse with the client is run:
--------------------------------------------------------
Exception in thread "main" javax.xml.rpc.ServiceException: Provider com.sun.xml.rpc.client.ServiceFactoryImpl not found
      at javax.xml.rpc.FactoryFinder.newInstance(FactoryFinder.java:44)
      at javax.xml.rpc.FactoryFinder.find(FactoryFinder.java:87)
      at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:58)
      at com.spc.whp.samples.client.Client.main(Client.java:22)


Output from JBoss
----------------------------------
00:21:23,625 ERROR [ContainerBase] Servlet.service() for servlet EchoBean threw exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
        at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:441)
        at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:67)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:155)
        at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:235)
        at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:164)
        at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:104)
        at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:659)
        at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:224)
        at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:502)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.intuit.spc.bhp.logging.LoggingFilter.doFilter(LoggingFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)

Client
-----------
package com.spc.whp.samples.client;
 
import java.net.URL;
 
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
 
import com.spc.whp.samples.Echo;
 
public class Client {
    public static void main(String[] args) throws Exception {
    	// System.setProperty( "javax.xml.rpc.ServiceFactory", "com.sun.xml.rpc.client.ServiceFactoryImpl");
        System.out.println("Starting Test Client");
        URL url = new URL("http://localhost:8080/EchoBeanService/EchoBean?wsdl");
        QName qname = new QName(
                        "http://webservice.samples.whp.spc.com/jaws",
                        "EchoService");
 
        System.out.println("Creating a service Using: \n\t" 
                                   + url + " \n\tand " + qname);
        ServiceFactory factory = ServiceFactory.newInstance();
        Service remote = factory.createService(url, qname);
 
        System.out.println("Obtaining reference to a proxy object");
        Echo proxy = (Echo) remote.getPort(Echo.class);
        System.out.println("Accessed local proxy: " + proxy);
       
        String string = "John";
        System.out.println("Sending: " + string);
        
        System.out.println("Receiving: " + proxy.echo("John"));
    }
}
 
 
EchoBean
---------
package com.spc.whp.samples.webservice;
 
 
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.jws.WebService;
 
@Stateless
@WebService(endpointInterface = "com.spc.whp.samples.webservice.Echo")
@Remote(Echo.class)
public class EchoBean {
        public String echo(String e) {
                return "Web Service Echo + " + e;
        }
}
 
 
Echo
---------
package com.spc.whp.samples.webservice;
 
import java.rmi.Remote;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
 
@WebService
@SOAPBinding(style = Style.RPC)
public interface Echo extends Remote {
        String echo(String e);
}

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-05-25 at 01:54:33ID23431062
Topics

J2EE

,

SOAP

,

Java Programming Language

Participating Experts
2
Points
500
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Jar a Servlet?
    I have several servlets that I would like to JAR to reduce clutter in a directory. I tried to jar the servlets in their current directory. When I attempt to run one of the jar'd servlets the webserver can't find it and I receive an error. Is it possible to jar servlets and...
  2. servlet cannot find class inside JAR
    My servlet cannot find the class inside the JAR file (mm_mysql-2_0_2-bin.jar) which is in the same directory as the servlet. I get ClassNotFindException when trying to load the Driver class with Class.forName("org.gjt.mm.mysql.Driver"); When I put the name of the J...
  3. servlets
    the servlets r not running properly...servlet class file not found..and path errors
  4. ClassLoaders and classpaths
    Hello, I am a little confused about flow between various classloaders and related concepts. After discussing it with my colleagues, here is how my understanding goes : Please mark true/false for each point and help correct my understanding by giving your comments. 1. An ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: CEHJPosted on 2008-05-25 at 04:05:11ID: 21642061

See if you can see a program called 'wsrunclient' in JBoss and try using that

 

by: jrwalker2Posted on 2008-05-25 at 08:27:40ID: 21642916

1. Can you give me an example on how to use this program please? I tried the following but got an exception (below).

wsrunclient.bat http://localhost:8080/EchoBeanService/EchoBean?wsdl "john"

2. Do I need to deploy the client inside of the same jar that packages Echo.class and EchoBean.class?

Thanks.


Exception
--------------
Caused by: java.lang.ClassNotFoundException: http:..localhost:8080.EchoBeanService.EchoBean?wsdl
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

 

by: CEHJPosted on 2008-05-25 at 08:32:35ID: 21642927

I really don't know what to do with it. You could post the batch file into the code snippet window

 

by: CEHJPosted on 2008-05-25 at 08:40:50ID: 21642950

I think the source of the problem is around this:

http://java.sun.com/webservices/docs/1.6/api/javax/xml/rpc/ServiceFactory.html#SERVICEFACTORY_PROPERTY

but i'm not sure. I think that might need to be set to the factory used by JBoss

 

by: jrwalker2Posted on 2008-05-25 at 08:46:59ID: 21642970

Is the following what you mean? I had this line in my client but it did not change anything

System.setProperty( "javax.xml.rpc.ServiceFactory", "com.sun.xml.rpc.client.ServiceFactoryImpl");

If not, can yoiu please give me a code example or steps on what you mean? Thanks

 

by: CEHJPosted on 2008-05-25 at 08:59:27ID: 21642999

That would be OK if it were the factory being used, but you might find that JBoss isn't using that. I think you're going to have to look into how JBoss is providing the service

 

by: shivaspkPosted on 2008-05-25 at 15:21:45ID: 21643826

jrwalker, first of all check if your web service is up and running.

http://localhost:8080/EchoBeanService/EchoBean?wsdl

when you open the above URL what do you see??

Lets go step by step, first get your service up and running.

if you are able to see a wsdl in the web browser than we can see how to create the client.

 

by: jrwalker2Posted on 2008-05-25 at 15:35:07ID: 21643851

Thanks for responding shivaspk. I attached what I see when I go to  http://localhost:8080/EchoBeanService/EchoBean?wsdl




<definitions name="EchoBeanService" targetNamespace="http://webservice.samples.whp.spc.com/">
<types/>
 
	<message name="Echo_echoResponse">
<part name="return" type="xsd:string"/>
</message>
 
	<message name="Echo_echo">
<part name="arg0" type="xsd:string"/>
</message>
 
	<portType name="Echo">
 
	<operation name="echo" parameterOrder="arg0">
<input message="tns:Echo_echo"/>
<output message="tns:Echo_echoResponse"/>
</operation>
</portType>
 
	<binding name="EchoBinding" type="tns:Echo">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
 
	<operation name="echo">
<soap:operation soapAction=""/>
 
	<input>
<soap:body namespace="http://webservice.samples.whp.spc.com/" use="literal"/>
</input>
 
	<output>
<soap:body namespace="http://webservice.samples.whp.spc.com/" use="literal"/>
</output>
</operation>
</binding>
 
	<service name="EchoBeanService">
 
	<port binding="tns:EchoBinding" name="EchoBeanPort">
<soap:address location="http://localhost:8080/EchoBeanService/EchoBean"/>
</port>
</service>
</definitions>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:

Select allOpen in new window

 

by: shivaspkPosted on 2008-05-25 at 15:41:47ID: 21643862

Ok as you use eclipse, lets test if the web service is up and running , use Eclipse web service explorer for this task , here is my personal tutorial,

http://soa2world.blogspot.com/2008/05/soap-client-eclipse-web-service.html

once if this is successful later we can concentrate on writing the client.

Can you also provide outputs of various system outs which you have put in the Client class.

 

by: shivaspkPosted on 2008-05-25 at 15:46:27ID: 21643870

also one more thing don't use

@SOAPBinding(style = Style.RPC)

Thats to Expose a RPC style service, which is not preferable in fact JAX WS has the no proper support for those type of services.  When you remove the above on you will get a Document/literal style web service which are considered best.

 

by: jrwalker2Posted on 2008-05-25 at 16:19:05ID: 21643939

I removed the @SOAPBinding statement. I also was able to see the wsdl in the web services explorer in eclipse. When I try to test the echo method (with the string "test"), I get the following exception:

The SOAP response failed schema validation. Please switch to the source view for the SOAP response in XML format.

SOAP Request Envelope:    
------------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://webservice.samples.whp.spc.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
 <ns0:echo>
  <arg0>test</arg0> 
  </ns0:echo>
  </soapenv:Body>
  </soapenv:Envelope>
 
SOAP Response Envelope:    
------------------------
The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 
 
XML document must have a top level element. Error processing resource 'http://localhost:51774/wsexplorer/wsdl/soap_envelope...
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: shivaspkPosted on 2008-05-25 at 16:23:18ID: 21643953

Oh man thats wired, why didn't it show up the SOAP Response? any way did u get any exception on the server end when you made this request?.

 

by: jrwalker2Posted on 2008-05-25 at 16:31:40ID: 21643977

Yes. I get the following error output from my JBoss server when I make the request:


16:31:23,171 ERROR [ContainerBase] Servlet.service() for servlet EchoBean threw exception
java.lang.NoClassDefFoundError
        at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:64)
        at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:120)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:125)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:97)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:255)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:179)
        at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:192)
        at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:502)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.intuit.spc.bhp.logging.LoggingFilter.doFilter(LoggingFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)

 

by: shivaspkPosted on 2008-05-25 at 16:49:55ID: 21644012

I think the EchoBean is unable to find the remote class

can you change this from

@WebService(endpointInterface = "com.spc.whp.samples.webservice.Echo")
@Remote(Echo.class)

to

@WebService(endpointInterface = "com.spc.whp.samples.webservice.Echo")
@Remote(com.spc.whp.samples.webservice.Echo.class)

Also before going any further I just want to know what exactly you are trying to do? are you trying to create a stateless session bean which is also exposed as a web service??

if thats the case then your remote interface class is inappropriate your classes must look like this

Try the below code only if my above change specified is failing because I have not done much coding in EJB 3 :)

Echo
---------
package com.spc.whp.samples.webservice;
 
import java.rmi.Remote;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
 
@WebService
@Remote
public interface Echo extends Remote {
        String echo(String e);
}
 
EchoBean
---------
package com.spc.whp.samples.webservice;
 
 
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.jws.WebService;
 
@Stateless
@WebService(endpointInterface = "com.spc.whp.samples.webservice.Echo")
public class EchoBean implements Echo{
        public String echo(String e) {
                return "Web Service Echo + " + e;
        }
}
 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:

Select allOpen in new window

 

by: jrwalker2Posted on 2008-05-25 at 17:24:40ID: 21644087

Yes. My goal is to create a stateless session ejb that is exposed as a web service. I originally followed this example (http://www.regdeveloper.co.uk/2007/01/23/ejb_web_services/). I tried your first suggestion, but I got the same error as before. So I tried your second suggestion...

There was an error at the line (@Remote) in the Echo interface ("Type mismatch: cannot convert from Remote to Annotation"). So I commented it out.

I'm very confused why this is happening, but I am getting the following error from jboss.

Notes on what I have done previously:
1. jboss-common-client.jar is built inside of my jar file. I do this because I got an exception that said that the the Logger could not be found
2. jboss-saaj.jar was copied from <JBOSS_HOME>\client to <JBOSS_HOME>\lib\endorsed
3. Installed jre is jre1.6.0_06
4. JAVA_HOME environment variable is C:\Program Files\Java\jdk1.5.0_10
5. CLASSPATH environment variable is
.;C:\Program Files\Java\jre1.5.0_10\lib\ext\QTJava.zip;C:\Documents and Settings\jwalker1\Desktop\javaee.jar;
6. This is what jboss outputs when it first starts up:

===============================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: C:\jboss\jboss-4.2.0CP02-2.1.2.0-SNAPSHOT

  JAVA: C:\Program Files\Java\jdk1.5.0_10\bin\java

  JAVA_OPTS: -Denv.token=dev  -Dprogram.name=run.bat -server -Xms128m -Xmx512m -XX:MaxPermSize=128m  -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000

  CLASSPATH: C:\Program Files\Java\jdk1.5.0_10\lib\tools.jar;C:\jboss\jboss-4.2.0CP02-2.1.2.0-SNAPSHOT\bin\run.jar

===============================================================================






17:11:16,125 ERROR [ContainerBase] Servlet.service() for servlet EchoBean threw exception
java.lang.NoClassDefFoundError
        at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:64)
        at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:120)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:125)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:97)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:255)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:179)
        at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:192)
        at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:502)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.intuit.spc.bhp.logging.LoggingFilter.doFilter(LoggingFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)


 

by: shivaspkPosted on 2008-05-25 at 18:59:53ID: 21644319

Here is a complete code I developed and executed successfully in Glass fish try in Jboss later we can see if we face any issues.

Note:

1) BeanLocal class may not be any use it was auto generated.
2) if you see the remote definition you can @web service and @Remote are added they are must for successful deployment of EJB and web service.

------------------EchoBean ------------------
package test;
 
import javax.ejb.Stateless;
import javax.jws.WebService;
 
/**
 *
 * @author Siva Prasanna
 */
@Stateless
@WebService(endpointInterface = "test.EchoBeanRemote")
public class EchoBean implements EchoBeanRemote, EchoBeanLocal {
 
    public String echo(String in) {
       return "Web Service Echo: "+in;
    }
}
 
-----------------EchoBeanLocal ------------------
package test;
 
import javax.ejb.Local;
 
/**
 *
 * @author Siva Prasanna
 */
@Local
public interface EchoBeanLocal {
    
}
 
------------------------EchoBeanRemote --------------------
package test;
 
import javax.ejb.Remote;
import javax.jws.WebService;
 
/**
 *
 * @author Siva Prasanna
 */
@Remote
@WebService
public interface EchoBeanRemote {
    String echo(String in);
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: jrwalker2Posted on 2008-05-25 at 19:42:29ID: 21644406

I really think that I am missing some configuration with JBoss, because even with your code, I get the following error:

19:41:55,734 ERROR [ContainerBase] Servlet.service() for servlet EchoBean threw exception
java.lang.NoClassDefFoundError
        at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:64)
        at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:120)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:125)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:97)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:255)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:179)
        at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:192)
        at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:502)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.intuit.spc.bhp.logging.LoggingFilter.doFilter(LoggingFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)

 

by: jrwalker2Posted on 2008-05-25 at 19:47:18ID: 21644413

The following is my build.xml file for creating the jar file:
---------------------------------------------------------------------
<?xml version="1.0"?>
<project name="FatJar whp-samples-soapui_fat.jar (experimental)" default="main" basedir=".">

        <property name="fjepPath" value="plugins/net.sf.fjep.fatjar_0.0.25/fatjar.jar"/>
        <taskdef name="fatjar.build" classname="net.sf.fjep.anttask.FJBuildTask" classpath="${fjepPath}"/>
        <typedef name="fatjar.manifest" classname="net.sf.fjep.anttask.FJManifestType" classpath="${fjepPath}"/>
        <typedef name="fatjar.exclude" classname="net.sf.fjep.anttask.FJExcludeType" classpath="${fjepPath}"/>
        <typedef name="fatjar.jarsource" classname="net.sf.fjep.anttask.FJJarSourceType" classpath="${fjepPath}"/>
        <typedef name="fatjar.filesource" classname="net.sf.fjep.anttask.FJFileSourceType" classpath="${fjepPath}"/>

    <target name="main">
        <fatjar.build output="whp-samples-soapui_fat.jar">
            <fatjar.manifest/>
            <fatjar.filesource path="C:\Documents and Settings\jwalker1\whp-samples-soapui\target\classes" relpath=""/>
            <fatjar.jarsource file="C:\Documents and Settings\jwalker1\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar" relpath=""/>
            <fatjar.jarsource file="C:\Documents and Settings\jwalker1\Desktop\javaee.jar" relpath=""/>
            <fatjar.jarsource file="C:\jboss\jboss-4.2.0CP02-2.1.2.0-SNAPSHOT\client\jboss-common-client.jar" relpath=""/>
        </fatjar.build>
    </target>
</project>

 

by: shivaspkPosted on 2008-05-25 at 19:47:34ID: 21644416

which version of Jboss are you using?
 
and how are you deploying these? you need to have EAR and deploy that in Jboss are you doing this?

 

by: jrwalker2Posted on 2008-05-25 at 19:50:32ID: 21644419

I using jboss-4.2.0

Is there an easy way to create an ear file? Maven 2 maybe?

 

by: shivaspkPosted on 2008-05-25 at 19:53:22ID: 21644426

EJB's are supposed to be packaged in EAR (Enterprise Archives) for deploying under any application server. you are trying to deploy only the EJB jar only? ya I had done that in WAS and Web logic long long back, any way make sure you are doing similar to this tutorial

http://java.boot.by/scbcd5-guide/apbs07.html

 

by: jrwalker2Posted on 2008-05-25 at 20:13:56ID: 21644468

Thanks for your help shivaspk, but I still get the same exception as before even after packaging the jar inside of an ear file.


20:11:34,781 ERROR [ContainerBase] Servlet.service() for servlet EchoBean threw exception
java.lang.NoClassDefFoundError
        at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:64)
        at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:120)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:125)
        at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:97)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:255)
        at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:179)
        at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:192)
        at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:502)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.intuit.spc.bhp.logging.LoggingFilter.doFilter(LoggingFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)

 

by: jrwalker2Posted on 2008-05-25 at 20:14:22ID: 21644469

Any additional suggestions are greatly appreciated,

 

by: jrwalker2Posted on 2008-05-25 at 21:07:58ID: 21644594

I'm having trouble viewing the xml.

Is this the correct url (because I can't see the xml in the browser)?

http://localhost:8080/EchoBeanRemote/EchoBean?wsdl

 

by: jrwalker2Posted on 2008-05-25 at 21:23:48ID: 21644608

Sorry. It is the same url:

http://localhost:8080/EchoBeanService/EchoBean?wsdl

I am confused as to where the "EchoBeanService" in the url comes from.

 

by: shivaspkPosted on 2008-05-26 at 08:09:10ID: 21646754

yes that the URL : http://localhost:8080/EchoBeanService/EchoBean?wsdl

This will be created by these as default

@WebService(endpointInterface = "test.EchoBeanRemote")
public class EchoBean implements EchoBeanRemote, EchoBeanLocal {

you can change the service name using serviceName="yourserviceName"

is the service up and running?

 

by: jrwalker2Posted on 2008-05-26 at 13:28:56ID: 21647957

Yes I got it up and running...I had a corrupt installation of jboss. Thanks for all your help

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...