I've been working on adding basic persistence to a Spring/CXF web service. The setup is pretty straightforward, and is based closely on the PetClinic sample in the spring distribution. However, once I tried to run a JUnit test to validate a save operation in my persistence DAO, I got this error message:
"No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here"
The short solution: Make sure that your hibernate properties contain the following:
- hibernate.current_session_context_class = thread
- hibernate.transaction.factory_class = org.hibernate.transaction.JDBCTransactionFactory
I haven't investigated yet what the impact of these changes will be on performance, etc. However, it does resolve this error message.
The details:
- CFX 2.1.1
- JBoss 4.0.5GA
- Hibernate 3.2.6ga
- Sun JDK 1.6_6
- Spring 2.5.4
The context:
* Trying to save an object to a database via a Spring-configured Hibernate session
Thursday, July 3, 2008
Wednesday, July 2, 2008
CXF: X is not a valid SOAP version
Again, a very simple solution, but not at all clear if you're looking at errors in the logs. The basic meaning of this error is that the web service client proxy is attempting to parse the soap envelope from a web service, but cannot find a valid SOAP version in the root element.
The confusing part here is that (at least in my case), it wasn't due to a bad WSDL or bad XML. It was simply that I was pointing my client to the actual WSDL URL instead of the service endpoint. More specifically, I was doing this:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(UserService.class);
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setAddress("http://localhost:8080/my-service/MyService?wsdl");
return (MyService) factory.create();
instead of this:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(UserService.class);
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setAddress("http://localhost:8080/my-service/MyService");
return (MyService) factory.create();
The short solution: Go check your code for creating your service client. Make sure you're using the location of the service endpoint, NOT the URL for the wsdl itself.
The details:
- CFX 2.1.1
- JBoss 4.0.5GA
- Sun JDK 1.6_6
- Spring 2.5.4
The context:
* Trying to consume a web service using Spring & Apache CXF
* The client throws a SOAPFault whenever it calls the service because it is attempting to run an operation against the URL for the WSDL
The confusing part here is that (at least in my case), it wasn't due to a bad WSDL or bad XML. It was simply that I was pointing my client to the actual WSDL URL instead of the service endpoint. More specifically, I was doing this:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(UserService.class);
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setAddress("http://localhost:8080/my-service/MyService?wsdl");
return (MyService) factory.create();
instead of this:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(UserService.class);
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setAddress("http://localhost:8080/my-service/MyService");
return (MyService) factory.create();
The short solution: Go check your code for creating your service client. Make sure you're using the location of the service endpoint, NOT the URL for the wsdl itself.
The details:
- CFX 2.1.1
- JBoss 4.0.5GA
- Sun JDK 1.6_6
- Spring 2.5.4
The context:
* Trying to consume a web service using Spring & Apache CXF
* The client throws a SOAPFault whenever it calls the service because it is attempting to run an operation against the URL for the WSDL
CXF Web Services: No write method for property X
This is actually a very simple problem that is frustratingly hard to solve if you're simply looking at error messages in your logs. Essentially, this error means "No method available for setting property X".
The short solution: Go check your class definition for whichever class is the subject of this error, and make sure you have a public setter method for that property.
The details:
- CFX 2.1.1
- JBoss 4.0.5GA
- Sun JDK 1.6_6
- Spring 2.5.4
The context:
* Trying to consume a web service using Spring & Apache CXF
* The client successfully connects to the web service and completes the call, but the CXF proxy throws an error while deserializing the SOAP response to a Java object.
The short solution: Go check your class definition for whichever class is the subject of this error, and make sure you have a public setter method for that property.
The details:
- CFX 2.1.1
- JBoss 4.0.5GA
- Sun JDK 1.6_6
- Spring 2.5.4
The context:
* Trying to consume a web service using Spring & Apache CXF
* The client successfully connects to the web service and completes the call, but the CXF proxy throws an error while deserializing the SOAP response to a Java object.
Subscribe to:
Comments (Atom)