ejb

Can I inject properties into a JPA Entity Listener

I could prototype this and see what happens, but I am being lazy. I want to be able to inject an EJB3 into my JPA Entity Listener so that it can access functionality of the EJB during the PrePersist operation. Is that possible? If not... then under JBoss, will the Listener be created once, or once per method invocation? I guess I am tryi...

When should I use EJB transaction attributes 'Mandatory' and 'Never'

I am referring to container managed transaction attributes in Enterprise Java Beans. I can't think of any use cases where using 'Mandatory' and 'Never' makes sense. Can anyone please explain what cases warrant using these transaction attributes? ...

Testing EJB 3.0 components

I've got a couple of questions concerning the integrated testing EJB 3.0 components using JUnit. In your JUnit tests you can inject to session beans resource-local entity managers and therefore "simulate" ejb-container. But what if... What if you need to test if transaction attributes on your ejb methods are handled properly? Can thi...

Does Weblogic 10.3 support EJB2.0 Specification?

Does Weblogic 10.3 support EJB2.0 Sepcification? ...

What is the difference between EJBHome.remove(Handle) and EJBObject.remove() in Websphere Application Server 5.1 for a Stateless Session Bean

According to my understanding of the EJB spec both of the remove methods should invoke Bean.ejbRemove() and put the EJB instance back in the EJB pool. This should make the Remote instance (returned from EJBHome.create()) no longer usable. As far as I can tell ejbRemove is being called but the remote instance is still usable, which impli...

Usage of observer pattern with EJB and AJAX

Hi, I want to build an Ajax gui, that is notified on any state changes happening in my ejb application. To achieve this, I thought I build an stateful ejb (3.0) that implements the Observable interface to which the Ajax client is added as an observer. First, is this possible with Ajax. If yes, is this a good design idea or is there a m...

Ejb-QL DISTINCT ON

Is it possible to use PostgreSQL-like DISTINCT ON in EJB-QL query? What i need to do is to fetch from db records that are distinct on 3 of 10 columns. ...

How can I select the local interface for an EJB?

Say I have the following EJB (using ejb3): @Stateless(name="Queries") @Remote(Queries.class) @Local(Queries.class) public final class QueriesEJB implements Queries { ... } The class is available through both a local and a remote interface. How can I inject the local interface for this EJB in another part of the app? Specifically...

HIbernate and CMT

Lately I decided to implement in my project CMT transactions (jBoss5, Hibernate, jta postgres datasource). Everything is working fine except Hibernate.initialize() in my entities. It works in EJB beans but when trying to invoke initialize in entity getter I get "couldn't associate with session" exception. It worked just fine before imple...

EJBs and Storing Objects in a Data Structure (Map, List, etc)

Is it possible to have objects stored in a data structure for the duration of an App Server's uptime? Basically I want an EJB that interfaces with this Data Structure, but does not require a full fledged database solution. As an example I made this dummy animal object: package com.test.entities; public class Animal implements java.io...

EJB Timers and Reliability

I need a method to be called in an App Server (Glassfish) every 5 seconds, no matter what. Are timers reliable enough for this? What are my options. ...

Enterprise Java Beans video tutorials

Are there video tutorials for Enterprise Java Beans with the same caliber as asp.net and windowsclient.net Learn section? ...

How to inject variables with EJB3 via XML?

I have a single set of EJB code that I want to deploy multiple times with different resources. Currently, the code looks something like (oversimplified): @Stateless public class Bean implements BeanLocal { @Resource(mappedName="stateBean") private StateBean state; } Now, I want to be able to deploy the code once, and create d...

Why do I get a NameNotFoundExcpetion when using context.lookup("java:comp/env/MyBean")

Why do I get a NameNotFoundException when using context.lookup("java:comp/env/MyBean") but not when I use context.lookup(MyBean.class.getName()) ? The error reports "No object bound for java:comp/env/MyBean" How do I bind the name and why does class.getName() still work? Why would I use java:comp/env ? I'm using Netbeans 6.5, Glassfish...

What is the cause of EJB 2.x "reentrant method call detected" Exceptions? How to solve them?

Hi all, I'm mantaining a EJB 2 CMP legacy app runing on a JBoss 4.0.4 GA application server with deployed entity/stateless session beans. All the EJB boilerplate code is generated via XDoclet from the EntityEJB/EntityEJBManager annotations. I've noticed that when my GUI client invokes the facade create method, I have lots of cases of E...

Java EE video lectures

There are plenty of java videos and video lectures floating about, but does anyone know of any that deal specifically with Java EE? For my own point of view I'd be more interested in the EJB side of things, but any Java EE lectures would be useful, as well as videos on things like Spring etc. Thanks. ...

How to correctly do a manytomany join table in JPA?

I need 3 entities: User, Contract (which are a many to many relation) and a middle entity: UserContract (this is needed to store some fields). What I want to know is the correct way to define the relationships between these entities in JPA/EJB 3.0 so that the operations (persist, delete, etc) are OK. For example, I want to create a Use...

giving an EJB a JNDI

Hi, I have created and EJB with a remote interface: @Stateless public class TestSessionBean implements TestSessionRemote { public void businessMethod() { System.out.println ("***businessMethod"); } } I to access it from another component (e.g a servlet) running on the server via: ic = new InitialContext(); ...

Are Enterprise Java Beans still useful when compared to Spring?

I have an upcoming project in a class that will allow me to work with either EJBs or Spring, and I was wondering what would be more applicable for "real world" situations. ...

Can I from a client detect which EJBs the current user is authorized to use?

I have various EJBs on a J2EE-server, with different security roles. Now, from a Java Swing client application, when I log the user on to the server, I would like to discover which of these EJBs that are accessible to the user, without actually trying to create them or invoke them. The reason I want to do this is to adjust the user int...