Metro on WebSphere 7 – com.ibm.xml.xlxp2.jaxb.JAXBContextImpl incompatible exception

Problem Developed a SOAP web service via Metro 2.0.1 (webservices-rt.jar), integrate with Spring via jaxws-spring-1.8.jar and deployed on WebSphere Application Server (WAS) version 7.0.0.13 . See web service below : File : UserWS.java package com.mkyong.user.ws; //import… @WebService() public class UserWS { private UserBo userBo; @WebMethod(exclude = true) public UserBo getUserBo() { return userBo; } @WebMethod(exclude …

Read more

Spring + JAX-WS : ‘xxx’ is an interface, and JAXB can’t handle interfaces

Problem Integrate Spring + JAX-WS, see web service below : package com.mkyong.user.ws; //imports… @WebService() public class PGUserWS { //DI via Spring private UserBo userBo; public UserBo getUserBo() { return userBo; } public void setUserBo(UserBo userBo) { this.userBo = userBo; } @WebMethod(operationName = "addUser") public boolean addUser(@WebParam(name = "userId") String userId, @WebParam(name = "User") User user) …

Read more

Spring + jax-ws : ‘#xxx’ is not a valid value for ‘NCName’

Problem Here’s the Spring + JAX-WS configuration file … <?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.5.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" > <wss:binding url="/ws/OrderWs"> <wss:service> <ws:service bean="#orderWs"/> </wss:service> </wss:binding> <!– this bean implements web service methods –> <bean id="#orderWs" class="com.mkyong.order.ws.OrderWS"> <property name="orderBo" ref="OrderBo" /> </bean> </beans> During server start up, it hits following …

Read more

java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler

Problem Developing jax-ws with Spring, using jdk1.6 + jaxws-spring-1.8.jar + Spring-2.5.6.jar. See following Spring XML configuration file : <?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.5.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" > <wss:binding url="/ws"> <wss:service> <ws:service bean="#UserWs"/> </wss:service> </wss:binding> <!– this bean implements web service methods –> <bean id="UserWs" class="com.mkyong.user.ws.UserWS"> <property name="UserBo" ref="com.mkyong.user.bo.UserBo" /> …

Read more

java.lang.ClassNotFoundException: org.springframework.beans.factory.support.ReaderContext

Problem Integrating jax-ws with Spring, using xbean-spring-2.8.jar + Spring-2.5.6.jar. While server is starting up, it hits java.lang.ClassNotFoundException: org.springframework.beans.factory.support.ReaderContext Solution The “org.springframework.beans.factory.support.ReaderContext” is no longer exist in Spring-2.5.x, it’s only exist in the old Spring version < 2.5.x. The solution is upgrade your xbean-spring to latest version , for example, v3.7. You can get xbean-spring.jar from ...

Read more

JAX-WS : SOAP handler in server side

SOAP handler is a SOAP message interceptor, which is able to intercept incoming or outgoing SOAP message and manipulate its values. For example, attach a SOAP handler in client side, which will inject client’s computer MAC address into the SOAP header block for every outgoing SOAP message that is send by the client. In server …

Read more

javax.xml.stream.XMLStreamException : ParseError at [row,col]:[x,xx]

