New to WS... Need help...
fil78 May 27, 2008 3:00 AMHello people,
I am very new to WS and I try to implement simpliest WS based on EJB3 and I get exception... Please, could somebody tell me what am I doing wrong?
Here is my code:
Bean:
import javax.ejb.Remote; import javax.ejb.Stateless; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; @Stateless @Remote(ProfileMgmtRemote.class) @WebService @SOAPBinding(style = SOAPBinding.Style.RPC) public class ProfileMgmtBean { @WebMethod public int summ(int a, int b){ return a+b; } }
Interface:
public interface ProfileMgmtRemote { public int summ(int a, int b); }
and client:
import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import com.tsystems.web.services.sample.ProfileMgmtRemote; public class WSClient { private String endpointURL = "http://127.0.0.1:8080/WebServiceProject/ProfileMgmtBean?wsdl"; private String targetNS = "http://sample.services.web.tsystems.com/"; /** * @param args */ public static void main(String[] args) { WSClient wsc = new WSClient(); try { System.out.println(""); URL wsdlURL = new URL(wsc.endpointURL); QName serviceName = new QName(wsc.targetNS, "ProfileMgmtBeanService"); Service service = Service.create(wsdlURL, serviceName); ProfileMgmtRemote inst = (ProfileMgmtRemote)service.getPort(ProfileMgmtRemote.class); System.out.println("And summ = " + inst.summ(1, 1)); } catch (MalformedURLException e) { e.printStackTrace(); } } }
Finally I get the following stack trace:
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to load Provider: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl at javax.xml.ws.spi.Provider.provider(Provider.java:90) at javax.xml.ws.Service.<init>(Service.java:81) at javax.xml.ws.Service.create(Service.java:98) at com.tsystems.test.client.WSClient.main(WSClient.java:28) Caused by: java.lang.IllegalStateException: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:96) at javax.xml.ws.spi.Provider.provider(Provider.java:82) ... 3 more Caused by: java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:91) ... 4 more Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference. at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:188) at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:65) ... 11 more Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions Two classes have the same XML type name "address". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address com.sun.xml.ws.developer.MemberSubmissionEndpointReference.addr at com.sun.xml.ws.developer.MemberSubmissionEndpointReference this problem is related to the following location: at javax.xml.ws.wsaddressing.W3CEndpointReference$Address at private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address at javax.xml.ws.wsaddressing.W3CEndpointReference Two classes have the same XML type name "elements". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties at com.sun.xml.ws.developer.MemberSubmissionEndpointReference this problem is related to the following location: at javax.xml.ws.wsaddressing.W3CEndpointReference$Elements at private javax.xml.ws.wsaddressing.W3CEndpointReference$Elements javax.xml.ws.wsaddressing.W3CEndpointReference.referenceParameters at javax.xml.ws.wsaddressing.W3CEndpointReference at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211) at javax.xml.bind.ContextFinder.find(ContextFinder.java:372) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522) at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:186) ... 12 more
I am using JBoss 4.2.2.GA and jbossws-3.0.1-native-2.0.4.GA.
Thanx for help.