ejb-3.0

How to eagerly fetch a single "default" entity from a collection in EJB3/JPA

I have a Person entity with multiple phone numbers. @OneToMany(mappedBy="person", cascade=CascadeType.ALL) public Set<PhoneNumberOfPerson> getPhoneNumbers() { return phoneNumbers; } Now I would like to implement a "get default phone number" method for Person that is eagerly fetched. This default phone number is one of the phone ...

EJB is not found in lifecycle module when it is redeployed on GlassFish

Hi, I have an EJB deployed on my GlassFish v2.1 application server. I have also set up a lifecycle module within GlassFish which utilises this bean when it receives a READY_EVENT type. I have the following code to look up the bean: BusinessInterface bean = (BusinessInterface) initialContext.lookup("JNDI lookup name"); ... // do somet...

How To Configure Query Cacheing in EclipseLink

I have a collection of states, that I want to cache for the life of the application, preferably after it is called for the first time. I'm using EclipseLink as my persistence provider. In my EJB3 entity I have the following code: @Cache @NamedQueries({ @NamedQuery( name = "State.findAll", query = "SELECT s FROM State...

Storing username that last modified database row via EJB3.0 and JPA

I'd like to store username that has last modified table row to as a field in every table. I have following setup: an user logs in, web layer calls some EJB 3.0 beans. Those EJB beans create and modify some JPA entities. Now, I'd like that username (from weblayer) would be automatically stored to every JPA entity (and database row) that...

How can I set isolation levels per method in EJB 3

Is it possible to set the database isolation level (ie Serializable, repeatable-read etc) for a given EJB 3 method call? I understand that this is not covered by the EJB Spec, so details of how to do it on either a JBoss or Glassfish specific manner would be great. I'm starting to get the impression it's not possible and that you can o...

Is it possible to use hibernate as Glassfish's persistence provider?

Is it possible to use hibernate as Glassfish's persistence provider and if so HOW? ...

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

JBoss 5 AS and EJB3 bean injection from servlets?

It was my understanding that JBossAS 5.x supported EJB3 bean injection in servlets with the @EJB3 annotation. I'm using the default configuration for JBossAS 5.0.1.GA and it's not working. I've added the mappedName argument to the @EJB annotation with the session beans JNDI name, and it just doesn't do anything. No apparent errors, the b...

Ejb 3, message driven bean cooperating with a stateful session bean?

Hey! I'm relative new to both Java EE and Stackowerflow, please be kind :-) I have a bunch of devices triggering Java messages to be sent on any state change. These devices are typically active for about 30-90 minute intervals. Each event message contains a device id in addition to the event details. Central in my application is a me...

Can an EJB3 bean "self inject" and call its own methods via EJB container?

Is it possible to "self inject" an EJB in order to call local methods as bean methods? There are some cases where this could be favorable, for example if container managed transactions are used and something should be accomplished in a new transaction. An example how this could work: Foo.java: @Local public interface FoO { public ...

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

Class Loading problem in Java Enterprise application

I have Enterprise Application with EJB3 and JSF on Glassfish server. After running this application for more than 2 weeks I realized that I have problem with Class Loading. I don't think this is a problem with permgen. The classes loaded every time when I open a page but then they never erased from the memory. Here is the snapshot of or ...

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

Singleton in Java App Server.. How bad of an idea is this?

I am currently working on some older java code that was developed without App Servers in mind. It is basically a bunch of "black box code" with an input interface, and an output interface. Everything in the "black box" classes are static Data Structures that contain state, which are put through algorithms at timed intervals (every 10 s...

Calling a Remote Bean vs Local Bean in App Server

Is there a noticeable amount of performance overhead in using Remote Bean Interface over using a Local Bean Interface? I would like to have every Client application connect to remote beans if there is little performance difference. ...

REQUIRES_NEW annotated method is executed without a transaction?

I have a stateless bean resposible for persisting entities to a database. This stateless bean is called by a message bean's onMessage method. The wired thing is that on the first message everything works fine, but on the next message the method responsible for persisting is invoked outside a transaction, even though the method is annotat...

Audit log with JBoss Seam (EJB3+JSF)

I would need to implement an audit log for a web application written with JBoss Seam. EntityListeners seem like good candidates, but I don't know how to connect the EntityListeners to the application session context to include the logged in used principal in the audit record. I wonder if there is a way to do this "connection", or if the...

Can Java Code tell if it is in an App Server?

Is there something I can call from a POJO to see if the code is currently in an App Server or outside of an App Server? Something like this (In rough PseudoCode): System.getRunningEnvironment().equals(Environment.Glassfish) or System.getRunningEnvironment().equals(Environment.ApplicationServer) or System.getRunningEnvironment().e...