|
Replies:
87
-
Last Post:
Dec 2, 2008 10:01 AM
by: cgage
|
|
|
|
|
|
|
Spring support in JAX-WS
Posted:
Jan 29, 2007 2:47 PM
|
|
|
Originally posted as http://weblogs.java.net/blog/kohsuke/archive/2007/01/spring_support.html
I'm seeing a lot of comments, and doing Q&A on the blog comment section is hard, so redirecting people to post their questions here.
You can "watch" a thread to be notified whenever someone posts a new message to your post.
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jan 29, 2007 4:47 PM
in response to: kohsuke
|
|
|
I fixed the problem anthavio reported. It turns out that on web application Spring always validates (by XSD) the bean definition file, whereas my test bed didn't.
So this revealed several bugs that I haven't caught before as well as some bugs in XBean code --- XBean isn't apparently as stable as I'd like it to be (like https://issues.apache.org/jira/browse/XBEAN-73).
Anyway, things are back into the shape. The test application started running again.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jan 30, 2007 12:03 PM
in response to: kohsuke
|
|
|
(accidentally posted the same text twice)
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 1, 2007 8:45 AM
in response to: kohsuke
|
|
|
I'm running into a problem trying to use this. I downloaded the spring-core-1.0-SNAPSHOT.jar (revision 181) from the repository (still can't build correctly from mvn for some reason).
When I deploy my app, I get the following error:
11:36:02 ERROR ContextLoader - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Line 1 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. Caused by: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
I found if I comment out the wss:bindings tag (and its descendants) in my applicationContext.xml file, it no longer complains.
Any ideas of what's going on?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 1, 2007 2:21 PM
in response to: cmoesel
|
|
|
The "White spaces are required between publicId and systemId." error happens when the jar doesn't contain the right schema files. This apparently happens if I run "mvn deploy" instead of "mvn clean deploy".
I must have pushed the wrong version to the repo.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 1, 2007 9:08 AM
in response to: kohsuke
|
|
|
I figured I'd also post the error I get when trying to build. If I run "mvn clean package" from the "jax-ws-commons/spring" directory, it fails on the tests.
Here's what it reports in "jax-ws-commons/spring/spring-core/target/surefire-reports/ToyTest.txt":
------------------------------------------------------------------------------- Test set: ToyTest ------------------------------------------------------------------------------- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.499 sec <<< FAILURE! test1(ToyTest) Time elapsed: 0.483 sec <<< ERROR! org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jax-ws.http' defined in class path resource [config.xml]: Cannot create inner bean '(inner bean)' while setting bean property 'bindings' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)' defined in class path resource [config.xml]: Cannot resolve reference to bean 'simplestService' while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simplestService': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: com.sun.xml.stream.buffer.MutableXMLStreamBuffer.setSystemId(Ljava/l]
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 1, 2007 2:22 PM
in response to: cmoesel
|
|
|
Looks like there's some versioning issue withxmlstreambuffer.jar. Maybe we need to post a newer version there. Thanks for the info.
|
|
|
|
|
|
|
|
Bad jar naming
Posted:
Feb 1, 2007 10:29 PM
in response to: kohsuke
|
|
|
suppose a project would like to depend on springframework's module named 'spring-core' and also your spring project.
Then we see these jars side by side: spring-core-1.0-SNAPSHOT.jar <-- jaxws-commons spring spring-core-2.0.2.jar <-- part of official spring module
Rather confusing - suggest you change the name of your jar.
Looking forward to seeing this project working.
|
|
|
|
|
|
|
|
Re: Bad jar naming
Posted:
Feb 2, 2007 4:39 PM
in response to: plynch
|
|
|
Ah, good point. Yeah, this is terrible.
I'll change the artifactId. Maybe jax-ws-spring, or something like that.
|
|
|
|
|
|
|
|
Re: Bad jar naming
Posted:
Feb 6, 2007 5:22 AM
in response to: mieleton
|
|
|
My bad, found out the correct files now 
Continuing my testing....
|
|
|
|
|
|
|
|
Re: Bad jar naming
Posted:
Feb 8, 2007 2:15 PM
in response to: kohsuke
|
|
|
I changed the artifactId to jaxws-spring.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 7, 2007 6:46 AM
in response to: mieleton
|
|
|
The schema files should be inside our spring extension jar, and remote references will be redirected to your local copy.
But I should still copy these xsds to those locations. If you can file an issue for this in http://jax-ws-commons.dev.java.net/issues/ that would be very helpful.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 7, 2007 9:12 AM
in response to: kohsuke
|
|
|
Hello...
I'm trying to specify the primary WSDL, but am having a hard time doing so. In one of the pre-1.0 versions of the spring support extension, I think I was able to do it like this:
<ws:primaryWsdl> <bean class="java.lang.String"> <constructor-arg> <value>WEB-INF/wsdl/MyService.wsdl</value> </constructor-arg> </bean> </ws:primaryWsdl>
I came to this solution via trial and error. Now, however, I get an error with the same config: com.sun.xml.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(WEB-INF/wsdl/MyService.wsdl)
If I just switch the value to "MyService.wsdl" instead of "WEB-INF/wsdl/MyService.wsdl", I get a different error: java.lang.IllegalArgumentException: Unknown type MyService.wsdl
Could you please advise on how to use this feature?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 8, 2007 3:16 AM
in response to: cmoesel
|
|
|
Looks like there was an 'else' forgetten in the code ;-):
public void setPrimaryWsdl(Object primaryWsdl) throws IOException { if(primaryWsdl instanceof String) { this.primaryWsdl = convertStringToSource((String)primaryWsdl); } else if(primaryWsdl instanceof URL) { this.primaryWsdl = SDDocumentSource.create((URL)primaryWsdl); } else if(primaryWsdl instanceof SDDocumentSource) { this.primaryWsdl = (SDDocumentSource) primaryWsdl; } throw new IllegalArgumentException("Unknown type "+primaryWsdl); }
On settign a primaryWsdl the illegalArgumentException will always be thrown...
This code was from the 1.0-source jar
Regards, Robert
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 8, 2007 4:54 AM
in response to: willemsrb
|
|
|
Good catch, Robert.
Thanks for digging into the code-- I had taken a quick glance at it but somehow missed that the exception is always thrown (doh!). I guess I'll just recompile a new jar for it for now. Usually Kohsuke's pretty good about getting fixes in fast, so I suspect this will be in a nightly real soon.
Yet another thing... that could not have happened... if it was closed source!
Thanks again! Chris
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 8, 2007 2:09 PM
in response to: willemsrb
|
|
|
Thanks for finding this. I just commited a fix.
Would be interested in becoming a developer on the project? That would allow you to make this kind of changes without waiting for me.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 16, 2007 7:08 AM
in response to: kohsuke
|
|
|
Hi Kohsuke,
thanks for the offer, but unfortunately, i'm too busy with my own work at the moment to be much of help... but if i find anything, i'll share...
Regards, Robert
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 19, 2007 3:33 PM
in response to: willemsrb
|
|
|
Even with the new 1.1 code I cant get the primaryWsdl to work. The input Object is of type QName when it calls the setPrimaryWsdl method so it drops through to the IllegalArgumentException. Any suggestions?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 8, 2007 5:35 AM
in response to: kohsuke
|
|
|
Hi,
got it working (after a few hours hitting my keyboard ;-)) and it is really super! Integration with Spring is working like a charm... We're now going from XFire to JAXWS (XFire had a big bug regarding soap headers)... Thanks Kohsuke!!!
However when i try to add a @HandlerChain(file="xxx") on my service implementation class the log gives the following warning:
Container org.jvnet.jax_ws_commons.spring.SpringService$ContainerWrapper@110ded doesn't support class com.sun.xml.ws.api.server.Module
Any idea how to get this working? It works when not using Spring to configure the webservices... (the original sun-jaxws.xml file)
Thanks in advance....
Regards,Robert
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 8, 2007 2:16 PM
in response to: willemsrb
|
|
|
The warning is not much to do with the handler chain, but I put a fix to this. I'll be releasing 1.1 now.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 9, 2007 6:44 AM
in response to: kohsuke
|
|
|
Kohsuke,
Again, thank you for all of your hard work and your promptness at fixing things. I don't know if you were asking me or Robert about being added as a developer. If you'd like to add me you may, but truthfully, I doubt I'd commit much at this point. But if I come across another easy fix like that, I'd certainly be happy to take care of it. It's up to you.
Unfortunately, it looks like you only pushed the 1.1 javadoc and schema to the maven repository. I expect you also intended to push out the jar?
-Chris
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 9, 2007 4:43 PM
in response to: cmoesel
|
|
|
Apparently the push wasn't complete. I should be fixed now. I added you as a developer, so feel free to make a quick fix like that.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 9, 2007 7:38 AM
in response to: kohsuke
|
|
|
Hi Kohsuke,
It looks like the two XSD documents have changed since 1.0 and now the previously working configuration no longer works (doesn't validate against XSDs). I tried to find the source of this myself, but I don't know xbeans well enough to figure it out.
In spring-jax-ws-core.xsd (line 208) and spring-jax-ws-servlet.xsd (lines 28 and 73), the line: <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded' /> has changed to: <xs:any namespace='##other'/>
Now the configuration *requires* an extra element from another namespace! Whoops. Anyway, as I said, I don't know how to fix this in the code, since I think those XSDs are generated by xbean. But I wanted to point it out.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 9, 2007 4:45 PM
in response to: cmoesel
|
|
|
I actually thought I fixed that bug --- to fix that bug I even created a forked maven-xbean-plugin.
Where did you find those XSDs? As far as I can tell, they do have @minOccurs and @maxOccurs.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 12, 2007 5:14 AM
in response to: kohsuke
|
|
|
Hi Kohsuke,
I did an svn update and then a mvn clean package from the spring directory. The resulting jar file had the bad XSDs in it (they were also in target/classes). Note, this is from the most current code in SVN, not necessarily the 1.1 release.
Just did one more svn up and mvn clean install to be sure and still got the faulty XSDs.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 14, 2007 2:21 PM
in response to: plynch
|
|
|
I thought this is an error that happens when XSD files are not packaged in the jar properly, or otherwise when Spring fails to resolve schema references locally.
Then Spring tries to fetch XSD from the remote website, which returns an error HTML page, and obviously it fails to parse as XML.
I applied your patch, but I thought the real fix is to upload the schemas to the website.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 15, 2007 7:00 AM
in response to: kohsuke
|
|
|
I did this 1. Download jaxws-spring-1.1.jar 2. Extract spring-jax-ws-core.xsd.html 3. Fix javadoc comments that are inserted into spring-jax-ws-core.xsd.html which contain unescaped '>' 4. Insert corrected spring-jax-ws-core.xsd.html back into jar file. 5. Try to load the test app war again with the new jar file included. It now works and doesn't throw the SAXParseException.
-Peter
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 15, 2007 5:49 PM
in response to: plynch
|
|
|
Thanks. I updated the site.
I'll push the new version shortly.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 15, 2007 6:11 PM
in response to: kohsuke
|
|
|
Somehow I got exception on my configuration:
14:28:46,332 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://jax-ws.dev.java.net/spring/servlet]
Can anyone give me some insights?
Thanks a lot.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 15, 2007 6:49 PM
in response to: jessie_zh
|
|
|
I think I know the problem. I just migrated to spring2, but somehow there is an old version of spring still there.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 16, 2007 7:14 AM
in response to: jessie_zh
|
|
|
Hi,
i thought i saw this aswell... i think i solved it then by adding the xbean-2.2.0.jar and xbean-spring-2.7.jar dependencies...
Regards, Robert
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 26, 2007 4:52 AM
in response to: kohsuke
|
|
|
Spring support for JAX-WS service endpoints seems to be working quite nicely.
However, is there a service client mechanism that would allow for spring to inject a port into a managed bean?
I suppose I'm looking for something like the XFire's XFireClientFactoryBean (http://www.mail-archive.com/cxf-user@incubator.apache.org/msg00087.html)
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 12:33 PM
in response to: rtiernay
|
|
|
There is already @WebServiceRef in the API and Java EE 5 injects those into the managed beans. Probably we could use the spring to do it.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 3:08 PM
in response to: jitu
|
|
|
No, we don't have any leverage on Spring development to have them understand a JavaEE annotation.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 3:12 PM
in response to: rtiernay
|
|
|
We should be able to do something similar.
Are we trying to inject Service, or port?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 4:07 PM
in response to: kohsuke
|
|
|
In @WebServiceRef case, one can do both.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 26, 2007 8:00 PM
in response to: kohsuke
|
|
|
Kohsuke,
What do you think of this:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2419
This issue stopped me from using jaxws-spring.
Glassfish developer is claiming the jaxws_commons-spring use of com.sun.xml.ws.transport.http.servlet.WSServletDelegate
is not valid.
However I don't really have a work around for the stated exception.
Basically I could not get jaxws spring to work in Tomcat or Glassfish on JDK 1.6
..and if using WSServletDelegate in this way is not valid, where does that leave this project.
What one can do to get Spring working with jaxws is use the DefaultLocatorFactory model - although admittedly not that sexy it works.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 3:22 PM
in response to: plynch
|
|
|
Ah, so this is what that is all about.
Plynch, we've been puzzled why you are trying to use WSServletDelegate. You really should have mentioned the spring support upfront so that we know you are just creating a test case that reveals the essence of the problem.
What Bhakti and Dhiru are saying is that WSServletDelegate is not meant for developers out there. They are meant for projects like jax-ws-commons.
I'll reopen the issue and talk to Bhati.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 3:24 PM
in response to: plynch
|
|
|
One more thing. Does this problem only happen in JDK6?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Feb 28, 2007 6:52 PM
in response to: kohsuke
|
|
|
I mentioned it twice in my comments in the bug that this affected jaxws-spring.
Sorry for the confusion, I merely wanted to provide the simplest test case possible to reproduce the issue in case configuring a complete jaxws spring test app would have been seen as too much work for the bug fixer.
I don't remember if I tried JDK 5. But I was able to reproduce the exact same issue with Tomcat 5.5.20, and 5.5.12 with JDK 6. I suppose you must have successfully run the test app on something so maybe you can tell me if it worked with JDK 5. jaxws-spring appears to have some satisfied users, which is why I struggled so long trying to resolve it. I ended up just going with the very simple ( and so far working ) DefaultLocatorFactory model spring provides to suck things into my SEI.
-Peter
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 1, 2007 10:49 AM
in response to: plynch
|
|
|
No, you've done the right thing. And thank you very much for trying to create a simplest possible test case. Much appreciated, and sorry for dropping the ball on our side.
For testing jaxws-spring I use Jetty, since it's better integrated to Maven.
In any case the bug is reopened, so let's see how it goes...
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 2, 2007 12:24 AM
in response to: kohsuke
|
|
|
A question on the handlers @PostConstruct and @PreDestroy annotations. The Webservice and both the handlers are working fine. ... <wss:service> <ws:service bean="#myService"> <ws:handlers> <ref bean="myLoggingHandler" /> <ref bean="mySoapHandler" /> </ws:handlers> </ws:service> </wss:service> ...
With the sun-jaxws.xml and Servlet both @PostConstruct and @PreDestroy works. With the jaxws-spring @PostConstruct works only for the WebService and not for the Handlers. @PreDestroy does not work for any. Is this a known issue ? These does'nt get called. Maybe I should look at the WSSpringServlet init and destroy methods ?
Do we need this in the init delegate.init(servletConfig);
and this in the destroy public void destroy() { if (delegate != null) { delegate.destroy(); } }
I am using RI 2.1 in tomcat. Is this supported in Glassfish.
|
|
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 5, 2007 5:46 PM
in response to: kohsuke
|
|
|
Thanks kohsuke. That is true, maybe I should let Spring handle the complete lifecycle. I will dig in to see why @PostConstruct worked for @Webservice.
In the WSSpringServlet why do we not have the delegate.init(servletConfig) in the init() and the delegate.destroy() in the destroy() methods.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 8, 2007 10:46 AM
in response to: alexj
|
|
|
I actually don't see delegate.init() call anywhere...
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 23, 2007 11:30 PM
in response to: kohsuke
|
|
|
I was comparing with the com.sun.xml.ws.transport.http.servlet.WSServlet init() and destroy() and WSSpringServlet and suspected that is why the @PostConstruct and @PreDestroy not working for the Handlers and @PreDestroy not for the WebService.
I have implemented using Spring way and works fine now.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 30, 2007 6:23 AM
in response to: kohsuke
|
|
|
Kohsuke - Can you have a look at this issue. Was trying to use XWSS for security in JAX-WS Spring Integration. With the xws-security.jar from JAX-WS or WSIT projects it does not pickup the server_security_config.xml. So I had a Security Handler and callback and it works. But with this solution from the client side the mustUnderstand=1 was failing. KumarJayanti suggested for JSE5 and JAX-WS there is no need for the Handler and using the latest xws-security.jar from XWSS3.0 at xwss.dev.java.net will have the extra SPI implementation that allows standalone XWSS (Non-WSIT) applications to work.
I tried and works fine with JSE5 and JAX-WS without the Spring integration. When using the Spring integration getting the following error. http://forums.java.net/jive/thread.jspa?messageID=210568#210568
Is there an easier way to use XWSS with Spring Integration I am missing. My plan is to implement WSIT once some other issues are solved when used with Tomcat.
Is there a plan to add XWSS support. We could have something like
<ws:features> <ws:xwsssecurity> <ref bean="xwssSecurityInterceptor" /> </ws:xwsssecurity> </ws:features>
<bean id="xwssSecurityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor"> <property name="policyConfiguration" value="classpath:wss-server-config.xml" /> <property name="callbackHandlers"> <list> <bean id="passwordValidationHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler"> <property name="users"> <props> <prop key="USERID1">PASSWORD1</prop> </props> </property> </bean> </list> </property> </bean>
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Apr 2, 2007 4:20 PM
in response to: alexj
|
|
|
I haven't figured out how to sort postings in date order, so it's becoming increasingly painful to find what's the new post in this thread. So please consider starting a new topic whenever you have issues with JAX-WS/Spring integration.
In the post referenced from your post, you say that the NPE occurs in:
>InputStream in = ctxt.getResourceAsStream(serverConfig);
What is that 'ctxt'? ServletContext? There's a bug filed in jaxws-spring this morning about jaxws-spring not injecting ServletContext properly. Could that be related? Or is it filed by you?
I think there's also another bug here. That is, XWSS shouldn't be relying on any particular transport, so if it can only work when ServletContext is not null, it has a problem. You should let Kumar know that.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 13, 2007 5:08 AM
in response to: kohsuke
|
|
|
Hi. I want to take a shot at this example (https://jax-ws-commons.dev.java.net/spring/) but got a nasty NPE. Together with the different hints for jars and schemas I now have a web project with
- spring.jar - commons-logging.jar - jaxb-imp.jar - jaxw-api.jar - jaxws-rt.jar - jaxws-spring-1.1.jar - xbean-spring-2.8.jar
in my web app class path. The runtime is Java SE 6, Tomcat 5.5 and the latest jax-ws 2.1.
My bean is simple:
package com.tutego.service;
public class GreeterService { public String greet( String name ) { return "Hello " + name + "!"; } }
And web.xml is standard too:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>SpringWeb</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list>
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param>
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
<servlet> <servlet-name>jaxws-servlet</servlet-name> <servlet-class> com.sun.xml.ws.transport.http.servlet.WSSpringServlet </servlet-class> </servlet>
<servlet-mapping> <servlet-name>jaxws-servlet</servlet-name> <url-pattern>/greet</url-pattern> </servlet-mapping>
</web-app>
The applicationContext.xml follows the suggestions with the namespace.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd">
<ws:service id="greeterService" impl="com.tutego.service.GreeterService" />
<wss:bindings id="jax-ws.http"> <wss:bindings> <wss:binding url="/greet" service="#greeterService" /> </wss:bindings> </wss:bindings>
</beans>
I thought this will be fine, but *boom*
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10e35d5: defining beans [date,greeterService,jax-ws.http]; root of factory hierarchy 13.03.2007 12:59:50 org.springframework.web.context.ContextLoader initWebApplicationContext SCHWERWIEGEND: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jax-ws.http' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean 'wss:binding#caf6c1' of type [com.sun.xml.ws.transport.http.servlet.SpringBinding] while setting bean property 'bindings' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wss:binding#caf6c1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'greeterService' while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'greeterService': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wss:binding#caf6c1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'greeterService' while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'greeterService': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'greeterService': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException Caused by: java.lang.NullPointerException at com.sun.xml.ws.server.EndpointFactory.getWsdlLocation(EndpointFactory.java:379) at org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.java:280) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectFromFactoryBean(AbstractBeanFactory.java:1226) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1191) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:211) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
Can anyone give me a hint?
Chris
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Mar 13, 2007 10:05 AM
in response to: ullenboom
|
|
|
The root cause of the problem is that your service endpoint class doesn't have @WebService annotation.
I fixed the spring support code to check for this error and report it.
|
|
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Apr 24, 2007 7:23 AM
in response to: kohsuke
|
|
|
I tried to get the example JAX-WS working on RAD7 but i am getting to following error:
Exception caught while initializing context Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: com/sun/xml/bind/api/JAXBRIContext.newInstance([Ljava/lang/Class;Ljava/util/Collection;Ljava/util/Map;Ljava/lang/String;ZLcom/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader;)Lcom/sun/xml/bind/api/JAXBRIContext; Caused by: java.lang.NoSuchMethodError: com/sun/xml/bind/api/JAXBRIContext.newInstance([Ljava/lang/Class;Ljava/util/Collection;Ljava/util/Map;Ljava/lang/String;ZLcom/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader;)Lcom/sun/xml/bind/api/JAXBRIContext;
As far as i can see it is missing the boolean c14nSupport in the call. I can't see how this is possible? Anyone some ideas. I am using the stockQuote example that has been provided.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Apr 24, 2007 6:57 PM
in response to: laonda
|
|
|
I suspect you have an old JAXB RI.
Maybe you are picking it up from the parent classloader inside containers. What container do you run?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Apr 25, 2007 2:23 AM
in response to: kohsuke
|
|
|
Thanks for the advice.
It was indeed a class loader problem. I changed the classloader to parent last and the server started up.
The problem is that if the classloader with the below settings it cant find the servlet: Stack Dump = javax.servlet.UnavailableException: SRVE0201E: Servlet [com.sun.xml.ws.transport.http.servlet.WSSpringServlet]: not a servlet class
* Server-specific Application Settings is on multiple, parent last * Application it self is on application class loader first, single class loader for application * Module is on application class loader first
I tried several settings but none seems to work. I found a simelar problem http://forum.springframework.org/showthread.php?t=33663 that advise to set the server-specific application setting to single. This will cause the admin consol to crash in my case. So thats not realy a solution. I will continue my search on this problem.
I removed the servlet-api-2.5.jar so it can use the websphere provided jar. If so i am getting a VerifyError:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': FactoryBean threw exception on object creation; nested exception is java.lang.VerifyError Caused by: java.lang.VerifyError
The post http://forums.java.net/jive/message.jspa?messageID=193093 defines the same problem. So it is probably a websphere issue.
Message was edited by: laonda
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Apr 25, 2007 10:52 AM
in response to: kohsuke
|
|
|
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 91 i n XML document from ServletContext resource [/WEB-INF/HistoricalData.xml] is inv alid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'wss:bindings'. One of '{"http: //jax-ws.dev.java.net/spring/servlet":service, WC[##other:"http://jax-ws.dev.jav a.net/spring/servlet"]}' is expected. Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'wss:bindings'. One of '{"http://jax-ws.dev.java.net/spri ng/servlet":service, WC[##other:"http://jax-ws.dev.java.net/spring/servlet"]}' i s expected.
Hey I get the following when having jaxws2.1 jaxws-spring-1-4.jar in my path.
Any ideas?
Regards,
Nick
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 15, 2007 2:42 PM
in response to: gregster
|
|
|
It looks like Spring is complaining that your document doesn't match with the schema. Can you paste the portion that it's complaining? (around line 91)
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 2, 2007 12:45 AM
in response to: kohsuke
|
|
|
Hello,
I want to implement web services with jax-ws 2. The project needing web services is being developed with Spring framework. Being new to web services I first implemented a simple web service with jax-ws without Spring. The application server is Tomcat 5.5 and the SDK is Java 5. All went quite nicely and I am happy how easily the web services can be implemented with jax-ws and with standard libraries.
But the problems started when I moved the implementation to the Spring framework. I followed the instructions in https://jax-ws-commons.dev.java.net/spring/ and used the jaxws-spring extension 1.4. There seem to be a lot of undocumented dependencies and I constantly have to find the newest (unstable) libraries. After solving one problem, I run into another. The latest one for example is "java.lang.NoClassDefFoundError: com/sun/istack/XMLStreamReaderToContentHandler" (with jaxws-rt version 2.1.2-SNAPSHOT - needed because some other problem).
So my question in the end is: can I implement jax-ws 2.0 (or 2.1) web services with Spring framework without jaxws-spring extension and how?
Thank you.
------- Not that relevant anymore, see http://forums.java.net/jive/message.jspa?messageID=215484#215484 instead.
Message was edited by: artsu
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 15, 2007 2:44 PM
in response to: artsu
|
|
|
I hear your pain. Some of us are trying to create a single download or "uberjar" that contains all the stuff you need. I guess you could have greatly benefited from that, right?
I'll pass this input along. I think we really need to do it.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 4, 2007 9:25 AM
in response to: kohsuke
|
|
|
Is it expected that I can use the Spring support in JAX-WS to work with the JMS custom transport framework as is?
--Keith
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 15, 2007 2:44 PM
in response to: keithwillard
|
|
|
Actually, no. JMS transport predates our Spring support, and it needs some love right now.
If you can file an issue for this so that this won't fall through the cracks, that would be great.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 15, 2007 11:47 PM
in response to: kohsuke
|
|
|
About the JMS support... we have a little thing up and running here... i could give it as input if you like... it uses the JAX-WS spring integration as the main container and uses the spring message listener container to wrap around JAX-WS to get it to listen to JMS.. however it is quite specific for our project and probably full of bugs and loose ends... but if you are interested just reply and i'll post it here...
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 16, 2007 10:59 PM
in response to: willemsrb
|
|
|
I'm very interested!
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jun 7, 2007 8:13 AM
in response to: kohsuke
|
|
|
Hi!
I'm trying to get the jaxws-spring combination to work.
Am using I am using Spring 2.0.7, jboss-4.0.5.GA, JAXWS2.1.1_20070501.jar and jaxws-spring-1.4.jar.
applicationContext namespace definitions:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://jax-ws.dev.java.net/spring/core https://jax-ws.dev.java.net/spring/core.xsd http://jax-ws.dev.java.net/spring/servlet https://jax-ws.dev.java.net/spring/servlet.xsd">
When I startup the JBoss, following error occurs:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://jax-ws.dev.java.net/spring/servlet] Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:261) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1111) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1104) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at fi.teligent.provisioning.ws.ApplicationContextUtil.<clinit>(Unknown Source) ... 149 more
first of all, when I try to access the servlet namespace schema shown in the example on how to configure this jaxws-spring (http://jax-ws.dev.java.net/spring/servlet.xsd), it is not found. With using https instead I can access it.
But I can't figure out the correct combination of how to use the namespace definitions to get this working?
One other person has this same problem: http://forums.java.net/jive/thread.jspa?messageID=220668&tstart=0
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jun 27, 2007 2:25 AM
in response to: mieleton
|
|
|
Hi,
we ussually got this error when we didn't have the XBEAN library as a dependency.. maybe the same for you?
Regards, Robert
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jul 9, 2007 12:22 AM
in response to: willemsrb
|
|
|
Ok... Is it part of JAX-WS or some other framework?
Could you point me towards that jar, as I haven't got the foggiest where to get it
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jul 9, 2007 4:52 PM
in response to: mieleton
|
|
|
I use Maven and that fetches all the necessary jars for us.
I think we need to provide all-in-one download zip file for non-Maven users...
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Nov 5, 2007 12:30 PM
in response to: kohsuke
|
|
|
Did the all in one archive ever happen? We can't seem to get past the namespace handler error and I believe we have the correct xbean jars.. (but then again I could be mistaken!!)
Thanks! Gary
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Jul 2, 2008 9:31 AM
in response to: kohsuke
|
|
|
I got the same exception i.e. java.lang.NoClassDefFoundError: com/sun/istack/XMLStreamReaderToContentHandler
When I looked at the pom.xml for jaxws-spring-1.8.jar and found there was an unnecessary dependency declared which is breaking the code. Here is the problem:
If you look at the jaxws-rt-2.1.3.jar pom.xml it has dependency on jaxb-impl-2.1.6.jar. In the jaxws-spring-1.8 pom.xml you have dependency on jaxws-rt-2.1.3.jar and that should drag the dependent jars with it. But .. the pom.xml has jaxb-impl-2.1.2.jar which really doesn't need to be there. Hence causes the applications to throw java.lang.NoClassDefFoundError: com/sun/istack/XMLStreamReaderToContentHandler
Also you can see a comment in the pom that dependency in jaxws-rt was not correct when this code was written and hence the pom was made the way it was (my guess!!!)
Here is what I had to do to overcome the issue: <dependencies> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>org.jvnet.jax-ws-commons.spring</groupId> <artifactId>jaxws-spring</artifactId> <version>1.8</version> <exclusions> <!-- Incorrect version declared in this pom --> <exclusion> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> </exclusion> <exclusion> <groupId>javax.jws</groupId> <artifactId>jsr181-api</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </exclusion> <exclusion> <groupId>javax.xml.soap</groupId> <artifactId>saaj-api</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.messaging.saaj</groupId> <artifactId>saaj-impl</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.stream.buffer</groupId> <artifactId>streambuffer</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.stream</groupId> <artifactId>sjsxp</artifactId> </exclusion> <exclusion> <groupId>com.sun.org.apache.xml.internal</groupId> <artifactId>resolver</artifactId> </exclusion> <exclusion> <groupId>org.jvnet.staxex</groupId> <artifactId>stax-ex</artifactId> </exclusion> <exclusion> <groupId>javax.annotation</groupId> <artifactId>jsr250-api</artifactId> </exclusion> <!-- SAAJ 1.3 asks for activation 1.0.2, which we don't have, so use 1.1 --> <exclusion> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> </exclusion> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 18, 2007 6:46 PM
in response to: willemsrb
|
|
|
We would also be very interested. I am more interested in how you did the Spring JAXWS integration with the JMS transport than in using the code itself.
What we want to do is to create a JMS transport layer similar to what we have done for Axis1, and XFire which is to use the Jencks JCA container and the Spring JMSTemplate classes to minimize our JMS code and to instantiate the service from Spring.
--Keith
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
May 31, 2007 4:41 AM
in response to: willemsrb
|
|
|
Sorry to take so long, but i've been too busy for my own good.... i'll just drop the code here because i don't have much time to get it up nice and generic... It is based on the 1.1 spring binding and i've noticed a few changes that won't work anymore at the moment...
Message Endpoint:
import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
import com.sun.xml.ws.transport.http.servlet.ServletAdapterList;
import com.sun.xml.ws.transport.http.servlet.SpringBindingList;
import java.io.IOException;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
/**
* MDP that supports message driven webservice endpoints.
*/
public class MessageEndpoint implements MessageListener {
/**
* Constructor.
*
* @param bindings
* @param url
* @param replyQueueFactory
* @param replyQueue
*/
public MessageEndpoint(final SpringBindingList bindings, String url, QueueConnectionFactory replyQueueFactory, Queue replyQueue) {
ServletAdapterList adapterList = bindings.create();
for (ServletAdapter adapter: adapterList) {
if (url.equals(adapter.getValidPath())) {
jmsAdapter = new JMSAdapter(adapter.getEndpoint());
}
}
if (jmsAdapter == null) {
throw new RuntimeException("URL not found in Spring defined endpoints. No adapter could be made to handle messages.");
}
this.replyQueue = replyQueue;
this.replyQueueFactory = replyQueueFactory;
}
/** Adapter to handle messages. */
private static volatile JMSAdapter jmsAdapter;
/** Queue factory for return message. */
private QueueConnectionFactory replyQueueFactory;
/** Queue for return message. */
private Queue replyQueue;
/**
* Handle a new message on the queue. Wraps the message in a JMS Connection and call the configured JMS adapter.
* @param message the message
*/
public void onMessage(final Message message) {
try {
// Hier komt de logica om een connection te maken, de connection weet waar de reply naar toe moet
JMSConnectionImpl connection = new JMSConnectionImpl(message, replyQueueFactory, replyQueue);
// Handle the message
jmsAdapter.handle(connection);
} catch (JMSException e) {
throw new RuntimeException("Unexpected jms-error in MDP", e);
} catch (IOException e) {
throw new RuntimeException("Unexpected io-error in MDP", e);
}
}
}
JMSConnectionImpl:
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.sun.xml.ws.api.message.Packet;
import com.sun.xml.ws.api.server.WSEndpoint;
import com.sun.xml.ws.api.server.WebServiceContextDelegate;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Principal;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Connection is used to store the incoming message and stream it from and
* act as a holder for the response.
*
*/
public class JMSConnectionImpl implements WebServiceContextDelegate {
/** Logger. */
private static Log log = LogFactory.getLog(JMSConnectionImpl.class);
/** Original ID of request message. */
private String requestMessageJMSID;
/** Inputstream buffer to stream incoming message. */
private byte[] inputStreamBuffer;
/** Number of bytes to ignore at start of buffer for inputstream. */
private int inputStreamRemoveBytes = 0;
/** Outputstream to temporary store outgoing message. */
private ByteArrayOutputStream outputStream;
/** ConnectionFactory for queue for outgoing message. */
private QueueConnectionFactory replyQueueFactory;
/** Queue for outgoing message. */
private Queue replyQueue;
/**
* Constructor.
*
* @param requestMessage incoming message
* @param replyQueueFactory connectionfactory for outgoing message
* @param replyQueue queue for outgoing message
* @throws JMSException on jms error
*/
public JMSConnectionImpl(final Message requestMessage, final QueueConnectionFactory replyQueueFactory, final Queue replyQueue) throws JMSException {
// Prepare outputstream
outputStream = new ByteArrayOutputStream();
// Store original JMS ID
requestMessageJMSID = requestMessage.getJMSCorrelationID();
// Prepare inputstream buffer
inputStreamBuffer = null;
if (requestMessage instanceof BytesMessage) {
log.debug( "Received bytes message ..." ) ;
inputStreamBuffer = new byte[(int)((BytesMessage)requestMessage).getBodyLength()];
((BytesMessage)requestMessage).readBytes(inputStreamBuffer);
} else if (requestMessage instanceof TextMessage) {
log.debug( "Received text message ..." ) ;
inputStreamBuffer = ((TextMessage)requestMessage).getText().getBytes();
} else {
throw new JMSException("Invalid message format: " + requestMessage.getClass().getName());
}
// log.debug( "BOM check byte 0: " + inputStreamBuffer[0] );
// log.debug( "BOM check byte 1: " + inputStreamBuffer[1] );
// log.debug( "BOM check byte 2: " + inputStreamBuffer[2] );
// log.debug( "BOM check byte 3: " + inputStreamBuffer[3] );
//
//
// // Remove BOM (Byte Order Mark)
// //
// // +-----------------------------------------+
// // | Bytes | Encoding Form |
// // +-----------------------------------------+
// // | 00 00 FE FF | UTF-32, big-endian |
// // | FF FE 00 00 | UTF-32, little-endian |
// // | FE FF | UTF-16, big-endian |
// // | FF FE | UTF-16, little-endian |
// // | EF BB BF | UTF-8 |
// // +-----------------------------------------+
// if (inputStreamBuffer[0] == (byte)0xEF && inputStreamBuffer[1] == (byte)0xBB && inputStreamBuffer[1] == (byte)0xBF) {
// inputStreamRemoveBytes = 3;
// log.debug("Removing first three bytes of stream because of BOM.");
// } else if ((inputStreamBuffer[0] == (byte)0x00 && inputStreamBuffer[1] == (byte)0x00 && inputStreamBuffer[2] == (byte)0xFE && inputStreamBuffer[3] == (byte)0xFF) || (inputStreamBuffer[0] == (byte)0xFF && inputStreamBuffer[1] == (byte)0xFE && inputStreamBuffer[2] == (byte)0x00 && inputStreamBuffer[3] == (byte)0x00)) {
// inputStreamRemoveBytes = 4;
// log.warn("Removing first four bytes of stream because of BOM (untested!).");
// } else if ((inputStreamBuffer[0] == (byte)0xFE && inputStreamBuffer[1] == (byte)0xFF) || (inputStreamBuffer[0] == (byte)0xFF && inputStreamBuffer[1] == (byte)0xFE)) {
// inputStreamRemoveBytes = 2;
// log.warn("Removing first two bytes of stream because of BOM (untested!).");
// }
// else {
// log.debug( "No BOM detected." ) ;
// }
inputStreamRemoveBytes = new String( inputStreamBuffer ).indexOf( "<?xml") ;
log.debug("Removing first " + inputStreamRemoveBytes + " of stream because of BOM or useless crap in message.");
if( inputStreamRemoveBytes == -1 ) {
log.warn( "Message does not contain <?xml something will go wrong" ) ;
inputStreamRemoveBytes = 0 ;
}
// Log incoming message
log.debug("Message received on queue:\n" + new String(inputStreamBuffer));
// Configuration for transmission
this.replyQueueFactory = replyQueueFactory;
this.replyQueue = replyQueue;
if (this.replyQueue instanceof MQQueue) {
log.debug("Setting replyQueue target client to non-jms");
((MQQueue)this.replyQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
}
}
/**
* Returns a stream to the incoming message.
* @return A stream to the incoming message.
*/
public InputStream getInputStream() throws JMSException {
ByteArrayInputStream bais = new ByteArrayInputStream(inputStreamBuffer, inputStreamRemoveBytes, inputStreamBuffer.length - inputStreamRemoveBytes);
return (bais);
}
/**
* Retuns a stream that the outgoing message can be written to.
* @return A stream that the outgoing message can be written to.
*/
public OutputStream getOutputStream() {
return (outputStream);
}
/**
* Transmit the outgoing message.
*
* @throws JMSException on jms errors
* @throws IOException on read/write errors
*/
public void transmit() throws JMSException, IOException {
if (outputStream != null) {
outputStream.flush();
}
QueueConnection connection = replyQueueFactory.createQueueConnection();
try {
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
try {
// BytesMessage replyMessage = jmsSession.createBytesMessage();
// byte[] content = ((ByteArrayOutputStream)getOutputStream()).toByteArray();
// if (content.length > 0) {
// replyMessage.writeBytes(content);
// }
TextMessage replyMessage = session.createTextMessage();
replyMessage.setJMSCorrelationID(requestMessageJMSID);
replyMessage.setText(new String(outputStream.toByteArray()));
// System.out.println( "Reply message id : \n" + replyMessage.getJMSMessageID() );
// System.out.println( "Reply message correlation id : \n" + replyMessage.getJMSCorrelationID() );
QueueSender sender = session.createSender(replyQueue);
try {
sender.send(replyMessage);
log.debug("Message sent via queue: \n" + replyMessage.getText());
} finally {
sender.close();
}
} finally {
session.close();
}
} finally {
connection.close();
}
}
/**
* NOT IMPLEMENTED: for WebServiceContextDelegate.
*
* @param packet packet
* @return null
*/
public Principal getUserPrincipal(final Packet packet) {
return null;
}
/**
* NOT IMPLEMENTED: for WebServiceContextDelegate.
*
* @param packet packet
* @param role role
* @return false
*/
public boolean isUserInRole(final Packet packet, final String role) {
return false;
}
/**
* NOT IMPLEMENTED: for WebServiceContextDelegate.
*
* @param packet packet
* @param wsEndpoint endpoint
* @return null
*/
public String getEPRAddress(final Packet packet, final WSEndpoint wsEndpoint) {
return null;
}
/**
* NOT IMPLEMENTED: for WebServiceContextDelegate.
*
* @param packet packet
* @param wsEndpoint endpoint
* @return null
*/
public String getWSDLAddress(final Packet packet, final WSEndpoint wsEndpoint) {
return null;
}
}
JMSAdapter:
import com.sun.xml.ws.api.message.Packet;
import com.sun.xml.ws.api.pipe.Codec;
import com.sun.xml.ws.api.server.TransportBackChannel;
import com.sun.xml.ws.api.server.WSEndpoint;
import com.sun.xml.ws.api.server.WSEndpoint.PipeHead;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.jms.JMSException;
/**
* Adapter for JMS transport.
*/
public class JMSAdapter implements TransportBackChannel {
/** The WS endpoint. */
private WSEndpoint endpoint;
/** Codec used the encode/decode packets. */
private Codec codec;
/** Handle the call to the endpoint. */
private PipeHead head;
/**
* Constructor.
* @param endpoint the ws endpoint
*/
public JMSAdapter(final WSEndpoint endpoint) {
this.endpoint = endpoint;
codec = endpoint.createCodec();
head = endpoint.createPipeHead();
}
/**
* Handle the request stored in the given JSM connection.
*
* @param connection JMS connection
* @throws IOException on read/write erros
* @throws JMSException on jms errors
*/
public void handle(final JMSConnectionImpl connection) throws IOException, JMSException {
//System.out.println( "Decode request ..." ) ;
try {
// Decode request
Packet packet = new Packet();
codec.decode(connection.getInputStream(), "text/xml", packet);
//System.out.println( "Request packet: " + packet ) ;
// Handle request
//System.out.println( "Handle request ..." ) ;
packet = head.process(packet, connection, this);
//System.out.println( "Response package: " + packet ) ;
// Encode response
//System.out.println( "Encode response ... " ) ;
OutputStream os = connection.getOutputStream();
codec.encode(packet, os);
os.close();
} catch (Exception e) {
// Create error message, move to dead letter queue
OutputStream os = connection.getOutputStream();
PrintStream ps = new PrintStream(os);
ps.println("Onverwachte fout tijdens transport opgetreden: " + e.getMessage());
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
ps.println(line);
}
os.close();
}
// Transmit reponse
//System.out.println( "Transmit response ... " ) ;
connection.transmit();
//System.out.println( "Done ..." ) ;
}
/**
* NOT USED: Close the connection.
*/
public void close() {
}
}
A lot of code is taken from the JMS transport project here in JAX-WS but changed a little for use in this situation.
The Spring config to get it working:
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName"
xmlns:ws= "http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd" >
<!-- Service implementations -->
<bean name="MyHTTPServiceImpl" class="foo.MyHTTPServiceImpl" />
<bean name="MyJMSServiceImpl" class="foo.MyJMSServiceImpl" />
<!-- Service mapping -->
<wss:bindings id="jax-ws.http">
<wss:bindings>
<wss:binding url="/someUrl"> <!-- This URL is exposed in web.xml -->
<wss:service>
<ws:service bean="#MyHTTPServiceImpl"
serviceName="ns1:MyService"
portName="ns1:MyHTTPPort"
xmlns:ns1="http://some.namespace/something"
>
</ws:service>
</wss:service>
</wss:binding>
<!-- Not accessable via web because not exposed in web.xml -->
<wss:binding url="/someOtherUrl" >
<wss:service>
<ws:service bean="#MyJMSServiceImpl"
serviceName="ns1:MyService"
portName="ns1:MyJMSPort"
xmlns:ns1="http://some.namespace/something"
>
</ws:service>
</wss:service>
</wss:binding>
</wss:bindings>
</wss:bindings>
<!-- Queue Connection Factory -->
<bean id="connectionFactory" class="com.ibm.mq.jms.MQXAQueueConnectionFactory" />
<!-- Request queue -->
<bean id="vraagQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName" value="requestQueue" />
</bean>
<!-- Response queue -->
<bean id="antwoordQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName" value="responseQueue" />
</bean>
<!-- Endpoint implementation -->
<bean id="messageEndpoint" class="nl.uwv.generiek.ws.jms.MessageEndpoint" >
<constructor-arg ref="jax-ws.http" type="com.sun.xml.ws.transport.http.servlet.SpringBindingList" />
<constructor-arg type="java.lang.String" value="/someOtherUrl" />
<constructor-arg type="javax.jms.QueueConnectionFactory" ref="connectionFactory" />
<constructor-arg type="javax.jms.Queue" ref="antwoordQueue" />
</bean>
<!-- JMS Transaction manager -->
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<!-- Message listener container, Websphere MQ is JMS 1.02 compliant -->
<bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
<property name="concurrentConsumers" value="5"/>
<property name="sessionTransacted" value="true" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="vraagQueue" />
<property name="messageListener" ref="messageEndpoint" />
<property name="receiveTimeout" value="5000" />
<property name="transactionManager" ref="jmsTransactionManager" />
</bean>
</beans>
Hope this helps someone...
Regards, Robert
|
|
|
|
|
|
|
|
404 Not Found: Invalid Request
Posted:
Jul 25, 2007 1:49 AM
in response to: kohsuke
|
|
|
..Deleted post.. issue solved and was due to external factors.
Message was edited by: artsu
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Aug 11, 2007 8:19 AM
in response to: kohsuke
|
|
|
Hi Kohsuke,
I am just beginning to use jaxws-spring. It looks like just what I needed. Thank you.
One minor comment is on the choice of namespace prefixes below:
xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
I think the names are not obvious and potentially misleading. WS implies web services to me while WSS implies Web Services Security. The current names threw me off briefly. Please consider a different choice. For example:
xmlns:jsic="http://jax-ws.dev.java.net/spring/core" xmlns:jsis="http://jax-ws.dev.java.net/spring/servlet"
where:
jsic = JAX-WS Spring Integration - Core jsis = JAX-WS Spring Integration - Servlet
Thanks again for this valuable work.
-- Regards, Farrukh
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Aug 22, 2007 3:16 PM
in response to: najmi
|
|
|
jsic/jsis acronym expansion isn't very obvious to me.
How about just "c" and "s". They look sufficiently different, and don't collide with any existing acronyms.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Sep 6, 2007 5:49 AM
in response to: kohsuke
|
|
|
Sorry for double posting, perhaps I should have posted this question here.....
I have successfully got the spring / jax-ws integration working with the jaxws-spring library. The problem now is that I am having trouble introducing AOP into the mix. The idea is that I would like some logging and performance measurement x-cutting 'around' code executed in each of my service implementation methods.
If I define any AOP configuration anywhere, even completely unrelated to the service classes, I get the trace (below) when deploying from eclipse:
---snip----
<aop:config> <aop:aspect ref="aBean"> <aop:pointcut id="myCutLogging" expression="execution(* Entry*.*(..))"/> <aop:around pointcut-ref="myCutLogging" method="log" /> </aop:aspect> </aop:config>
<bean id="aBean" class="server.aspect.WSRequestAuthenticationAspect"/>
---snip----
After doing a little bit of digging, I find that when I include this snippet, the setService() method in SpringBinding is being called (or at least would be if spring didn't detect the type incompatibilities) with a java.lang.reflect.Method which is a referencing the aspect method:
server.aspect.WSRequestAuthenticationAspect.log(org.aspectj.lang.ProceedingJoinPoint) throws java.lang.Throwable
This is way over my head and I would be delighted if somebody could help out........kohsuke???
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wss:binding#246ffc' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.reflect.Method] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1126) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:215) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:281) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:131) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) at org.apache.catalina.startup.Catalina.start(Catalina.java:551) 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:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) 05-Sep-2007 14:18:58 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart 05-Sep-2007 14:18:58 org.apache.catalina.core.StandardContext start SEVERE: Context [/wsapi] startup failed due to previous errors 05-Sep-2007 14:18:59 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 05-Sep-2007 14:18:59 org.apache.coyote.http11.Http11BaseProtocol start INFO: Starting Coyote HTTP/1.1 on http-8080 05-Sep-2007 14:18:59 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 05-Sep-2007 14:19:00 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/297 config=null 05-Sep-2007 14:19:00 org.apache.catalina.storeconfig.StoreLoader load INFO: Find registry server-registry.xml at classpath resource 05-Sep-2007 14:19:00 org.apache.catalina.startup.Catalina start INFO: Server startup in 20422 ms
|
|
|
|
|
|
|
|
jmaki-demo-app with jax-ws spring support?
Posted:
Sep 17, 2007 3:16 AM
in response to: kohsuke
|
|
|
Hi,
I'v been trying out the jmaki-demo-app from the source code and I'm able to get the application running, only the dependency injection of Spring doesn't seem to work. Should this example work? In this example a greeter service is used where a property is used to set the prefix. This property is never set when I run the example.
<bean id="myService" class="greeter.GreetingService"> <property name="prefix" value="Bonjour, " /> </bean>
The example can be found in:
jax-ws-commons\json\jmaki-demo-app
It would be nice to see an example with some actual injection of a spring bean or property. Are there any suggestions on how to get this example running?
cheers,
Rudie.
|
|
|
|
|
|
|
|
CLASS NOT FOUND :com/sun/xml/ws/transport/http/servlet/ServletAdapterList,
Posted:
Sep 24, 2007 1:00 PM
in response to: ekkelenkamp
|
|
|
I am trying to implement the sample project given at https://jax-ws-commons.dev.java.net/source/browse/jax-ws-commons/trunk/spring/test-app/ to get jax-ws running. But I am getting this error : - java.lang.NoClassDefFoundError: com/sun/xml/ws/transport/http/servlet/ServletAdapterList
I have included jaxws-spring-1.7.jar and xbean-spring-2.8.jar files in the project.
What else jar files I need to include?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Sep 25, 2007 5:09 AM
in response to: kohsuke
|
|
|
Hello,
I have this strange error. Everything actually works for me, but not all in our team. I am running the application in Linux, but I have successfully run the application on Windows as well. We are using versions spring 2.06, jaxws-spring 1.6, jaxb-api 2.1, jaxws-api 2.1, jaxws-rt EA3, tomcat 5.5.23. My locale (LANG) is en_US. The team is in Russia so this could be an issue with computer's locale, though I changed my locale to Russian but still didn't have the problem. A clip from context xml: <wss:binding id="MMa_binding_for_import" url="/services/import"> <wss:service> <ws:service bean="#mmaWebService"/> </wss:service> </wss:binding>
web.xml: <!-- Jax-WS configuration --> <servlet> <servlet-name>jaxws-servlet</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class> </servlet>
<servlet-mapping> <servlet-name>jaxws-servlet</servlet-name> <url-pattern>/services/import</url-pattern> </servlet-mapping>
So the problem: When deploying the error message is as follows: ----- 2007-09-25 13:07:56,343 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/MMa]] - <Exception sending context initialized instance of class org.springframework.web.context.ContextLoaderListener> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MMa_binding_for_import' defined in ServletContext res WsContext.xml]: Cannot create inner bean '(inner bean)' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property ' ception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1': FactoryBean threw excepti on; nested exception is [failed to localize] nestedModelerError(com.sun.xml.ws.util.localization.LocalizableMessage@1 d7bd04) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1': FactoryBean threw exception on objec exception is [failed to localize] nestedModelerError(com.sun.xml.ws.util.localization.LocalizableMessage@1 d7bd04) Caused by: [failed to localize] nestedModelerError(com.sun.xml.ws.util.localization.LocalizableMessage@1 d7bd04) at com.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:276) at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModel er.java:573) at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:52 0) at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:361 ) at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.jav a:247) at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.jav a:266) at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.jav a:174) at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:420) at org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.ja va:317) at org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.ja va:44) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectF romFactoryBean(AbstractBeanFactory.java:1236) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectF orBeanInstance(AbstractBeanFactory.java:1207) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.re solveInnerBean(BeanDefinitionValueResolver.java:219) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.re solveValueIfNecessary(BeanDefinitionValueResolver.java:127 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.applyPropertyValues(AbstractAutowireCapableBeanFactor at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.populateBean(AbstractAutowireCapableBeanFactory.java: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.createBean(AbstractAutowireCapableBeanFactory.java:42 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjec t(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g etSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.pre InstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(A bstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContex t(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext( ContextLoader.java:187) at org.springframework.web.context.ContextLoaderListener.contextInitialized (ContextLoaderListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j ava:3763) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211 ) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja va:759) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:31 0) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSu pport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) at org.apache.catalina.startup.Catalina.start(Catalina.java:551) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) 25.9.2007 13:07:56 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart 25.9.2007 13:07:56 org.apache.catalina.core.StandardContext start SEVERE: Context [/MMa] startup failed due to previous errors
----
Any ideas where the problem lies? Any help highly appreciated. Thanks.
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Oct 10, 2007 12:24 PM
in response to: kohsuke
|
|
|
Yeah, I am having the exact same issue as 'artsu'. Any word on that fix?
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Nov 1, 2007 7:49 PM
in response to: kohsuke
|
|
|
I'm sorry kohsuke but I don't agree with you about maven fetching the correct dependencies. Ever since I had to switch from CXF to Jax-ws RI I'm having headaches to set it up properly with Spring (as someone else pointed out, one error after another).
The sample code is outdated, the documentation is lacking more information and I couldn't find answers to problems in jax-ws RI site or forums.
As of now I am having the same unsolved problem some other users have pointed out: I'm getting java.lang.NoClassDefFoundError: com/sun/istack/XMLStreamReaderToContentHandler error when my WS is called (the wsdl shows fine).
In my pom.xml I'm using
<dependency> <groupId>org.jvnet.jax-ws-commons.spring</groupId> <artifactId>jaxws-spring</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <version>2.1.2</version> </dependency>
So please, please, please. Can someone point out what jar has this class. If we at least know which project this class belongs to we might find out how to set-up the correct dependencies in maven.
Posted edited after chilling out. /rant turned off :P
Message was edited by: danielmfreitas
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Nov 1, 2007 8:06 PM
in response to: danielmfreitas
|
|
|
Hey.
After a fun time checking inside the jars from the jax-ws implementation I found out that the needed jar is jaxb-impl.jar, from RI 2.1.2. This jar does have the class I'm looking for. After I copied the jar to my webapp lib folder, I noticed that there is a jaxb-impl-2.1.2.jar which DO NOT contain the missing class.
I dunno who is depending in this file: if it is a incorrect pom dependency for jax-ws or if it is another module or 3rd party library that needs that one and the dependency conflict resolver (whatever it is called) of maven selected this one.
I will try to find the correct version for jaxb-impl and see if I can tell maven to select this one over others.
Message was edited by: danielmfreitas
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Nov 1, 2007 8:30 PM
in response to: danielmfreitas
|
|
|
Ok. Reading the MANIFEST.MF file from jaxb-impl.jar that comes with RI 2.1.2, I think the version needed is jaxb-impl-2.1.4.
On, https://maven-repository.dev.java.net/nonav/repository/, there is a couple of versions. I checked the 2.1.4 version and the class was there. There are some more recent versions but I didn't bother checking.
I could successfully run the test now. By the way, I checked the jaxws-spring-1.7.pom file and look what I found:
<dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.1.2</version> </dependency>
Indeed, jax-ws did not set up the dependencies properly (or maybe the jar was updated but not the pom).
So i fixed it myself to
<dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.1.4</version> </dependency>
So I don't have to explicitly add that dependency to my project's pom.
Message was edited by: danielmfreitas
|
|
|
|
|
|
|
|
Re: Spring support in JAX-WS
Posted:
Dec 2, 2008 10:01 AM
in response to: kohsuke
|
|
|
Do you know if the all-in-one download zip file containing all of the necessary jar files was created or posted somewhere? I am not using Maven. I am using MyEclipse ide, with Java 1.5.0 and am getting a lot of the same errors users have posted here. I am trying to use Spring 2.5 with jax-ws 2.1 and jdk 1.5.0_12. Do I need to use jdk 1.6?
Any help would be appreciated.
Thanks, Charlie
|
|
|
|
|