i followed this article: http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/
so i have:
HelloWorld http://pastebin.com/BJ3QA7pR
HelloWorldImpl http://pastebin.com/RM5SBZ5C
HelloWorldPublisher http://pastebin.com/H525WevK
which serves as the endpoint.
on the other side i have the client which i generated with wsimport:
HelloWorld http://pastebin.com/g07H1exf
HelloWorldImplService http://pastebin.com/f0YWMiYt
this runs fine in eclispe without alfresco being involved. however, i want to call the webservice from alfresco (from java backed web script for example)
i tried to copy the client side stuff to my amp file and calling it from a webscript but it fails!
Caused by: java.lang.IncompatibleClassChangeError: Class com.ibm.wsdl.DefinitionImpl does not implement the requested interface javax.wsdl.extensions.AttributeExtensible
Webscript http://pastebin.com/7JksRdtU
1 - is there a more elegant way to configure the access to the wsdl by defining a spring bean (spring-ws) or such
2 - why is it not working? full trace: http://pastebin.com/ak1qzygA
using alfresco community 5.0.a
thanks
You will see IncompatibleClassChangeError usually when the dependancy/library jar has changed. Hence the method/code dependant on the library has to be recompiled against the changes.
Guessing the problem here has much to do with some dependancy jar being mispicked or an older version of jar present or one jar prioritized over the other. A look into the jars containing 'com.ibm.wsdl.DefinitionImpl' class in your classpath should be of some help.
Related
I have an app deployed on IBM WebSphere 8.5.5.0.
When the app tries to call a remote web service, I get
java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.apache.axis2.jaxws.spi.Provider not a subtype.
It seems that WAS is picking (probably bundled) Axis2 impl. of the JAX-WS Provider class instead of the CXF one that I want to use.
The app WAR does not come with Axis2 impl. of javax.xml.ws.spi.Provider
The app WAR contains a CXF jar with the Provider impl., org.apache.cxf.jaxws.spi.ProviderImpl
I tried
Classloaders set to "Classes loaded with local class loader first (parent last)"
http://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/twbs_thirdparty.html
Set the com.ibm.websphere.webservices.DisableIBMJAXWSEngine property to true (http://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/twbs_thirdparty.html)
adding "-Djavax.xml.ws.spi.Provider=org.apache.cxf.jaxws.spi.ProviderImpl" in JVM arguments for the server
Neither of them helped, I still have the same exception.
Interestingly when I print System.getProperty(“javax.xml.ws.spi.Provider”) from a test JSP within the app, it outputs org.apache.cxf.jaxws.spi.ProviderImpl.
Thanks for any help
Applying a WebSphere Fix Pack 9 solved the issue completely.
Short version: A restful spring web service crashes when I include a dependency: com.google.gdata: core: 1.47.1
Long Version:
I was trying to make a restfull web service that consume certain information from a spreadsheet in google drive
this is my sequence of steps:
preparing classes that made the connection and the data obtained from drive (not web, only backend classes, unit and integration tests included): all ok
prepare a restfull web service with spring, basically download a spring tutorial (http://spring.io/guides/tutorials/rest/3/) and execute: all ok
then remove tutorial's business classes and include my components, change controllers to invoke my components, plus add gdata dependence in file graddle.build, try execute: houston we have a problem
It's strange, when start app context, log print something like this:
C:\Users\Grubhart\Documents\proyectos\error_Rest_Gdata\complete\src\main\java\com\yummynoodlebar\config\WebAppInitializer.java:39: error: can not find symbol
servletContext.setInitParameter ("defaultHtmlEscape", "true");
^
symbol: method setInitParameter (String, String)
location: Variable of type ServletContext ServletContext
but when the rest app is just downloaded (whitout my code, neither gdata dependency) it works, the only thing I did was add my code and the google api dependence, so I started to see what could cause the error
remove all my code (but leave the gdata jar) and... wait for it.. same error,
remove gdata dependency: it works
then add gdata dependency again and test: the same error again
So I think that by including the gdata jar does something that prevents start the entire app context
I created a repo on github to illustrate the error:
https://github.com/Grubhart/error_spring_restWS_gdata
the master branch has the code of a service that works without gdata dependence
gdata_error branch as you can imagine has added gdata dependency (only dependency, no extra code) in gradle.build file:
compile 'com.google.gdata: core: 1.47.1'
and presents the error
no need install anything (even gradle) only have jdk, download the code and run it as stated in the readme file to see errors
i do my homework, look in google, stackoverflow (great site!), spring forum but can't find nothing
if anyone has experience with this problem, or know where i can found more information would be great if you can share experiences or if you know where to look for more info about this error
The original post doesn't contains:
yummynoodlebar\config\WebAppInitializer.java:39: error: cannot find symbol
servletContext.setInitParameter("defaultHtmlEscape", "true");
ServletContext needs import javax.servlet.*; Maybe the error is for that.
Since the spring context configuration in java classes for web applications works with Servlet 3.0 maybe you have overwritten troubles between some dependencies that comes with gdata which may do use of dependencies other than the servlet version you are using to deploy the application or which it was originally configured, I hope this helps you!.
I am learning how to implement web services in Java. Following the example in O'Reilly's book "Learning Java," I downloaded a WSDL file (see http://bit.ly/13moiTh) for a weather service at cdyne.com and generated a set of classes using the wsimport tool.
The first problem was that when I generated a JAR file and referenced it in the Eclipse project, the classes were not recognized. I had to use wsimport -keep and individually copy all source files into the project to make it build.
Next, to make sure that the service was available, I constructed a simple HTTP POST client based on the code from the book. I could successfully access the getCityWeatherByZIP service with that code, so there was no connectivity or authentication issue.
Finally, I tried to access the getCityWeatherByZIP and getCityForecastByZIP services using the automatically-generated web services client code. Both silently failed, i.e. the isSuccess() methods returned false and all response fields were null:
Weather service = new Weather();
WeatherSoap weatherSoap = service.getWeatherSoap();
WeatherReturn weather = weatherSoap.getCityWeatherByZIP(ZIP);
if (weather.isSuccess()) {
System.out.format("%s, %s : %s : Temperature: %s, Wind: %s\n",
weather.getCity(), weather.getState(), weather.getDescription(),
weather.getTemperature(), weather.getWind());
}
else {
System.out.println("Failed to obtain weather");
}
In stepping through the code, in getCityWeatherByZIP() I discovered the following NoSuchMethodException:
com.sun.xml.internal.ws.api.message.Packet.setHeaderList(com.sun.xml.internal.ws.api.message.HeaderList)"
This exception occurs in line that says (in the Debug perspective of Eclipse):
"SEIStub.invoke(Object, Method, Object[]) line: not available"
Clearly, the Packet.setHeaderList(HeaderList) method does not exist, which is also corroborated by the documentation of the non-internal class:
https://jax-ws.java.net/nonav/jax-ws-20-fcs/arch/com/sun/xml/ws/api/message/Packet.html
I am using the latest JDK 1.7 and Eclipse Version: Kepler Service Release 1, Build id: 20130919-0819.
I do not know how to fix this problem. Any help would be appreciated.
In addition to the source code from the book, you also need a copy of the JAX-WS web service code in order to compile and run. You update the Build Path inside Eclipse to reference any jars for the JAX-WS web service, and it sounds like Eclipse doesn't have a copy on the classpath.
JAX-WS is the specification but you will need an actual implementation of JAX-WS in order to run, possibly the Reference Implementation?
I'm consuming a webservice where the WSDL file contains imports to other wsdl and xsd schemas, e.g:
<import namespace="http://my.api.com/" location="http://other.server.com:8888/context/services/MyService?wsdl=1"/>
which in turn can import other files
<xsd:import namespace="http://my.api.com/" schemaLocation="http://other.server.com:8888/context/services/MyService?xsd=1"/>
The client is generated by cxf with a maven plugin. The main WSDL file is added as a classpath resource. However, at runtime it appears that the client actually needs access to other.server.com:8888 to resolve the WSDL completely. So the question is, does a tool exist for importing and resolving all URLs in a WSDL so that it is not dependent absolute server URLs in other imports in the WSDL, and suitable for including in a client project?
We do not control the WSDL, so we can't change it in the source.
Edit: Looking for a tool that works on Linux
Check the ServiceModel Metadata Utility Tool (Svcutil.exe) from Windows SDK.
svcutil /t:metadata http://service/metadataEndpoint
This tool locates or discovers, one or more related documents that describe a particular XML Web service using the Web Services Description Language (WSDL).
I don't know if I understood your question correctly. I'm having my battles with Jax-ws/SOAP too. :)
If you need to generate the java classes needed to call the webservice you can use Apache CXF. Inside it you have a wsdl2java. You can use it on linux.
Another option in Java SDK, on the bin folder there's the wsimport that you can use it too.
Edit: You can change the final URL at runtime using the Service class created by Apache CXF.
new SomeRandomJaxWSService(new URL(wsdl),new QName(namespace, serviceName))
In development I use jetty as the servlet container. I have the following development configuration:
master project which has wabapp directory
derived project which overrides some of the files in webapp directory
The master project webapp can be started in development mode thanks to providing appropriate WebAppContext to jetty.
Now I want to start derived project analogously, assuming that when request is made, there is an attempt to:
get resource from webapp directory of derived project
if it does not exists, get it from webapp directory of master project
I know that it is possible to override WebAppContext#getResource() method, however some libraries we use in the project seem to perform IO operations on wabapp directory on their own. For example by calling ServletContext#getRealPath("/"), and then reading files without use of ServletContext#getResource() method. The problem could be solved on lower level by some virtual file system on top of File, however it does not seem to be supported in JDK 1.6, any suggestions?
It seems that using something like ResourceCollection is sufficient:
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/util/resource/ResourceCollection.html
Unfortunately the GWT's DevMode which I use is based on jetty 6, where ResourceCollection is unavailable. I extended the Resource class myself, and together with own GWT JettyLauncher, and thanks to small trick with setting resourceBase on DefaultServlet via reflection, I was able to serve webapp from two directories simultaneously.
protected void doStart() throws Exception {
setClassLoader(new LauncherWebAppClassLoader());
super.doStart();
ServletHolder holder = getServletHandler().getServlet("default");
Servlet servlet = holder.getServlet();
Field field = servlet.getClass().getDeclaredField("_resourceBase");
field.setAccessible(true);
field.set(servlet, combinedResourceBase);
}