"ALRubinger" wrote : @EJB injection into Servlets isn't yet supported, Yannik.
I have a similar problem; for one I also wanted to inject a stateless bean into
a servelt, but since that doesn't seem to work. So next I tried injecting the
same bean in a "normal" app, but I get the same problem :(
App-Code:
| public class SimpleTest
| {
|
| @EJB
| private static ICustomerDispatcher disp;
|
| public static void main(String[] args)
| {
| injectionMode();
| }
|
| private static void injectionMode()
| {
| System.out.println("injectionmode!");
|
| if (disp != null)
| {
| Customer newCust = disp.createCustomer("Jane", "Smith");
|
| System.out.println(newCust.getLastName());
| System.out.println(newCust.getId());
| }
| else System.out.println("no dispatcher!!");
| }
|
Bean:
| @Stateless
| @Local(ICustomerDispatcher.class)
| @Remote(ICustomerDispatcher.class)
| public class CustomerDispatcherBean implements ICustomerDispatcher
| {
| @PersistenceContext
| EntityManager em;
|
| public static final String RemoteJNDIName =
CustomerDispatcherBean.class.getSimpleName() + "/remote";
| public static final String LocalJNDIName =
CustomerDispatcherBean.class.getSimpleName() + "/local";
|
| public Customer createCustomer(String firstName, String lastName)
| {
| Customer newCust = new Customer();
| newCust.setFirstName(firstName);
| newCust.setLastName(lastName);
| em.persist(newCust);
| return newCust;
| }
|
| public Customer findCustomer(int id)
| {
| return em.find(Customer.class, id);
| }
| }
|
And the interface:
| @Local
| @Remote
| public interface ICustomerDispatcher
| {
| public Customer createCustomer(String firstName, String lastName);
| public Customer findCustomer(int id);
| }
|
Well, I skipped the Customer entity ... since it's a POJO with an @Entity
annotation.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4011815#4011815
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4011815
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user