FAQ Database Discussion Community


Singleton injection order

java-ee,dependency-injection,singleton,ejb,ejb-3.0
I have the following: @Singleton public class A { @Inject private B b; @PostConstruct void initialize(){ b.someMethod(); } } @Singleton public class B { } Can we be sure that B will always be injected before A?...

JAX-WS @WebService on RESTful web-service endpoint

java,jax-rs,jax-ws,ejb-3.0
Some time ago in one of the projects I found @WebService annotations on some of the jersey root(@Path) resource classes. As far as I understood at the time it was some legacy code or simply a misused JAX-WS annotation. Recently I stumbled upon this post in which mixing JAX-RS service...

Exception in using appclient jar in EJB 3 :javax.ejb.EJBException: java.rmi.MarshalException:

java,java-ee,glassfish,ejb-3.0
I am trying to learn ejb 3 and facing an issue in the below mentioned scenario which I am not able to figure out. I am having one Entity (Book) to store book related data. I have created Stateless Bean and Remote interfaces and deployed the jar in glassfish 4....

Simulate @Startup on EJB 3.0 (WebLogic 11gR1)

java,java-ee,ejb-3.0,startup,weblogic11g
My goal is to set up a scheduled job that starts running at startup. on EJB 3.1, I could do something like: @Startup @Stateless public class SchedulePoller { @Resource TimerService timerService; @PostConstruct public void defineScheduler() { timerService.createTimer(60000, 60000, null); } @Timeout public void checkSchedule(Timer timer) { System.out.println("time: " + new...

Inject a parameter from client to ejb bean in the context

java,ejb-3.0
How to inject a parameter in the client of an Ejb? Something like that: final Hashtable<String, String> jndiProperties = new Hashtable<String, String>(); jndiProperties.put("java.naming.factory.initial", "org.ow2.carol.jndi.spi.MultiOrbInitialContextFactory"); jndiProperties.put("java.naming.factory.url.pkgs", "org.ow2.jonas.naming"); jndiProperties.put("java.naming.provider.url", "rmi://localhost:1099"); final Context context = new InitialContext(jndiProperties); Object obj = context.lookup("MyEjbTest");...

Invoking Message driven bean via SOAPUI?

java,java-ee,ejb-3.0
I started working on an existing project and want to test the changes I did on a Message driven bean. But I never used message driven beans, so how do I invoke this bean? Is it possible to invoke it via SOAPUI call? Bean code : @MessageDriven(name = "StudentsScores", activationConfig...

Is there a way to inject dependency in code using interface?

java,java-ee,ejb,ejb-3.0
I want to get the reference to some Stateless bean inside my code. The problem is I only know the Interface it is implementing (i do not know the name, classname or any other). Normally for any other EJB i would use @EJB annotation with an Interface private @EJB MyInt...

EJB on a remote client

java,java-ee,ejb,ejb-3.0,ejb-3.1
I have successfully compiled, deployed, and tested a simple, Remote, Stateless Session Beans on my local machine using this tutorial. The program just prints out "Hello World" in NetBeans output window when run. However I wish to run the client application on another home machine which doesn't has GlassFish or...

EJB @Local and @Stateless together

java,java-ee,ejb-3.0
I got my work rejected at uni because of using @Local and @Stateless on one EJB. It is a helper bean to validate/fix passed objects. I think it is completely legal to annotate my ejb's with both local and stateless. Can someone explain to me why can this be an...

JPA + EJB: Transactions with Native Queries

java,hibernate,jpa,jboss,ejb-3.0
I have a problem with managing transactions with native queries in JPA in Stateless bean. I use JBoss EAP 6.2 and Oracle 11g database and as JPA framework I use Hibernate. Datasource is configured under JBoss with Oracle JDBC driver. I have one method that should delete something in database...

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) doesn't work

java,jpa,glassfish,ejb-3.0
I need to delete a list of employees ignoring any integrity constraints (i.e. successfully delete the entity that doesn't related to any others yet or skip the entity that related to others) using JPA 2.0 and EJB3.0 on glassfish3.0: I iterated on the list and call entity manager in a...

EJB - EJBTransactionRolledbackException argument type mismatch - overloaded method

ejb,jboss7.x,ejb-3.0,illegalstateexception,wildfly-8
I really need some help! By invoking an EJB that has method overloading, I'm having the following exception: javax.ejb.EJBTransactionRolledbackException: argument type mismatch Interestingly, this happens randomly and only in this overloaded method. See the structure below: // superclass public abstract class GenericService<T> { public void update(T object) throws Exception {...

Find all EJBs implementing interface

java-ee,dependency-injection,ejb-3.0
I have a set of data that is provided by multiple providers. As they each have their own ways of accessing it, they each have separate EJBs although they all implement the same interface. Is there a way to have all of them injected? So that I end up with...

How to deploy EJB 3.0 application in Wildfly 8 application server

java,ejb-3.0,wildfly-8,ejb-3.2
I am migrating EJB 3.0 application from jboss AS 6 to wildfly AS 8. Is it possible to deploy EJB 3.0 application to wildfly as ease in wildfly? After updating the EJB spec as per wildfly EJB modules in pom.xml, I am getting compilation error that below symbols are not...

NULL EJB referece

java-ee,glassfish,ejb,ejb-3.0,glassfish-4
I have a EAP created with Eclipse containing two modules: a Dynamic Web Application, and a EJB module. The application.xml of the EAP: <?xml version="1.0" encoding="UTF-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7"> <display-name>JExecuterEAP</display-name> <module>...

@LocalBinding(jndiBinding=“sample/student”) of EJB 3.0 not present in EJB 3.2

java,ejb-3.0,jndi,wildfly-8,ejb-3.2
@LocalBinding(jndiBinding="sample/student") in EJB 3.0 is used to give preferred JNDI name to EJB bean. And to lookup using defined JNDI name, the code used is Context c = new InitialContext(); studentBean = (studentlBean) c.lookup("sample/student"); How this can be performed in EJB 3.2 as @LocalBinding is not supported in EJB3.2 wildfly...

How to make a generic EJB class

java,ejb,ejb-3.0
I have tow entities named : Address and Client. I have an interface whitch looks like : public interface IDAOEnitityFactory extends Serializable{ List<Address> findAllByClass(); } The implementation looks like : @Stateless @Local(IDAOEnitityFactory.class) public class DAOEnitityFactory implements IDAOEnitityFactory { @PersistenceContext(unitName = "MY_PU") protected EntityManager entityManager; @Override public List<Address> findAllByClass() { return...

Multi-threading in EJB's

java,multithreading,ejb-3.0
I am learning about EJB's, so far I have read that multi-threading is not allowed in EJB'S, because it is the container who should care about thread-safety and let the developer only focus in the business logic, so basically that means that EJB ensures that only one thread has access...