EJB3 Abstract

I am using JBoss 5 GA, I have created a test bean session and local frontend. I have created a servlet client. I tried to inject the interface into the servlet using @EJB ..

But when I call this servlet I got the requested resource which is not available !!!! When I comment // @EJB the page starts successfully, any help please

Jotnarta p>

+2


source to share


1 answer


It would be helpful to add some of your code to your question, at least annotations in your EJB, local interface (if you annotated it) and servlet ...

However, according to Chapter 11. Introduction to EJB Injection in Servlets JBoss EJB3 Tutorials , for an EJB module containing an EJB3 SLSB, defined as follows:

@Stateless(name="calculator")
@Remote(CalculatorRemote.class)
@Local(CalculatorLocal.class)
public class CalculatorBean implements CalculatorRemote, CalculatorLocal
{
...

      

The local interface can be injected into the web module servlet as follows:



private CalculatorLocal calculator;

/**
 * Injecting the EJB
 */
@EJB(name = "calculator")
public void setCalculator(CalculatorLocal calculator)
{
   this.calculator = calculator;
}

      

There is an important note in this tutorial that I am pasting below:

To inject into a web module, your web.xml must use the 2.5 version of the xsd web application:

<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">

      

+3


source







All Articles