Search code examples
glassfishejbcode-injection

EJB Injection failure on deploy


I've got a problem exxh EJB's.

First of all, my setup: I am using GlassFish & JEE6. I have got a REST-Service packaged as a WAR and a bean packaged as an EJB-Jar. They are not inside an EAR. The EJB should be used from the REST-WAR via @EJB, but when I try to deploy the WAR, GlassFish shows this error:

Error occurred during deployment:

Exception while deploying the app [exx-upload-1.0] : Cannot resolve reference Local ejb-ref name=com.ex.exx.model.FileUpload/ocr,Local 3.x interface =com.ex.exx.api.IOCRService,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session. Please see server.log for more details.

(The EJB was deployed before without any erros).

I have no clue why. Here is the EJB Code:

Interface:

@Local
public interface IOCRService {
    public String performOCRonImage(BufferedImage input);
}

and Implementation:

@Stateless
@LocalBean
public class OCRScanner implements IOCRService  {

    private Logger logger = Logger.getLogger(this.getClass().getName());
    private final static String NOT_RECOGNIZED = "Can not regocnize text";
    /**
     * Default constructor.
     */
    public OCRScanner() {
        logger.log(Level.INFO, "### OCR SCANNER BUILD" + this);
    }



    public String performOCRonImage(BufferedImage input) {
        logger.log(Level.INFO, "### OCR SCANNER CALLED" + this);
    }

    ...

And here is the important part in the WAR:

public class FileUpload {
private final File PROPERTIES_FILE = new File(
        "fileUploadProperties.properties");
private final String PARAMETER_NAME = "file";
private final Logger logger = Logger.getLogger(this.getClass().getName());


@EJB
private IOCRService ocr;

public Response uploadFile(...) {
    // do some stuff
    logger.log(Level.INFO, "### EJB" + ocr.toString())
}

Anny suggestions? I can not find my failure here.


Solution

  • Solved this, by replaceing @Local with @Remote. This works, however, I am not satisfied as I do not understand why.