- This topic has 1 reply, 2 voices, and was last updated 15 years, 1 month ago by Brian Fernandes.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
ddelenMemberHi ,
I try to write a simple WS useing Jax-Ws. in the i,plementation of the service I want too use spring. The problem is that spring is not injected. So my bean stay null which caused a NPE
My applicationContext.xml
<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" > <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="swimgateservicesPU" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="userRepository" class="be.swimgate.integration.repository.UserRepository"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> </beans>
My web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <description>JAX-WS endpoint - LogInServiceService</description> <display-name>LogInServiceService</display-name> <servlet-name>LogInServiceService</servlet-name> <servlet-class> com.sun.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>LogInServiceService</servlet-name> <url-pattern>/LogInServicePort</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> </web-app>
And the ws implentation, which is called via Delegation
@Service public class LogInService { @Autowired UserRepository userRepository; public UserDTO doLogIn(String userId, String password) { User user = userRepository.findByUsernameAndPassword(userId, password);
userrepository is always null , deployment on Tomcat 6
Any one an idea?
tx
Diederik
Brian FernandesModeratorDiederik,
The injection will not happen because the beans are not obtained from a Spring context.
You will need to use the Spring servelet and listener as detailed here:
https://jax-ws-commons.dev.java.net/spring/a more detailed explanation is here: http://jgeeks.blogspot.com/2008/09/exposing-jax-ws-web-service-using.html
Hope this helps.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)