ejb-3.0

Read Environment Variables in persistence.xml file

家住魔仙堡 提交于 2019-12-18 13:28:40
问题 I want to read environment variables inside persistence.xml file. Idea is that i don't want my database details to be read from properties file as there is a change of getting properties file override.Instead i want to read details from environment variables. Is there any way to achieve this criteria. Iam using Spring 3 my standalone application will be deployed in unix machine. 回答1: You can update properties in a persistence unit by supplying a Map (see this). Conveniently, environment

Can EJB2 and EJB3 coexists in one application?

若如初见. 提交于 2019-12-18 12:30:49
问题 does anybody know if it is possible to iteratively replace EJB2.1 beans with EJB3 beans in Java EE application? That is: at one time remove one 2.1 bean from the code and add corresponding EJB3 bean that implements the same behavior without touching the rest of the code (+ be able to inject the legacy EJBs via annotations in the new EJB3). I am not expert at EJB specs (and I have experience only with EJB3), but to me EJB is a simply component with given business interface that is managed by

In what situations are EJBs used ? Are they required in websites/ web-application development?

家住魔仙堡 提交于 2019-12-18 12:03:02
问题 Are EJBS used in database backed websites(that are accessible to all)? 回答1: Nothing is ever required of course. If you wanted you could build a web-application as a single large C function behind CGI . That said, EJBs do make web application development a lot easier. It's not for nothing that they are included in the ultra-lightweight Web Profile of Java EE 6. EJB does not contain any Database APIs of itself, but it integrates extremely well with JPA. You can inject the EntityManager in it,

Is it okay to pass injected EntityManagers to EJB bean's helper classes and use it?

不想你离开。 提交于 2019-12-18 11:35:39
问题 We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its helpers. Is this safe? It has worked well until now, but I found out some Oracle document that states its implementation of EntityManager is thread-safe. Now I wonder whether the reason we did not have issues until now, was only because the implementation we were using happened to be thread-safe (we use Oracle). @Stateless class SomeBean { @PersistenceContext private EntityManager em; private SomeHelper

Multithreading in a stateless session bean?

女生的网名这么多〃 提交于 2019-12-18 01:05:00
问题 The EJB 3.0 specification does not allow a business method of a stateless session bean to create new threads. Why is that? What is wrong with creating additional worker threads that only do raw computations and never call into the app server? Say, my session bean implements a service that lets users to upload images, and the business method does cpu-intensive image processing on these images. Then it can only use one cpu core to do this job, even if the machine has 8 or more cores? If i

Best current framework for unit testing EJB3 / JPA [closed]

我只是一个虾纸丫 提交于 2019-12-17 22:32:11
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Starting a new project using EJB 3 / JPA, mainly stateless session beans and batch jobs. I've used JUnit in the past on standard Java webapps and it seemed to work pretty well. In EJB2 unit testing was a pain and required a running container such as JBoss to make the calls

Elegantly handling constraint violations in EJB/JPA environment?

浪尽此生 提交于 2019-12-17 18:28:51
问题 I'm working with EJB and JPA on a Glassfish v3 app server. I have an Entity class where I'm forcing one of the fields to be unique with a @Column annotation. @Entity public class MyEntity implements Serializable { private String uniqueName; public MyEntity() { } @Column(unique = true, nullable = false) public String getUniqueName() { return uniqueName; } public void setUniqueName(String uniqueName) { this.uniqueName = uniqueName; } } When I try to persist an object with this field set to a

No EJB receiver available for handling

蹲街弑〆低调 提交于 2019-12-17 15:56:21
问题 I'm using EJB 3.0 with JBoss AS 7.1.1 Final. I am getting this error when I try to connect my client to the server: Aug 15, 2012 12:05:00 PM org.jboss.ejb.client.EJBClient <clinit> INFO: JBoss EJB Client version 1.0.5.Final Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:GrahamsProjServer,modulename:GrahamsProjServer,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvoc ationContext@6a340101 at org

Stateful EJBs in web application?

风流意气都作罢 提交于 2019-12-17 10:34:33
问题 I never used stateful EJBs. I understand that a stateful EJB can be useful with a java client. But i wonder: in which case to use them on a web application? And how? Should we put these stateful beans in Session (because of stateless http)? Is it a good practice? (without debating too much about stateful vs stateless) 回答1: Funny enough, it's a 2nd question on SFSB and web app for the day, while this topic is usually not that common. in which case to use them on a web application? The

use of entityManager.createNativeQuery(query,foo.class)

时光毁灭记忆、已成空白 提交于 2019-12-17 09:31:10
问题 I would like to return a List of Integers from a javax.persistence.EntityManager.createNativeQuery call Why is the following incorrect? entityManager.createNativeQuery("Select P.AppID From P", Integer.class); specifically why do I get "...Unknown entity: java.lang.Integer" Would I have to create an entity class that has a single field that is an Integer ? Thanks 回答1: What you do is called a projection . That's when you return only a scalar value that belongs to one entity. You can do this