[英]Java EE EJB 3.0 Annotations
I am working on Glassfish version 3 , when I am trying to compile app this error log appears in the log file, 我正在使用Glassfish版本3,当我尝试编译应用程序时,此错误日志出现在日志文件中,
SEVERE: The annotation symbol defined in super-class is not compatible with Session ejb ManagerDaoImpl
The annotations are @Singleton
and @Stateless
注释是
@Singleton
和@Stateless
Is there any way to solve this problem? 有什么方法可以解决这个问题吗?
The bean with @Singleton
annotations is for one instance by Java VM, and the bean with @Stateless
is for several instances by Java VM. 带有
@Singleton
注释的bean用于Java VM的一个实例,带有@Stateless
的bean用于Java VM的多个实例。
If you have commons methods, you can define a base class, something like next: 如果你有commons方法,你可以定义一个基类,如下所示:
public abstract class AbstractBean {
public void commonMethod() {
// do common operation
}
}
public interface LocalFoo {
public void foo();
}
public interface RemoteFoo {
public void foo();
}
@LocalBean
@Local(LocalFoo.class)
@Remote(RemoteFoo.class)
@Stateless
public class FooBean extends AbstractBean implements LocalFoo, RemoteFoo {
@Override
public void foo() {
// do something
}
}
Our bean is ; 我们的豆是;
@Stateless
@Singleton
public class ManagerDaoImpl extends AbstractDAO<X> implements ManagerDAO {
@EJB
PersonDAO personDao;
@PersistenceContext(unitName = "PoyrazPU")
private EntityManager em;
. 。 .
。 .
。
SEVERE: The annotation symbol defined in super-class is not compatible with Session ejb ManagerDaoImpl ++ SOLVED by using @LocalBean @Local(LocalFoo.class) instead of @Singleton 严重:超类中定义的注释符号与使用@LocalBean @Local(LocalFoo.class)而不是@Singleton的Session ejb ManagerDaoImpl ++ SOLVED不兼容
Our new bean is ; 我们的新豆是;
@Stateless
@LocalBean
@Local(MAanagerDAO.class)
public class ManagerDaoImpl extends AbstractDAO<X> implements ManagerDAO {
@EJB
PersonDAO personDao;
@PersistenceContext(unitName = "PoyrazPU")
private EntityManager em;
The problem is solved but there is a new problem about @Lock annotation. 问题已经解决,但@Lock注释存在新问题。 I got this error,
我收到了这个错误,
SEVERE: @Lock is only permitted for singleton session beans 严重:@Lock仅允许用于单例会话bean
@Asynchronous
@Lock()
@AccessTimeout(-1)
@Override
public void doStuff(Mass mass) {
for (int i = 0; i < RETRY_COUNT; i++) {
notify(mass);
try {
Thread.sleep(TIME);
} catch (InterruptedException ex) {
BeanLogger.logError("Thread sleep threw exception while informing masses: ", new ThreadSleepException(ex));
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.