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 Metro on WebSphere 7 – com.ibm.xml.xlxp2.jaxb.JAXBContextImpl incompatible exception

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 an interface, and JAXB can’t handle interfaces

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 Spring + jax-ws : ‘#xxx’ is not a valid value for ‘NCName’

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.apache.xbean.spring.context.v2.XBeanNamespaceHandler

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 java.lang.ClassNotFoundException: org.springframework.beans.factory.support.ReaderContext

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 javax.xml.stream.XMLStreamException : ParseError at [row,col]:[x,xx]

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 Container Authentication with JAX-WS – (Tomcat version)

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 Application Authentication with JAX-WS

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 How to bypass certificate checking in a Java web service client

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 SunCertPathBuilderException: unable to find valid certification path to requested target

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 java.security.cert.CertificateException: No name matching localhost found

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 Deploy JAX-WS web services on Tomcat

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 Wrapper class package.jaxws.methodName is not found. Have you run APT to generate them?

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.

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.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.

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

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.

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

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.

Read more 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: 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.

Read more 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/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.

Read more 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.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

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

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 JAX-WS – java.net.BindException: Address already in use: bind

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.

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