Problem Created a JAX-WS handler to inject a mac address into the client side SOAP request header automatically : File : MacAddressInjectHandler.java public class MacAddressInjectHandler implements SOAPHandler<SOAPMessageContext>{ @Override public boolean handleMessage(SOAPMessageContext context) { //…… //get mac address String mac = getMACAddress(); //add a soap header, name as "mac address" QName qname = new QName("http://ws.mkyong.com/", "mac …

Read more

JAX-WS : wsgen tool example

The wsgen tool is used to parse an existing web service implementation class and generates required files (JAX-WS portable artifacts) for web service deployment. This wsgen tool is available in $JDK/bin folder. Use cases 2 common use cases for wsgen tool : Generates JAX-WS portable artifacts (Java files) for web service deployment. Generates WSDL and …

Read more

JAX-WS : wsimport tool example

The wsimport tool is used to parse an existing Web Services Description Language (WSDL) file and generate required files (JAX-WS portable artifacts) for web service client to access the published web services. This wsimport tool is available in the $JDK/bin folder. Use Case An common use case of this wsimport tool. 1. Server – Published …

Read more

Container Authentication with JAX-WS – (Tomcat version)

In this article, we show you how to implement container authentication with JAX-WS, under Tomcat 6.0. In this way, the authentication is declarative rather than programmatic like this – application authentication in JAX-WS. And Tomcat implement the container authentication via security realm. At the end of this article, the deployed web service will authenticate user …

Read more

Application Authentication with JAX-WS

One of the common way to handle authentication in JAX-WS is client provides “username” and “password”, attached it in SOAP request header and send to server, server parse the SOAP document and retrieve the provided “username” and “password” from request header and do validation from database, or whatever method prefer. In this article, we show …

Read more

How to bypass certificate checking in a Java web service client

In Java web service development environment, developer are always generate a test certificate using keytool. While doing client testing, often times, the web service test client will hits following error messages : java.security.cert.CertificateException: No name matching localhost found SunCertPathBuilderException: unable to find valid certification path to requested target Here’s a source code, that i copied …

Read more

SunCertPathBuilderException: unable to find valid certification path to requested target

1. Problem Set up a localhost Tomcat to support SSL and deployed this web service for testing. While connecting to the deployed web service over SSL connection via this URL : https://localhost:8443/HelloWorld/hello?wsdl, it hits Terminal javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Caused by: sun.security.validator.ValidatorException: PKIX …

Read more

java.security.cert.CertificateException: No name matching localhost found

Problem Configured Tomcat to support SSL and deployed this simple hello world web service. And use following client connect to the deployed web service over SSL connection : package com.mkyong.client; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import com.mkyong.ws.HelloWorld; public class HelloWorldClient{ public static void main(String[] args) throws Exception { URL url = new URL("https://localhost:8443/HelloWorld/hello?wsdl"); QName …

Read more

Deploy JAX-WS web services on Tomcat

Here’s a guide to show you how to deploy JAX-WS web services on Tomcat servlet container. See following summary steps of a web service deployment. Create a web service (of course). Create a sun-jaxws.xml, defines web service implementation class. Create a standard web.xml, defines WSServletContextListener, WSServlet and structure of a web project. Build tool to …

Read more

JAX-WS attachment with MTOM

A complete JAX-WS SOAP-based example to show how to use Message Transmission Optimization Mechanism (MTOM) and XML-Binary Optimized Packaging (XOP) technique to send a binary attachment (image) from server to client and vice verse. Note There are ton of articles about what’s MTOM and the benefits of using it (see reference sites below), but it’s …

Read more

Wrapper class package.jaxws.methodName is not found. Have you run APT to generate them?

Problem In JAX-WS development, when following service endpoint is deploying, File : HelloWorld.java package com.mkyong.ws; //Service Endpoint Interface @WebService public interface HelloWorld{ @WebMethod String getHelloWorldAsString(); } File : HelloWorldImpl.java //Service Implementation package com.mkyong.ws; @WebService(endpointInterface = "com.mkyong.ws.HelloWorld") public class HelloWorldImpl implements HelloWorld{ @Override public String getHelloWorldAsString() { //… } } It hits following error message immediately? …

Read more

How to trace SOAP message in Eclipse IDE

In SOAP web service, each HTTP request or response encapsulates a SOAP envelope, these messages are easy to trace by using Eclipse IDE, build-in “TCP/IP monitor” tool. The idea is host another server in between the client and server to perform port forward function to intercept the HTTP traffic. 1. Normal SOAP envelope flows In …

Read more

java.lang.ClassNotFoundException : org.glassfish.external.amx.AMXGlassfish

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: org.glassfish.external.amx.AMXGlassfish Solution The JAX-WS dependency library “management-api.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “management-api.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException : org.glassfish.gmbal.ManagedObjectManager

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: org.glassfish.gmbal.ManagedObjectManager Solution The JAX-WS dependency library “gmbal-api-only.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “gmbal-api-only.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException : org.jvnet.staxex.XMLStreamReaderEx

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: org.jvnet.staxex.XMLStreamReaderEx Solution The JAX-WS dependency library “stax-ex.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “stax-ex.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException : javax.xml.ws.soap.AddressingFeature$Responses

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: javax.xml.ws.soap.AddressingFeature$Responses Solution The JAX-WS dependency library “jaxws-api.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “jaxws-api.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException : com/sun/xml/ws/policy/PolicyException

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: com/sun/xml/ws/policy/PolicyException Solution The JAX-WS dependency library “policy.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “policy.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException : com/sun/xml/bind/v2/model/annotation/AnnotationReader

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: com/sun/xml/bind/v2/model/annotation/AnnotationReader Solution The JAX-WS dependency library “jaxb-impl.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “jaxb-impl.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener Solution The JAX-WS dependency library “jaxws-rt.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “jaxws-rt.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat. Reference WSServletContextListener JavaDoc

JAX-WS – java.net.BindException: Address already in use: bind

Developing a Java web service development with JAX-WS, and publish an end point… public static void main(String[] args) { Endpoint.publish("http://localhost:8080/ws/hello", new WallStreetImpl()); } 1. Problem It hits the following error message. Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use: bind … Caused by: java.net.BindException: Address already in use: bind at …

Read more

java.lang.ClassNotFoundException : com/sun/xml/stream/buffer/XMLStreamBuffer

Problem Deploying a JAX-WS web service on Tomcat, hits following error message : java.lang.ClassNotFoundException: com/sun/xml/stream/buffer/XMLStreamBuffer Solution The JAX-WS dependency library “streambuffer.jar” is missing. Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “streambuffer.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.