ejb-3.0

How to use JDBC ClientInfo with JPA and EJB3

We are migrating a JDBC based application to JPA and EJB3. Our old application used the Connect#setClientInfo API to record the current user name as part of the client info: http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html#setClientInfo%28java.lang.String,%20java.lang.String%29 We need to do something similar in th...

Have server return reference to EJB Remote interface?

Can a server-side enterprise bean return a reference to another bean's remote interface that the client can use to call methods on that remote bean? Example: I have a singleton auction house bean which has a vector of singleton auction item beans. I want to return to the client a vector of interfaces to the auction items so that the cl...

EJB3 unit testing expected exception

Hi guys! Are there any ways to test for expected exceptions on an EJB3 session bean method. When I invoke the method the container (glassfish) correctly outputs that an IllegalArgumentException has been thrown, but on the client I am not able to catch any exception arising from that method invocation. Could it be that exceptions at this...

EJB dependency injection of remote service fails on Glassfish

I am unable to get dependency injection to work for my remote service and I cannot figure out why. I want an instance of RemoteService so I wrote. @EJB(name="RemoteService") private RemoteService service; And the Bean itself is defined with mappedName="RemoteService: @Stateless(mappedName = "RemoteService") public class RemoteService...

EJB module initialization listener

It's posible to define a listener for EJB 3.0 .jar that is called in the module/context initialization? Similar to the ServerContextListener for web project? ...

EJB3 Stateful session bean for login and shopping cart and change template

Hello every body now I work with shopping cart, I wonder use between Stateful session beans or HTTP session for cart or login. Everybody have any ideas? In Stateful Session bean how to do compare state for item id, if it equals I will add to item one unit it means if item id = 1 it is coke and user add to cart one more coke it will bec...

How to define the constructor of an EJB3 session bean

Hi, I'm creating an EJB3 module which tries to respect a specific facade/implementation design pattern. My facade should be totally EJB free. I have 2 classes in this module: an entity bean and a session bean, which is the manager of this entity. The manager contains an EntityManager attribute. I also have a factory which instantiates...

How can I manage to use 2 persistense units and make my app to recognize which to use?

I hava a JavaEE/ EJB3 application in which I'll need to connect diferent databases. It's on JBOSS 5.10GA. After I tried to deploy it I got the following error: 09:04:57,921 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/opt/jboss-5.1.0.GA/server/idiomas/deploy/idiomas.ear/ state=PreReal mode=Manual requiredStat...

Optimistic Lock Exception with Foreign Keys

We are using JEE5 with GlassFishV2.1 and MySQL 5.1 and this is related to OptimisticLockException that we get. We have two database tables. First table is USER: having UserId and EmailId columns. Second table is SME_ACCOUNT with AdminId, SharedId, SpaceLeft and Version field which is managed by javax.persistence.Version (@version anno...

Multithreading in a stateless session bean?

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 me...

Strategies for performance optimizations on an inherited EJB3 application

I was asked to have a look at a legacy EJB3 application with significant performance problems. The original author is not available anymore so all I've got is the source code and some user comments regarding the unacceptable performance. My personal EJB3 skill are pretty basic, I can read and understand the annotated code but that's all ...

how to catch OptimisticLockException in web layer

I'm having one issue that is how to catch OptimisticLockException in web layer (.war code) when it is raised by the EJB layer. We are using JEE5, GlassFishV2.1 and JPA (with TopLinks)and Container Managed Transactions.But when the dirty read occur due to trnasaction by another concurrent user on the same entity.It gives Transaction.Roll...

Weblogic No unique bean of type [javax.persistence.EntityManager]

I am new to EJB3 and working on an exisitng code. We are using weblogic10.3 and the below code works fine @Stateless(mappedName="ProcessIssacIncomingMessage") @TransactionManagement(value=TransactionManagementType.CONTAINER) @TransactionAttribute(value=TransactionAttributeType.REQUIRED) @EjbRef(name="Database" jnod-name="Database") pu...

Error Getting JDBC Connection

Hi there, im having problem getting a JDBC connection from a EJB SessionBean.The error which is being throwing is: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous war...

Transfer objects only once via EJB / JPA(Hibernate)

Hello! I am using the Java Enterprise Edition with JPA(Hibernate) for a Server-Client application (via EJB). The program stores a lot of data in a database that needs to be transfered to the client. Because I want to transfer as less data as possible I do not want to transfer objects twice. I want to demonstrate my problem with a small...

Unit test error (JSF): Absent Code attribute in method that is not native or abstract

Hello! I get a strange error when Im trying to unit test a Java class dealing with JSF components (javax.faces.model.SelectItem). The error I get is this: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/model/SelectItem at java.lang.ClassLoader.defineClass1(Na...

LoginModule getting invoked twice in jboss (before accessing secured EJB3 method)

Its been quite a while I'm stuck with this.I've wriiten my own login module XtrLdapLoginModule which implements the javax.security.auth.spi.LoginModule to authenticate users against three credentials viz. username, password and account. I couldn't use the LdapExtLoginModule cause it wouldn't help me authenticate against a particular acco...

Resolution should not happen via injection container error.

I have an EJB3 project to be deployed on JBoss 5.1.0 GA. I have Stateless EJBs being injected into other Stateless beans and Servlets. I'm using the @EJB annotation without any parameters to inject the EJB beans, (i have a test project just to simulate the injection, which works). When i try deploying i get the error below. "Caused ...

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

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....) ...

Useful environment for CDI / weld web-applications

I am new to weld and consider what environment is useful for a web-application using CDI (Weld). I want to use JSF or Wicket for presentation and JPA/Hibernate for my persistence layer (including Transaction-Management). The obvious scenario is to use a JBoss or Glassfish application server with EJB3 surrounding, but is there not a chanc...