ejb-3.0

Entity Manager / persistance file structure

偶尔善良 提交于 2019-12-11 08:28:24
问题 The title isn't clear as I couldn't think of one but, I have an EJB project and am trying to play with JPA. To create the entity manager I am injecting it in via annotations @PersistenceContext(unitName="testConnection") private EntityManager em; When I run a test query which I believe to be fine Query userQuery = em.createQuery("SELECT u FROM TestUser u WHERE u.username = 'test' u.password = 'test'"); tu = (TestUser) userQuery.getSingleResult(); I get an exception which points toward the EJB

Create a stateful session bean from a stateless bean

 ̄綄美尐妖づ 提交于 2019-12-11 07:29:41
问题 The context is the following : An client application uses a stateless session bean in order to login on an EJB server application. If the login is successful, the client should get a stateful session bean in order to perform some transactions on his personal data. However, I would want that the login method returns a new instance of this stateful session bean such that a client should not be able to manually call this session bean and perform transactions without being authenticated. Is it

stateless EJB3 bean invoked from request-scoped JAX-RS web service accumulates state

梦想与她 提交于 2019-12-11 04:59:49
问题 I have the following situation: Request-scoped JAX-RS service invokes stateless EJB3 bean and the EJB3 bean retains state between successive invocation of the web service from a client. Code as follows: web service @javax.enterprise.context.RequestScoped @Path("/actions") public class CounterFrontEnd { @EJB private ICounterService.ILocal counterService; @GET @Produces("application/text;") @Path("/counter") public String counter() { return String.format("%d ", counterService.incCounter()); }

What is the proper way to deal with Exceptions in Interceptors in EJB3?

瘦欲@ 提交于 2019-12-11 04:56:17
问题 I want to use an interceptor for my bean, which will check the validity of a given connection token. If the connection is invalid, I want to throw a particular exception, if the connection expired, I want to send another (TokenExpiredException, something like this). These Exceptions are included in the interface given to the client. @AroundInvoke public Object checkParams(InvocationContext ctx) throws TokenExpiredException, Exception{ //code to check token //... throw new

Can I place all of my EJB deployment descriptors in the META-INF directory of an EAR file, rather than the EJB jar files

和自甴很熟 提交于 2019-12-11 04:39:46
问题 I have an enterprise application which is delivered as an EAR file. The META-INF folder within the ear contains 'application.xml' as expected, with a list of modules belonging to the application. There are a number of EJB jar files within the ear also, each of which contain a number of EJBs. For certain reasons, we wish to use XML deployment descriptors to configure all of the ejbs. As a result we have a number of ejb-jar files, each one embedded in the META-INF folder of each jar within the

Empty EntityManager in Java EE bean on JBoss 5.1

Deadly 提交于 2019-12-11 04:12:13
问题 I'm a newbie in Java EE. This is the first project I'm trying to do and I have a problem that I just can't solve. I've created three projects: slowka-beans (EJB), slowka-persistance (JPA) and slowka-web(JSF). After deploying them I can't get access to persistence unit - the EntityManager is null. Everything works fine - I can create beans, inside them instantiate entity classes and show them on JSF page. But how can I store them in the DB? I have MySQL database configured on JBoss site. The

Transaction is not rolled back in ejb

寵の児 提交于 2019-12-11 04:03:17
问题 I am not an ejb expert. I have a service class like below. I am saving a file in some location in my service class and calling a method in dao to save the file hash code. Due to some reasons some time I get an exception in my dao layer. Recently I observed the file which is saved from my service layer is not deleted when I get excxeptions. @Stateless @Local @TransactionManagement public class ImportUpgradeServiceImpl implements ImportUpgradeService { @Inject private UpgradePackageDao

SessionContext Injection using @Resource annotation

孤者浪人 提交于 2019-12-11 03:54:14
问题 I need to rollback in EJB 3 Stateless SessionBean (CMT, JBoss version 5), for which I am using sessionContext.setRollbackOnly(); This sessionContext is injected using @Resource annotation. My questions: 1) Is it preferred way to rollback in EJB3? 2) Why Jboss complains on deployment if I use public setter injection // throws exception on deployment. private SessionContext sessionContext; @Resource public void setSessionContext(SessionContext sessionContext) { this.sessionContext =

GWT Deserialisation of Persistent Entities (JPA)

一笑奈何 提交于 2019-12-11 03:38:54
问题 I am currently developing Java/GWT-application which is hosted on a weblogic application server. I am using EJB3.0 with EclipseLink as persistence layer. Sadly my GWT has problems to deserialize persistent entities. It might be helpful for you to know, that I have the EclipseLink-Library in my classpath (including javax.persistence.Entity ) am not recieving the persistence objects from a database or persistence-manager - I am creating the objects with standard java code use Eclipse IDE for

Hibernate in Glassfish - Ejb3Configuration NoClassDefFoundError

本秂侑毒 提交于 2019-12-11 03:34:41
问题 I've put the Hibernate libraries in both the Glassfish domain and in the library collection of my project in Netbeans. hibernate-entitymanager.jar contains both HibernatePersistence (the last class in the call stack) and Ejb3Configuration, so I'm rather stumped as to why I get the missing class error for Ejb3Configuration. java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.ejb.Ejb3Configuration at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory