ejb

How to perform a DB cleanup operation upon shutdown in an EJB container.

Hi, I have an EJB app. which basically has to execute a SQL query when it is shutdown. A shutdown hook would presumably work, but that way I can't use injected entitymanager/datasource etc. Is there a way to provide a shutdown hook that can invoke methods on EJB bean? Our EJB container is JBoss5.1. Thanks! ...

First connect to Glassfish v3 is slow

When trying to connect to glassfish v3 from swing application it is very slow for the first time. Takes 4-10 seconds. On the client side: public void myMethod(){ NewSessionBeanRemote facade; try { InitialContext ic = new InitialContext(); facade = (NewSessionBeanRemote) ic.lookup(NewSessionBeanRemote.class.getNa...

Redeploy tree on Glassfish 3.0.1

I use Netbeans 6.9.1 and Glassfish 3.0.1. I have this model: EnterpriseApplicationA contains EJBmoduleA and the BeanA that exposes a remote interface. EnterpriseApplicationB contains EJBmoduleB and the BeanB. The BeanB calls the BeanA using @EJB injection. All is working, but if I made a trivial change in a business method of BeanA (...

JSF Error Target Unreachable, 'null' returned null

Hello Everybody now i working with JSF 2.0 and EJB3 and i used Primefaces to display error message or success message, i have two problem are one when i put Button sumit (JSF command button) next page Error display /register.xhtml @26,172 value="#{userController.user.username}": Target Unreachable, 'null' returned null my code are ...

EJB testing strategies?

I'm working on a Java EE 6 application. When I started out, I was writing tests for my EJB classes by manually instantiating the EJB, then manually adding the members that normally get provided by dependency injection. As the application gets more complicated, I find that this approach just doesn't cut it. So I'd like to be able to start...

How do i catch exceptions from container managed transaction commit?

Hi! I have a @Stateless EJB with a @WebService interface, using container managed transactions, meaning transactions are automatically committed by the container after a method has been called if it doesn't throw a system exception. If i try to EntityManager.persist(...) two objects with the same value for a column with a unique const...

Suggestions for implementing method invocations based on the parameter passed to servlet

Hi, I would like to get some suggestions on implementing a solution that invokes ejb methods based on the parameters I pass to a servlet. I have a web project and an ejb 3.0 project. The ejbs are invoked from the servlet in the web project. The ejbs are invoked based on the parameters I pass to the servlet. For every action I need to ...

Java EE -- using the same stateful object for several users

Hello SO! Even though I've been in Java SE for quite some time now, I started EE & web w/ Java only about a month ago, so pardon if the question seems a bit noobish... So here's the situation: I'm trying to write a JS based multi-player game with real-time interaction (let's say chess in this example, though it really doesn't matter wh...

Are EJBs applications like Web Services ?

Is developping an EJB application is considered like a web services ? Or the two are different ? Or you can make EJBs like web services ? ...

problem deplotying ejb on glassfish 3

Hi. I have problem with my ejb and glassfish. When i want to deploy ejb project on glassfish, it can't. I use netbeans 6.9 (glassfish server 3 and java EE 6). mesasage in ejbmodule output: dist-directory-deploy: pre-run-deploy: In-place deployment at C:\Users\Darjan\Documents\NetBeansProjects\EJBModule4\build\classes Initializing... de...

how the Transaction concept is implemented in EJB

I wan to know how the transaction is internally implemented in EJB. I want to know the logic they use to create a transaction. if you could point out some articles that would be helpful ...

ClassNotFoundException deploying webservice on Weblogic 10.3 with Hibernate

I have a project with a EJB implementing a JWS Webservice, like this: @Stateless @Remote(WebServiceTest.class) @WebService( serviceName="TestService", name="TestName" ) public class WebServiceTestImpl implements WebServiceTest { @Override @WebMethod(operationName="hello") public String hello() { return "Hello World!"; } } I de...

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

EJB's - when to use Remote and/or local interfaces?

I'm very new to Java EE and I'm trying to understand the concept of Local interfaces and Remote interfaces. I've been told that one of the big advantages of Java EE is that it is easy to scale (which I believe means you can deploy different components on different servers). Is that where Remote and Local interfaces come in? Are you suppo...

Java Newbie: JPA and EJB workflow question

I'm just learning about JPA and session beans. I've worked through a simple database model (schema designed using MySQL Workbench) and used an IDE (NetBeans) wizard to generate the JPA entity classes and session beans. My question has to do with an appropriate workflow when the data model changes. For example, if I add a column to a tab...

how to raise OptimisticLockException

Unable to catch optimistic lock exception. one way to raise OptimisticLockException is by using em.flush() try{ //some enitity em.flush() } catch(OptimisticLockException ole){} but i dont think this is best solution beacuse in this full database is flush. another work around is by catching EJBException and find RollBackExce...

@Asynchronous private method in EJB

I have an asynchronous method in my EJB singleton that's called from another method in the same class. I already know that I can't call the asynchronous method directly, I have to obtain an EJB proxy. The problem is, I don't want the asynchronous method to be visible outside the class; but when I make it private, it's not executed asynch...

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

OptimisticLockException with 2 foreign keys

Hello, This is in continuation with the question I logged as a "Unregistered User". I did not find a way to add comments (as suggested by Plínio Pantaleão) to that question, so created a "Registered Account" and this question. Apologies if there really was a wy to do this. Please refer to http://stackoverflow.com/questions/3812968/opti...