ejb-3.0

How to specify name for resource annotations in compile time?

蹲街弑〆低调 提交于 2019-12-09 12:26:57
问题 Our code has something like this: @Resource(name = "java:comp/resource/foo/bar/ONE_QUEUE") private Queue queue; However, in one deployment scenario the queue annotation should look like this: @Resource(name = "java:comp/resource/foo/bar/SECOND_QUEUE") private Queue queue; I would like to choose the name to use with Maven build profiles. What options do I have? 回答1: This is not the right way to do things. Resources should be added to the local jndi name of individual EJBs. This is to separate

EJB3 with Spring

≡放荡痞女 提交于 2019-12-09 01:21:32
问题 I have understood that if I use EJB in Spring context, I get all the same benefits as if I was using it in "pure" EJB3 environment, is this true? I have googled but can't find a definitive, clear answer. For example, let's say I have a session bean that updates some tables in the database and it throws a System Exception. In "pure" EJB3 environment the transaction is rolled back. What if I for example @Autowire this bean using Spring, does Spring take care of the transaction handling same way

Can i make my own Singleton Stateless Bean with EJB 3.0?

家住魔仙堡 提交于 2019-12-08 07:51:09
问题 Now, with EJB 3.1, we can find the javax.ejb.Singleton annocation that can ensure that this bean is going to be singleton. Is there a way that i can ensure singleton using stateless beans in EJB 3.0 with some modifications in my code (use of the keyword static, or other way to do that....) 回答1: If you're able to limit your @Stateless bean pool size to exactly 1, then you can get pretty close to an @Singleton . The effect would be like having an @Singleton that uses @Lock(WRITE) for all calls

EJB3 Client Lookup

和自甴很熟 提交于 2019-12-08 07:37:30
问题 I am trying to invoke a EJB from a standalone Java client, getting the below error. Lookup code String localJNDIName = "ejbremote:gcmsnew/gcmsutilbeans.jar/CustomerSurveyManageQstBean#com.smbcgroup.gcms.utility.bl.survey.CustomerSurveyManageQstRemote"; InitialContext ic = new InitialContext(); GCMSBaseRemote bean = (GCMSBaseRemote)ic.lookup(localJNDIName); Exception javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: ejbremote at com.ibm

Am I using EJBs properly?

时光毁灭记忆、已成空白 提交于 2019-12-08 02:03:29
问题 I am using a JEE6 stack including JPA 2.0, JSF 2.0, EJB 3.1 etc. The way my architecture is setup is the following: I have JPA annotated DAOs using hibernate as my JPA provider. I have JSF Managed beans which correspond to my facelet/xhtml pages. I have EJBs that handle all of my database requests. My XHTML pages have JSF EL which make calls to my Managed beans. My managed beans contain references to my DAO entities which are managed by EJBs. For example, I have a user entity which is mapped

ThreadLocal (and Singleton) in EJB Container

不打扰是莪最后的温柔 提交于 2019-12-07 17:35:31
问题 I've written an authorization system which relies on objects representing the current user. To simplify programming and increase performance I want to hold those objects in a ThreadLocal after the user has logged in. It looks like this: public class UserCache { private static final ThreadLocal<User> cache = new ThreadLocal<User>(); public User getCurrentUser() { return cache.get(); } public void setCurrentUser(User user) { cache.set(user); } } I've read that static elements make clustering

EJB3 DataSource DataSource.getConnection

谁说胖子不能爱 提交于 2019-12-07 13:00:53
问题 In a CMT J2EE environement (Container Managed Transaction) what transaction / connection is used when I JDNI-lookup for a DataSource object and invoke DataSource.getConnection ? Is this connection part of the (potentially distributed) transaction? Does getConnection() return the same Connection every time I call it for the same DataSource object? I only know using Connections by the same EntityManager using native SQL statements. It is something that keeps me puzzling. As I understood the

JMS queue message receive order

只愿长相守 提交于 2019-12-07 11:55:05
问题 I am adding two JMS messages in the same destination sequentially. Will both of these messages be received in the same order in which I have added them or is there a chance for reverse ordering, that is, which ever the message is received first in the destination will be retrieved first. I am adding into a destination as: producer.send(Msg1); producer.send(Msg2); Msg1 and Msg2 will be added sequentially in all the cases (like network failures and latency. etc.)? 回答1: Message ordering is not

How do I call a remote EJB in an EAR from another?

自作多情 提交于 2019-12-07 01:58:53
问题 In Weblogic 10.3, how do I inject a remote EJB from one EAR into a Stateless bean of another, both EARs being deployed in the same container? Ideally I'd like to do as much as possible with annotations. So suppose I have the following interface: public interface HelloService { public String hello(); } implemented by the following EJB: @Stateless @Remote public class HelloServiceBean implements HelloService { public String hello() { return "hello"; } } Suppose they're packaged and deployed in

EJB3 or “Spring3 + hibernate” which one suitable

余生颓废 提交于 2019-12-07 01:52:24
问题 There are so many things are common in in EJB3 and Spring 3 with hibernate. I need to findout where I can use Spring framework with hibernate not EJB3 and viceversa. 回答1: You can use them interchangeably. If you go with EJB3, you'll have to have a full Java EE, EJB3 app server. Some are free, some are not. If you go with Spring 3, you need to have the Spring JARs in your CLASSPATH, but a full Java EE app server is not required. Tomcat or Jetty are sufficient, depending on your needs. There