EJB注入失败部署 [英] EJB Injection failure on deploy
问题描述
我有一个问题exxh EJB的。
I've got a problem exxh EJB's.
首先,我的设置:我正在使用GlassFish& JEE6。我得到一个REST-Service打包成WAR,一个bean作为EJB-Jar打包。他们不在EAR内。
应该通过@EJB从REST-WAR使用EJB,但是当我尝试部署WAR时,GlassFish会显示此错误:
First of all, my setup: I am using GlassFish & JEE6. I 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:
部署:部署应用程序时出现异常[exx-upload-1.0]:无法解析引用局部ejb-ref name = com.ex.exx.model.FileUpload / ocr,Local 3.x interface = com.ex.exx.api。 IOCRService,EJB链接= NULL,查找=,= mappedName,JNDI名称=,= RefType的会话。请参阅server.log了解更多详细信息。
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.
(EJB已部署之前没有任何错误)。
(The EJB was deployed before without any erros).
我不知道为什么。以下是EJB代码:
I have no clue why. Here is the EJB Code:
接口:
@Local
public interface IOCRService {
public String performOCRonImage(BufferedImage input);
}
和实现:
@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);
}
...
这里是重要的在WAR中的一部分:
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.
推荐答案
通过用@Remote替换@Local来解决这个问题。
但是,我不满意,因为我不明白为什么。
Solved this, by replaceing @Local with @Remote. This works, however, I am not satisfied as I do not understand why.
这篇关于EJB注入失败部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!