-
15. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
moweis Aug 4, 2008 7:53 AM (in response to moweis)Yes JBOSS_HOME is set.
What should my classpath be?
All I currently have in my classpath are 4 locations
1) current directory so that I can access my Client
2) parent directory of META-INF/wsrm-jaxws-endpoint-config.xml
3) directory for my generated classes from wscompile
4) {$JBOSSWS_HOME}/deploy/lib/jbossws-native-core.jar
Am I missing anything? -
16. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
ropalka Aug 4, 2008 8:30 AM (in response to moweis)Yes, you have to ensure (using proper endorsing setup) that jbossws jaxws api will be used instead of jaxws that is distributed with the JVM.
-
17. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
ropalka Aug 4, 2008 8:42 AM (in response to moweis)Try to add this piece of code to your client source:
URL jaxwsThatIsUsed = javax.xml.ws.Service.class.getProtectionDomain().getCodeSource().getLocation(); System.out.println("JAXWS that is used: " + jaxwsThatIsUsed);
and send me your console output. -
18. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
moweis Aug 4, 2008 9:17 AM (in response to moweis)getCodeSource is returning a null, so I'm unable to call getLocation
I really appreciate your help.
I'm trying to run the example now on my PC, to see if I run into the same problems (I currently running it on a mac). -
19. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
moweis Aug 4, 2008 11:57 AM (in response to moweis)Hi Richard,
You were right.
I went ahead and added all the jboss/jbossws jars to my classpath, and I no longer get the cannot be cast exception.
However, I get a new exception now:Exception in thread "main" org.jboss.ws.extensions.wsrm.api.RMException: Unable to create WSRM sequence
at org.jboss.ws.core.jaxws.client.ClientImpl.createSequence(ClientImpl.java:563)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152)
at $Proxy16.ping(Unknown Source)
at org.jboss.test.ws.jaxws.samples.wsrm.client.SimpleServiceTestCase.main(SimpleServiceTestCase.java:33)
Caused by: javax.xml.ws.WebServiceException: java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at org.jboss.ws.core.jaxws.client.ClientImpl.handleRemoteException(ClientImpl.java:410)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:316)
at org.jboss.ws.core.jaxws.client.ClientImpl.createSequence(ClientImpl.java:550)
... 4 more
Caused by: 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:84)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:171)
at org.jboss.ws.core.CommonSOAP11Binding.createMessage(CommonSOAP11Binding.java:59)
at org.jboss.ws.core.CommonSOAPBinding.bindRequestMessage(CommonSOAPBinding.java:158)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:292)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:304)
... 5 more
Here is my client code:package org.jboss.test.ws.jaxws.samples.wsrm.client; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import org.jboss.ws.core.StubExt; import org.jboss.ws.extensions.wsrm.api.RMProvider; import org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService; public final class SimpleServiceTestCase { private static final String serviceURL = "http://localhost:8080/jaxws-samples-wsrm/SimpleService"; public static void main(String[] args) throws Exception { String url = null; if ( args != null && args.length > 0 && args[0] != null ) url = args[0]; else url = serviceURL; System.out.println("Calling wsdl"); QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService"); QName portName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleServicePort"); URL wsdlURL = new URL(url + "?wsdl"); Service service = Service.create(wsdlURL, serviceName); SimpleService proxy = (SimpleService)service.getPort(SimpleService.class); ((StubExt)proxy).setConfigName("Standard Anonymous WSRM Client", "META-INF/wsrm-jaxws-client-config.xml"); proxy.ping(); // one way call proxy.echo("Hello World!"); // request responce call ((RMProvider)proxy).closeSequence(); } }
-
20. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
moweis Aug 4, 2008 12:32 PM (in response to moweis)
Richard,
Ok, got it working.
You were right all long regarding the classpath.
Thanks for your help and patience! -
21. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 8, 2008 8:27 AM (in response to moweis)Hello,
I had the exact same problem and got as far as fixing the StubExt issue, but now I am stuck at the "Unable to create WSRM sequence" exception.
How did you fix that? My classpath seems to be correct. Here's the client:public void pingTest() { System.err.println("java.class.path: " + System.getProperty("java.class.path")); System.err.println("java.endorsed.dirs: " + System.getProperty("java.endorsed.dirs")); URL jaxwsThatIsUsed = javax.xml.ws.Service.class.getProtectionDomain() .getCodeSource().getLocation(); System.out.println("JAXWS that is used: " + jaxwsThatIsUsed); ssp.ping("test"); }
The output is:JAXWS that is used: file:/D:/Programs/jboss/as0/jboss-4.2.3.GA/client/jbossws-native-jaxws.jar java.class.path: [lots of stuff...];D:\Programs\jboss\as0\jboss-4.2.3.GA\client\jbossws-native-core.jar;[...more stuff];D:\Programs\jboss\as0\jboss-4.2.3.GA\lib\endorsed\serializer.jar;D:\Programs\jboss\as0\jboss-4.2.3.GA\lib\endorsed\xalan.jar;D:\Programs\jboss\as0\jboss-4.2.3.GA\lib\endorsed\xercesImpl.jar java.endorsed.dirs: D:\Programs\jboss\as0\jboss-4.2.3.GA\lib\endorsed
What did I miss? -
22. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 8, 2008 8:33 AM (in response to moweis)Actually, I don't have the exact same problem. My exception is;
org.jboss.ws.extensions.wsrm.api.RMException: Unable to create WSRM sequence at org.jboss.ws.core.jaxws.client.ClientImpl.createSequence(ClientImpl.java:563) at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170) at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152) at $Proxy21.ping(Unknown Source) at test.ws.stationsService.StationsServiceTest.pingTest(StationsServiceTest.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.jboss.ws.WSException: Cannot obtain operation meta data for: {http://docs.oasis-open.org/ws-rx/wsrm/200702}CreateSequence at org.jboss.ws.core.CommonClient.getOperationMetaData(CommonClient.java:203) at org.jboss.ws.core.CommonClient.getOperationMetaData(CommonClient.java:184) at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:309) at org.jboss.ws.core.jaxws.client.ClientImpl.createSequence(ClientImpl.java:550) ... 24 more
-
23. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 11, 2008 4:50 AM (in response to moweis)Ok, I've got WS-ReliableMessaging to work. The problem was that the WS-Policy information had to be removed from the WSDL and put into a separate file, using the @PolicyAttachment annotation to refer to it.
The tutorial at http://jbws.dyndns.org/mediawiki/index.php?title=Native_WS-ReliableMessaging_Tutorial imports the WS-Policy namespace in the WSDL file and embeds the policy there. But JBoss generates and publishes its own WSDL for the web service, using the information from the annotations.
The solution can be found at: http://jbws.dyndns.org/mediawiki/index.php?title=WS_Reliable_Messaging
You need to create a separate XML file (e.g. wsrm-exactly-once-in-order-policy.xml) containing the policy:<?xml version="1.0" encoding="UTF-8"?> <wsp:Policy wsu:Id="exactly_one_in_order_rm_delivery" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsrmp:DeliveryAssurance> <wsp:Policy> <wsrmp:ExactlyOnce/> <wsrmp:InOrder/> </wsp:Policy> </wsrmp:DeliveryAssurance> </wsp:Policy>
Then, in the web service implementation, use annotations to link that policy to the web service:@WebService @EndpointConfig( configFile = "META-INF/wsrm-jaxws-endpoint-config.xml", configName = "Standard WSRM Endpoint" ) @PolicyAttachment(@Policy( policyFileLocation = "META-INF/wsrm-exactly-once-in-order-policy.xml", scope = PolicyScopeLevel.WSDL_BINDING) ) public class MyRMService { ...
-
24. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
ropalka Aug 11, 2008 4:59 AM (in response to moweis)"karypid" wrote:
Ok, I've got WS-ReliableMessaging to work. The problem was that the WS-Policy information had to be removed from the WSDL and put into a separate file, using the @PolicyAttachment annotation to refer to it.
The tutorial at http://jbws.dyndns.org/mediawiki/index.php?title=Native_WS-ReliableMessaging_Tutorial imports the WS-Policy namespace in the WSDL file and embeds the policy there. But JBoss generates and publishes its own WSDL for the web service, using the information from the annotations.
This is the reason why tutorial specifieswsdlLocation = "WEB-INF/wsdl/SimpleService.wsdl"
in service endpoint (it forces JBossWS to don't generate the WSDL at runtime but use provided one instead). -
25. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 11, 2008 5:18 AM (in response to moweis)Understood. However, I can't get it to work. When I add the WSDL file to the META-INF/wsdl folder of my EJB jar (I use a stateless session bean to implement the web service and the "start from WSDL" approach via wsconsume), JBoss publishes the web service using a file:// URL. For instance, the following SLSB (notice that the PolicyFile annotation is commented out):
@Stateless @WebService(serviceName = "StationsService", wsdlLocation = "META-INF/wsdl/StationsService.wsdl", targetNamespace = "http://www.armoniq.com/StationsService/", endpointInterface = "com.armoniq.stationsservice.StationsServicePortType" ) @EndpointConfig(configFile = "META-INF/wsrm-jaxws-endpoint-config.xml", configName = "Standard WSRM Endpoint") //@PolicyAttachment(@Policy(policyFileLocation = "META-INF/wsrm-exactly-once-in-order-policy.xml", scope = PolicyScopeLevel.WSDL_BINDING)) public class StationsService implements StationsServicePortType { // Logger logger = Logger // .getLogger(StationsService.class.getClass().getName()); public void ping(String in) { System.out.println("Ping received with text: " + in); // logger.log(Level.INFO, "Ping received with text: " + in); } }
Causes JBoss to publish this WSDL:<wsdl:definitions name="StationsService" targetNamespace="http://www.armoniq.com/StationsService/" xmlns:echoes="http:/www.armoniq.com/echoes/2008/core" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.armoniq.com/StationsService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <xsd:schema targetNamespace="http://www.armoniq.com/StationsService/"> <xsd:import namespace="http:/www.armoniq.com/echoes/2008/core" schemaLocation="http://localhost:8080/myrm.ear-myrm.ws.impl/StationsService?wsdl&resource=myrm.base.xsd"/> <xsd:element name="ping"> <xsd:complexType> <xsd:sequence> <xsd:element name="in" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types> <wsdl:message name="pingRequest"> <wsdl:part element="tns:ping" name="parameters"/> </wsdl:message> <wsdl:portType name="StationsServicePortType"> <wsdl:operation name="ping"> <wsdl:input message="tns:pingRequest"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="StationsServiceSOAP" type="tns:StationsServicePortType"> <wsp:PolicyReference URI="#wsrm11policy"/> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="ping"> <soap:operation soapAction="http://www.armoniq.com/StationsService/fetchSchedule"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> </wsdl:operation> </wsdl:binding> <wsdl:service name="StationsService"> <wsdl:port binding="tns:StationsServiceSOAP" name="StationsServicePort"> <soap:address location="file://localhost:8080/myrm.ear-myrm.ws.impl/StationsService"/> </wsdl:port> </wsdl:service> <wsp:UsingPolicy/> <wsp:Policy wsu:Id="wsrm11policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsp:All> <wsp:ExactlyOne> <wsp:All> <ns1:RMAssertion xmlns:ns1="http://docs.oasis-open.org/ws-rx/wsrmp/200702"/> <ns2:UsingAddressing xmlns:ns2="http://www.w3.org/2006/05/addressing/wsdl"/> </wsp:All> </wsp:ExactlyOne> </wsp:All> </wsp:Policy> </wsdl:definitions>
Notice the <soap:address> tag that uses file:// as a protocol.
Even in the jbossws management console (http://localhost:8080/jbossws/services) the link uses this address and clicking on it does not work. You have to copy the link from the web page, paste it to the address bar of the browser and replace file: with http: to get to the (incorrect) WSDL.
I am using JBoss 4.2.3 and JBossWS 3.0.2. -
26. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 11, 2008 6:57 AM (in response to moweis)Ok, I've finally found out what was wrong.
First of all, the tutorial is correct and everything should work fine
even without the @Policy annotation (provided of course you embed
your WS-Policy in the WSDL file).
Strange thing though:
When using "wsdLocation" in @WebService, JBoss reads the WSDL file you provided and does the following:
1) if the <soap:address> tag in the WSDL file has a "file://..." URL in it,
it does NOT replace it with the actual address where your web service
endpoint was bound.
2) if the <soap:address> tag in the WSDL file has an "http://..." URL in it,
it replaces it with the actual address where your web service
endpoint was bound.
I had the bad luck of having specified file://path/to/my/contract.wsdl causing the weird behavior.
I know this is totally unrelated to the topic of this thread by now, but I
wanted not to leave any lingering doubt regarding the approach without
@Policy (which I prefer by the way).
In any case, before I go running to JIRA, can someone explain if there's
some reason why JBoss won't touch the file:// address bindings and
therefore this is proper behavior, or would you consider this a bug? -
27. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
ropalka Aug 11, 2008 8:27 AM (in response to moweis)It's a bug
-
28. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Aug 11, 2008 8:56 AM (in response to moweis)In that case... https://jira.jboss.org/jira/browse/JBWS-2277
-
29. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
karypid Nov 11, 2009 4:13 AM (in response to moweis)I've added a patch that seems to fix this (in the most straight-forward, but also uneducated manner one can think of).