ejb

Does ejb stateless class has to be public?

半城伤御伤魂 提交于 2019-12-24 05:29:06
问题 Can @Stateless class have different modifiers than public? In documentation I have only found constraints of constructor/methods visibility, but nothing interesting about class level access. 回答1: According to ejb3-1 specification: 4.9.2 Session Bean Class The following are the requirements for the session bean class: • The class must be defined as public, must not be final, and must not be abstract. The class must be a top level class 来源: https://stackoverflow.com/questions/25867608/does-ejb

EJB creating using SessionBean EJBObject and EJBHome interfaces

时光总嘲笑我的痴心妄想 提交于 2019-12-24 03:32:13
问题 I am confused about creating EJB I have seen many samples of EJB on the internet and also sample project in which an EJB is developed using SessionBean , EJBObject and the EJBHome interfaces. In some other examples EJB is created without these interfaces and using only one or two interfaces e.g. if its locally accessible, javax.ejb.Local interface is used while for remotely access javax.ejb.Remote is used. So i am confused about creating EJB. What is the difference between these two type? I

How to distribute an event to all nodes in a (Wildfly) cluster?

岁酱吖の 提交于 2019-12-24 03:08:25
问题 I would like to notify all nodes in a cluster when the state of a longer running process in my JavaEE 7 WebApp changes, so that every node can in turn notify their clients via WebSocket about that change. I am working with Wildfly 10 in a clustered environment. What JavaEE 7 API / Programming model or Wildfly Service would be todays best practice to achieve that ? 回答1: If you want to stay within JavaEE ecosystem, then JMS topic is the way to go. Topics are like broadcast channels - every

EJB @Schedule issue

五迷三道 提交于 2019-12-24 02:42:08
问题 I need to schedule a task in my web application. The task needs to use a member field of the Servlet that is initialized during deployment. I have used the EJB @Schedule . However when the task is fired, the member field is null. I guess that the cause lies in the fact that I had to add the @Stateless annotation to the servlet in order to make the @Schedule work, and my Servlet needs to preserve its state indeed? If yes, how can I fire my task in a simple and efficace way? Using GlassFish 3

EJB @Schedule issue

时光怂恿深爱的人放手 提交于 2019-12-24 02:42:05
问题 I need to schedule a task in my web application. The task needs to use a member field of the Servlet that is initialized during deployment. I have used the EJB @Schedule . However when the task is fired, the member field is null. I guess that the cause lies in the fact that I had to add the @Stateless annotation to the servlet in order to make the @Schedule work, and my Servlet needs to preserve its state indeed? If yes, how can I fire my task in a simple and efficace way? Using GlassFish 3

Multiple EntityManagers managed by the container (CMT)

心不动则不痛 提交于 2019-12-24 02:20:13
问题 I have the following situation: My applications needs to dynamically connect to multiple databases, so after a lot of search I think the best option is to do create multiple EntityManagers and decide at runtime which one to use. Here is the code: public class GenericDao { @PersistenceContext(unitName = "db1") protected EntityManager em1; @PersistenceContext(unitName = "db2") protected EntityManager em2; @PersistenceContext(unitName = "db3") protected EntityManager em3; } This way I can

ClassCastException when using embedded glassfish for unit tests

人走茶凉 提交于 2019-12-24 00:34:52
问题 I'm running some unit tests on some EJBS via maven and an embedded glassfish container. One of my tests works, but all subsequent attempts to test a different EJB result in the same error: java.lang.ClassCastException: $Proxy81 cannot be cast to Followed by whatever bean I'm attempting to test. I'm confident my setup is good since, as I say, one of my beans can be tested properly. Examples of workiing code: @Stateful public class LayoutManagerBean implements LayoutManager { private final Log

How do I run a standard Arquillian EJB Session Test with Maven?

天大地大妈咪最大 提交于 2019-12-23 22:54:45
问题 I'm brand new to Arquillian and Maven, having just started with both this week so I apologize for the simple question. Needless to say I've put in some real hours learning the ropes. For my latest trick I'm trying to setup a standard EJB Session Bean. Most of my knowledge has come from the Arquillian getting started guides: http://arquillian.org/guides/getting_started/ http://arquillian.org/guides/getting_started_rinse_and_repeat/ http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US

EJB: Dependency injection without Interface

烂漫一生 提交于 2019-12-23 20:45:29
问题 I had this code @Local interface IRepo { //... } @Stateless class Repo implements IRepo { // .. } class WebS { @EJB private IRepo repo; // ... } And all worked normally. But now I remove interface IRepo and make @Stateless class Repo { // .. } class WebS { @EJB private Repo repo; // ... } and JNDI look up fails. could not resolve global JNDI name for @EJB for container WebS ... Can I make Dependency injection without Interface? 回答1: You should use @Stateless @LocalBean // <-- annotation here

How do I correctly use SNAPSHOTS dependencies with EARs and EJBs

半城伤御伤魂 提交于 2019-12-23 19:24:37
问题 I am trying to build an EJB in an EAR. My EJB has dependencies on SNAPSHOTS. So when I build the EAR my structure looks like this: my-ear-1.0.0-SNAPSHOT.ear + META-INF - application.xml - MANIFEST.MF - my-ejb-1.0.0-SNAPSHOT.jar - third-party-lib-1.0.0-SNAPSHOT.jar However, when using the maven-ejb-plugin to generate its MANIFEST.MF: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.3</version> <configuration> <archive> <manifest>