OK, I tried:
@Stateless
public class SimpleEJB {
@Resource
SessionContext context;
public String sayHello(String name) {
System.out.println("context: " + context.getContextData());
return "Hello " + name + "!!!";
}
}
and invoked bean method in the Servlet as:
@EJB SimpleEJB bean;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException {
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h2>Serving at: " + request.getContextPath() +
"</h2>");
out.println("<h2>Invoking EJB: " + bean.sayHello("Duke") + "</h2>");
out.println("</body></html>");
}
and saw the following in the console:
[#|2010-03-04T16:43:58.091-0800|INFO|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=http-thread-pool-8080-(1);|context:
{}|#]
This is expected because there is no data in the context. There are
several samples showing PersistenceUnit injection at:
http://blogs.sun.com/arungupta/tags/jpa
Can you make sure that persistence.xml is in WEB-INF/classes/META-INF/ ?
-Arun
On 3/4/10 4:30 PM, glassfish_at_javadesktop.org wrote:
> Has nobody any more idea what could be the problem here? :(
> [Message sent by forum member 'homer86' (baltasar86_at_web.de)]
>
> http://forums.java.net/jive/thread.jspa?messageID=390173
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
--
Need Application Server ? Download from http://glassfish.org
Blog: http://blogs.sun.com/arungupta