[jboss-user] [JBossWS] - Re: EntityManager injection in Webservice
froden
do-not-reply at jboss.com
Wed Jan 16 09:19:10 EST 2008
I have a similar problem.
The interface for the EJB:
package services;
|
| import javax.ejb.Local;
|
| @Local
| public interface TestServiceInterface {
| public String getString();
| }
The EJB itself:
package services;
|
| import javax.ejb.Stateless;
| import javax.jws.WebMethod;
| import javax.jws.WebService;
| import javax.jws.soap.SOAPBinding;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| @Stateless
| @WebService
| @SOAPBinding(style=SOAPBinding.Style.RPC)
| public class TestService implements TestServiceInterface {
|
| @PersistenceContext
| private EntityManager em;
|
| @WebMethod
| public String getString() {
| System.out.println("em: " + em);
| return "Quite frankly, it gives me the heebie jeebies.";
| }
| }
The web service is defined in my web.xml like this:
<servlet>
| <servlet-name>TestService</servlet-name>
| <servlet-class>services.TestService</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>TestService</servlet-name>
| <url-pattern>/TestService.ws</url-pattern>
| </servlet-mapping>
| </servlet>
The web service works like it should, but the EntityManager is not injected. System.out.println("em: " + em); in the webmethod always prints a null.
Any clues?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120463#4120463
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120463
More information about the jboss-user
mailing list