Hi Gytis,
I tried EAP 7.0 today, unfortunately got NPE of txbridge outbound. I put all my test code to https://github.com/JonkeyGuan/txbridgeInEAP7
I was using the same approach as I did in Tomcat 8.
could you help to figure out the reason and provide the correct approach of txbridge outbound?
list exception below:
==================================
22:12:15,322 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "ServiceA1.war" with deployment "ServiceA1.war"
22:12:19,328 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (default task-9) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
22:12:19,382 INFO [com.test.user.service.UserServiceImpl] (default task-11) updating local user ...
22:12:19,387 INFO [com.test.user.service.UserServiceImpl] (default task-11) updated
22:12:19,387 INFO [com.test.user.service.UserServiceImpl] (default task-11) updating remote user ...
22:12:19,412 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-11) Creating Service {http://service.user.test.com/}inboundUserService from WSDL: http://localhost:8280/ServiceB1/inboundUserService?wsdl
22:12:19,417 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-11) Creating Service {http://service.user.test.com/}inboundUserService from WSDL: http://localhost:8280/ServiceB1/inboundUserService?wsdl
22:12:19,432 ERROR [org.jboss.jbossts.txbridge] (default task-11) java.lang.NullPointerException
22:12:19,433 INFO [com.test.user.service.UserServiceImpl] (default task-11) updated
22:15:23,710 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-13) Creating Service {http://service.user.test.com/}UserService from WSDL: http://localhost:8180/ServiceA1/UserService?wsdl
22:15:23,713 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-13) Creating Service {http://service.user.test.com/}UserService from WSDL: http://localhost:8180/ServiceA1/UserService?wsdl
22:15:23,724 INFO [com.test.user.service.UserServiceImpl] (default task-15) updating local user ...
22:15:23,730 INFO [com.test.user.service.UserServiceImpl] (default task-15) updated
22:15:23,730 INFO [com.test.user.service.UserServiceImpl] (default task-15) updating remote user ...
22:15:23,743 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-15) Creating Service {http://service.user.test.com/}inboundUserService from WSDL: http://localhost:8280/ServiceB1/inboundUserService?wsdl
22:15:23,748 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-15) Creating Service {http://service.user.test.com/}inboundUserService from WSDL: http://localhost:8280/ServiceB1/inboundUserService?wsdl
22:15:23,758 ERROR [org.jboss.jbossts.txbridge] (default task-15) java.lang.NullPointerException
22:15:23,759 INFO [com.test.user.service.UserServiceImpl] (default task-15) updated
==================================
core code:
===================================
@WebService(portName = "OutbounUserPort", serviceName = "OutboundUserService", endpointInterface = "com.test.user.service.UserService")
@HandlerChain(file = "/jaxws-handlers-outbound.xml")
public class OutboundUserServiceImpl extends UserServiceImpl {
}
------------------------------------------
jaxws-handlers-inbound.xml
<!-- Server side config file for inbound bridging -->
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
<handler-chain>
<protocol-bindings>##SOAP11_HTTP</protocol-bindings>
<handler>
<handler-name>TransactionBridgeHandler</handler-name>
<handler-class>org.jboss.jbossts.txbridge.inbound.JaxWSTxInboundBridgeHandler</handler-class>
</handler>
<handler>
<handler-name>WebServicesTxContextHandler</handler-name>
<handler-class>com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor</handler-class>
</handler>
</handler-chain>
</handler-chains>
------------------------------------------
public class ClientFactory {
private static URL loalServiceURL;
private static URL remoteServiceURL;
static {
try {
loalServiceURL = new URL("http://localhost:8180/ServiceA1/UserService?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
remoteServiceURL = new URL("http://localhost:8280/ServiceB1/inboundUserService?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
private static QName localQName = new QName("http://service.user.test.com/", "UserService");
private static QName remoteQName = new QName("http://service.user.test.com/", "inboundUserService");
public static UserService getClient() {
return getClient(loalServiceURL, localQName);
}
public static UserService getRemoteClient() {
UserService client = getClient(remoteServiceURL, remoteQName);
BindingProvider bindingProvider = (BindingProvider) client;
bindingProvider.getBinding().setHandlerChain(getOutboundHandlers());
return client;
}
private static UserService getClient(URL url, QName qName) {
UserService client = null;
Service service = Service.create(url, qName);
client = service.getPort(UserService.class);
return client;
}
@SuppressWarnings("rawtypes")
private static List<Handler> getOutboundHandlers() {
List<Handler> handlers = new ArrayList<Handler>();
handlers.add(new JaxWSTxOutboundBridgeHandler());
handlers.add(new JaxWSHeaderContextProcessor());
return handlers;
}
}
------------------------------------------
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false) |
| public void updateUser(User user) { |
log.info("updating local user ...");
userMapper.updateByID(user);
log.info("updated");
// for the dups to rollback
// userMapper.add(user);
log.info("updating remote user ...");
ClientFactory.getRemoteClient().updateUser(user);
log.info("updated");