How to propagate the same instance using CDI

I have a web application with JAX-RS, CDI and EJB. In each resource I inject a Stateless SessionBean, and my question is whether it is possible to inject the same instances into a provider of JAX-RS and the Stateless SesionBean. I am trying to pass s

EJB: Custom authentication and authorization

I'm trying to add my own authentication and authorisation to Java EE REST application. I've managed to get working version with JAX-RS's SecurityContext, ContainerRequestFilter implementation (with JWT) and @RolesAllowed annotations on end-point meth

Can two session beans implement the same remote interface?

I'm a newbie to ejb .I want to know is can two session beans implement the same remote(local) interface, if not why? The code example is welcome. Thanks for any help!Yes, they can. Example: public interface NodeService { public void start(); } First

@PostConstruct called twice on single @Singleton @Startup bean

my problem is that the @PostConstruct is called twice even though it shouldn't. I searched a lot and found similiar problems with jersey https://java.net/jira/browse/JERSEY-1883?filter=-3. However I tried to make a small example which apparently stil

EJB Lookup works, but method call does not

I have an instance of a JBoss EAP 6.1 where i deployed 2 EJB applications. The server starts without errors! Now I have created a javaSE application to call these EJBs. And here is the problem... If I make lookup of EJB from applicationA/EJBBean!br.c

Deployment of Weblogic12c EJB ambiguous error

I'm trying to deploy the application in Weblogic 12c. During deployment, I'm getting the below error weblogic.management.DeploymentException: weblogic.application.naming.ReferenceResolutionException: [J2EE:160092]Error: The ejb-link "BeanClass"

configure localhost to send e-mails using the servlet

I have written a simple program to send email. The servlet program and JSP code is below. I get the following error message in jsp page. I am using glassfish server. I have added following jar file to my class path. lib/mail.jar lib/dsn.jar lib/imap.

JavaEE EJB Can not Intercept TransactionRolledbackException

I am building a small JavaEE project and have a Repository Class: @Stateless public class UserRepository extends AbstractRepository<User> { @PersistenceContext private EntityManager em; public User getByName(String username) { CriteriaBuilder criter

JBOSS can not find a data source

I'm developing a webapp with EJB3, Hibernate, JSF and JBOSS, but I'm not able to start JBOSS, as it keeps on throwing this error: 16:03:55,888 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA 16:03:56,130 INFO [org.jboss.msc] JBoss MSC version

Pot ejb invalid: it contains zero ejb.

I have 2 modules: ejb and war, and ear module, that contains them. Modules build successfully, but when I try to deploy ear to glassfish, I recieve this error: glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadI

Top performance issues in Jboss AS 7

I've taken part in a project where we have recently changed the application server to Jboss AS 7 (EAP 6). The system is a Jboss installation running in Domain Mode with one server (Server A) containing EJB's connecting to a relational database and th

EJB - Send data remotely

I want to exchange data between two applications JEE6/JSF2.0 and i'm looking for the best solution. I thought of the below solutions : by using a JSON file. by using XML file. by using GSON file. by using Remote interface (EJB 3.0). For you, what's t

use entitymanager to load collections anxiously

I have an entity (Contact) that has a collection that is lazy loaded. I do not which to change this but i need to load the collection when i do a em.find(Contact.class, myID) can this be done without changing the entity and without using jpql stateme

Injecting EntityManager into Servlet?

I want to inject an EM into a Servlet, the persistence unit is declared in the EJB JAR. I have an EAR with an EJB JAR and a WAR. The problem is that I get this error: Could not resolve a persistence unit corresponding to the persistence-context-ref-n

EJB 1.1 and the io disc

I have a question about EJB 1.1 (yes really that old ... - please dont kid me...) So the question is one of the old ones: Why should I not do disk io within EJBs? Especially reading files. To be more precise the use case: Its all about one file that

Load the spring context into an EJB-based application

The following is the situation : I have a business layer, that is an EJB project. In fact, there is only one EJB that is created. This EJB is responsible to expose the service classes to other layers, that calls the EJB. I want to introduce spring (t

Java EE: EJB Entity, Standalone Web

Can you please tell me how is best to do? How can I create a new instance of an entity on web application if I have only the interface.. I have : EJB(3.1) Project Web project I have an EJB Project like: User.java @Entity public class User { //variabl

Mocking injection of EJB in tests

Whenever I want to test a class which uses resource injection I end up including a constructor that will only be used within the test: public class A { @EJB B b; // Used in tests to inject EJB mock protected A(B b) { this.b = b; } public A() {} // Me

EJB creation and deployment using Intellij 10 and GlassfishV3

Does anyone have a good tutorial on how to create and deploy EJB's using Intellij 10 and Glassfish. I have been working on learning some J2EE basics and this has been a huge stumbling block as I have found tutorials for everything else. Thank you.Ple

EJB test 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 co

How to provide business logic in the spring in a remote server?

Using Spring as Framework, if i need provide business logic's service to either JSP/Servlets(on Web Servers) or to Application desktop client or Mobile clients, the only way to accomplish the logic business(without EJB) in a remote server is through

Delete a large number of lines from an EJB timer

I need to delete millions of rows from a table from within an EJB Timer. The problem is that the timer has a transaction timeout of 90 seconds, so I should divide the work into bite-size chunks. Since I don't know how many rows can be deleted in 90 s

LazyInitializationException

I have 2 Hibernate objects : Dero and Motif. a Dero has a set of Motif. I load a Dero object from the DB fine. but when I try to access its set of Motif : assertEquals(dero.getMotifRefus(),deroFromDB.getMotifRefus()); I get an exception : org.hiberna

EJB and synchronization

Are Session Beans (stateless session beans, stateful session beans) Synchronized?Only one thread at a time will be accessing your beans. It is up to the application server to manage this. So you should not be using synchronized from within your beans