天道酬勤,学无止境

ejb-3.0

带有弹簧的 EJB3(EJB3 with Spring)

问题 我已经明白,如果我在 Spring 上下文中使用 EJB,我将获得与在“纯”EJB3 环境中使用它一样的好处,这是真的吗? 我用谷歌搜索过,但找不到明确的、明确的答案。 例如,假设我有一个会话 bean,它更新数据库中的一些表,并抛出一个系统异常。 在“纯”EJB3 环境中,事务被回滚。 例如,如果我使用 Spring 来 @Autowire 这个 bean,那么 Spring 是否像 EJB3 容器一样处理事务? 或者是什么? 它可能需要一些特定的配置还是完全“自动”? 回答1 我已经明白,如果我在 Spring 上下文中使用 EJB,我将获得与在“纯”EJB3 环境中使用它一样的好处,这是真的吗? 您通常使用 POJO + Spring或EJB3。 我对“Spring 中的 EJB”是什么意思有点困惑...... POJO + Spring 和 EJB3 现在非常接近,并且在声明式事务管理方面具有相同的功能。 我不知道关于security 的所有细节,但我想说这两种技术也非常相似。 实际上 Spring 和 EJB3 都依赖于其他规范。 重要的是:JPA(持久性)、JTA(分布式事务)、JMS(消息传递)、JDBC(数据源)。 两种技术堆栈中都存在对此的良好支持。 这两种技术都变得非常灵活,您可以选择使用或不使用。 因此,您可以在应用程序中使用 EJB3。 服务器并且很轻

2021-11-29 04:47:56    分类:技术分享    java   spring   transactions   ejb-3.0   autowired

Is it safe to inject an EJB into a servlet as an instance variable?

We all know that in the web tier there is the possibility that only a single instance of a given Servlet exists which services multiple requests. This can lead to threading issues in instance variables. My question is, is it safe to inject an EJB using the @EJB annotation into a servlet as an instance variable? My initial instinct would be no, under the assumption that the same instance of the EJB would service multiple requests at the same time. It would seem that this would also be the instinct of a number of other programmers: Don't inject to servlets However have I jumped to the wrong

2021-11-28 16:52:56    分类:问答    servlets   ejb-3.0   code-injection

Is using data transfer objects in ejb3 considered best practice

Although obviously not all scenarios can be covered by a single design, is it generally felt now that ORM classes should be passed to and fro between the presentation and business layer (either local or remote), replacing the need for data transfer objects? As far as I can see, using ORM classes presents problems of unnecessary eager loading, context management issues and tight coupling, but also saves a great deal of time and keeps things simple. Is there now a standard approach that generally favours one over the other (for the majority of situations)?

2021-11-28 16:38:16    分类:问答    hibernate   design-patterns   jakarta-ee   ejb-3.0

Best features of EJB 3

The scenario You have developed a webapp using EJBs version 3. The system is deployed, delivered and is used by the customer. If you would have to rewrite the system from scratch, would you use EJBs again? No: Don't answer this question, answer this one instead. Yes: Provide one important, real problem that EJBs solved, based on your personal experience. Let the answer contain just one problem. This will let other readers vote up the best feature of EJBs.

2021-11-28 04:51:54    分类:问答    java   jakarta-ee   ejb-3.0

JBoss事务超时设置?(JBoss transaction timeout setting?)

问题 我们在 JBoss 5.1.0.GA 应用程序中有一个定时器服务触发任务,问题是我们无法更改事务超时。 这个长 Lucene 索引可能需要比默认的 300 秒限制更长的时间。 问题是如何更改超时值,将@TransactionTimeout(1800) 添加到worker 方法或类没有任何效果。 编辑:在 deploy/transaction-jboss-beans.xml 中设置它工作正常: <property name="transactionTimeout">1800</property> 但是注释似乎对计时器启动的或正常的无状态 EJB 没有影响。 回答1 我正在将 EJB3 与 Jboss 5.1.0.GA 一起使用,并成功地在JBOSS_HOME/deploy/transaction-jboss-beans.xml设置了这个值。 <property name="transactionTimeout">300</property>的默认<property name="transactionTimeout">300</property> 回答2 事务超时,JBOSS EPA 7.1 版本默认设置为 300。 添加这一行( <coordinator-environment enable-tsm-status="true" default-timeout="1200"/>

2021-11-28 01:46:28    分类:技术分享    jboss   timeout   ejb-3.0   transactions   jboss5.x

How does EJB and JPA relate? [duplicate]

This question already has answers here: Relationship between EJB 3.0 and JPA? (4 answers) Closed 4 years ago. I am reading the EJB 3 in Action book and I have the following question : Is the POJO's you write and annotate with @Entity and so on also a EJB entity type? I don't understand what JPA has to do with EJB. Isn't JPA a own specification now? The entities are also contained in a own persistence container. They talk about EJB 3 Java Persistence API etc. but I don't understand what entities has to do with EJB.

2021-11-27 16:12:11    分类:问答    java   jakarta-ee   jpa   ejb-3.0

EJB3 transaction rollback

I'm using CMT in EJB3 state-less session beans. Also I've created my own Exception having the annotation "@ApplicationException (rollback=true)". Do I have to use "context.setRollbackOnly()" when I want to rollback the transaction? Can I just rollback the transaction by throwing an exception inside public method in the bean? If so (the answer to Q#2 is yes) do I have to throw the exception out of the method by declaring the exception in the method or will it be sufficient to just throw an exception inside the method and handle it inside the same method itself? (I don't want to propagate the

2021-11-27 13:12:59    分类:问答    java   jakarta-ee   transactions   ejb-3.0   rollback

Examples or Uses Cases to explain EJB Transaction Attributes

There are some good explanations of EJB Transaction Attributes (and annotations) out there, for example, OpenEJB's. But sometimes when I try to cover this with someone who hasn't worked with many transactional resources, I see their eyes start to glaze over. So my question - how would you explain EJB Transaction Attributes to your grandmother? Required RequiresNew Mandatory NotSupported Supports Never I'm thinking a contrived example, analogy, or a concise real-world use case would be helpful.

2021-11-27 11:31:11    分类:问答    java   transactions   jakarta-ee   ejb-3.0

EJB3.0 Serializing a handle to a Stateful Bean

I'm attempting to persist the remote handle to a Stateful EJB3.0 bean. This bean's interface is defined: @Remote public interface Hello extends Serializable { Handle getHandle(); void sayHello(); } The implementation is: @Stateful @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class HelloBean implements Hello { @Resource private SessionContext ctx; @Override public Handle getHandle() { try { return ctx.getEJBObject().getHandle(); } catch (Exception e) { throw new RuntimeException(e); } } @Override public Handle sayHello() { System.out.println("hello"); } } According to

2021-11-26 01:59:00    分类:问答    java   jakarta-ee   glassfish   ejb-3.0

Java EE: Proxy cannot be cast to Local Interface, maybe classloading issue?

I'm currently "rearranging" my Java EE application, which consists of three components: MyAppInterface: mostly JPA- and JAXB-annotated POJOs, also some EJB Local Interfaces MyAppServer: JPA Facades, EJBs, Jersey resources MyAppWeb: GWT frontend, communicates with MyAppServer via HTTP/REST via loadbalancer Both MyAppServer and MyAppWeb use the classes defined in MyAppInterface; MyAppServer "exports" some of its EJBs via local interfaces in MyAppInterface. MyAppInterface is kind of the API, it's what you need to work with MyAppServer. In Maven I am packaging MyAppInterface as jar, both

2021-11-25 10:50:28    分类:问答    jakarta-ee   ejb-3.0   classloader