Questions tagged [ejb-3.0]

This tag is used for question related to the session bean and message-driven bean component types of the EJB 3.0 programming model. For questions about the persistent entities defined in the document "Java Persistence API" of the EJB 3.0 specification, use the [JPA] tag.

ejb-3.0
Filter by
Sorted by
Tagged with
32 votes
2 answers
15k views

JSF request scoped bean keeps recreating new Stateful session beans on every request?

I'm building my first Java EE application using JSF, PrimeFaces, Glassfish and Netbeans. Because I'm new, it's possible I'm approaching the core problem wrong. Core problem: I want to maintain user'...
Alan B. Dee's user avatar
  • 5,536
570 votes
14 answers
247k views

What is the difference between DAO and Repository patterns?

What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven ...
Thurein's user avatar
  • 6,725
83 votes
10 answers
163k views

"detached entity passed to persist error" with JPA/EJB code

I am trying to run this basic JPA/EJB code: public static void main(String[] args){ UserBean user = new UserBean(); user.setId(1); user.setUserName("name1"); user....
zengr's user avatar
  • 38.6k
75 votes
15 answers
128k views

java.lang.IllegalStateException: Multiple representations of the same entity with @ManyToMany 3 entities

I have 3 entities with ManyToMany relationships: Role Entity: @Entity public class Role { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer roleID; private ...
user1188867's user avatar
  • 3,828
56 votes
7 answers
77k views

How can I avoid the Warning "firstResult/maxResults specified with collection fetch; applying in memory!" when using Hibernate?

I'm getting a warning in the Server log "firstResult/maxResults specified with collection fetch; applying in memory!". However everything working fine. But I don't want this warning. My code is ...
Gnik's user avatar
  • 7,292
40 votes
4 answers
113k views

Batch inserts using JPA EntityManager

Is there a way where we can use batch inserts using JPA EntityManager. I know there is no direct way to achieve this but there must be some way to achieve this mechanism. Actually, for every insert ...
Prathap's user avatar
  • 1,043
22 votes
2 answers
19k views

Eager / auto loading of EJB / load EJB on startup (on JBoss)

EJBs seem to be loaded lazily - whenever accessed. However, I want to initialize them eagerly - i.e. whenever the container starts-up. How is this achieved (in JBoss in particular) This topic gives ...
Bozho's user avatar
  • 593k
57 votes
1 answer
61k views

Difference between a "jta-datasource" and a " resource-local " datasource?

The terms "jta-datasource" and "resource-local datasource" are a little vague to me. I'm putting down what I am understanding ( or assuming ) and I'd like you to say where I'm right / wrong. The same ...
stratwine's user avatar
  • 3,681
46 votes
4 answers
238k views

use of entityManager.createNativeQuery(query,foo.class)

I would like to return a List of Integers from a javax.persistence.EntityManager.createNativeQuery call Why is the following incorrect? entityManager.createNativeQuery("Select P.AppID From P", ...
Jim Ward's user avatar
  • 539
29 votes
2 answers
20k views

EJB 3.0 - Nested Transaction != Requires New?

I just read the Transactions Chapter (10) of "Mastering EJB 3.0" and now I'm confused about nested transactions. The book says "The EJB-defined transaction manager does not support nested ...
NorRen's user avatar
  • 711
15 votes
1 answer
7k views

Stateful EJBs in web application?

I never used stateful EJBs. I understand that a stateful EJB can be useful with a java client. But i wonder: in which case to use them on a web application? And how? Should we put these stateful ...
Sebastien Lorber's user avatar
10 votes
4 answers
23k views

How to inject persistence context to different data source programmatically

In standard EJB 3, when injecting entity manager, persistence unit (which refers to datasource) is hardcoded into annotation: (or alternatively xml file) @PersistenceContext(unitName = "myunit") ...
Primk's user avatar
  • 501
1 vote
2 answers
3k views

Passing a JSF2 managed pojo bean into EJB or putting what is required into a transfer object

Currently i am calling EJB 3 Session Beans from JSF 2. However, i am not sure if i should be passing JSF managed beans into EJB? Assuming that whatever on the form (and thus the backing bean) was ...
HJW's user avatar
  • 23.2k
15 votes
1 answer
59k views

No EJB receiver available for handling

I'm using EJB 3.0 with JBoss AS 7.1.1 Final. I am getting this error when I try to connect my client to the server: Aug 15, 2012 12:05:00 PM org.jboss.ejb.client.EJBClient <clinit> INFO: JBoss ...
Graham's user avatar
  • 5,704
13 votes
4 answers
13k views

Inject a EJB into a JSF converter with JEE6 [duplicate]

I have a stateless EJB that acceses my database. I need this bean in a JSF 2 converter to retreive an entity object from the String value parameter. I'm using JEE6 with Glassfish V3. @EJB annotation ...
Michael Bavin's user avatar
12 votes
3 answers
13k views

Injecting a static EJB, nonsense?

I want to write this piece of code : @Stateless public class MyEjb { @EJB private static MyOtherEjbWhichIWantStatic myOtherEjb; } It makes sense to me, that I want to inject an EJB in my ...
Cyril Gandon's user avatar
  • 16.9k
4 votes
4 answers
5k views

access existing instance stateful inside stateless, java ee 6

Is it possible to access a stateful session bean inside a stateless bean? My problem is that I have a session bean called User and I want to access user info inside a stateless bean... I am trying ...
Alex's user avatar
  • 2,136
95 votes
4 answers
98k views

Spring vs EJB. Can Spring replace EJB? [closed]

Since Spring is able to use transactions just like EJB. For me, Spring is able to replace the requirement of using EJB. Can anyone tell me what are the extra advantages of using EJB?
cometta's user avatar
  • 35.4k
73 votes
9 answers
36k views

Should I use EJB3 or Spring for my business layer?

My team is developing a new service oriented product with a web front-end. In discussions about what technologies we will use we have settled on running a JBoss application server, and Flex frontend (...
Justin Standard's user avatar
44 votes
21 answers
104k views

Successful build in Maven still showing errors in Eclipse

I'm having something quite peculiar here, my build is successful in maven when I type "mvn clean install" however once imported into Eclipse it's showing errors. See for yourself: I guess ...
Heetola's user avatar
  • 6,021
26 votes
4 answers
16k views

How to access the file system from an EJB 3?

I would like to know how can I access the file system from an EJB 3 bean? I searched the Internet on the subject and haven't found a good answer. Some suggest using the java.io/java.nio even though ...
Pierre Thibault's user avatar
25 votes
4 answers
52k views

A JTA EntityManager cannot use getTransaction()

How can I use the following code in my non-ejb application. The code works. @Override public void saveItems(Collection<T> items) { synchronized (em) { EntityTransaction tx = em....
auser's user avatar
  • 6,897
21 votes
2 answers
23k views

Elegantly handling constraint violations in EJB/JPA environment?

I'm working with EJB and JPA on a Glassfish v3 app server. I have an Entity class where I'm forcing one of the fields to be unique with a @Column annotation. @Entity public class MyEntity implements ...
hallidave's user avatar
  • 9,909
17 votes
6 answers
72k views

In @Table(name = "tableName") - make "tableName" a variable in JPA

I am using JPA and I need to make the "tableName" a variable. In a database, I have many tables, and my code needs to access the table where I specify it to read. @Entity @Table(name = "tableName") ...
zengr's user avatar
  • 38.6k
15 votes
2 answers
30k views

Embedding images into html email with java mail

I am sending html and images with javamail but for some reason I don't see the images as part of the html, I see them only as an attachment. I don't know why is that. This is how it looks like when ...
javing's user avatar
  • 12.4k
12 votes
3 answers
16k views

EJB 3 or Hibernate 3

Regarding a Java EE Web application which is going to be served by a full Java EE Application server e.g. GlassFish, which is the best ORM Solution? EJB 3 or Hibernate 3 And why?
ehsun7b's user avatar
  • 4,836
10 votes
2 answers
6k views

Using stateful session beans with servlets

I am trying my first EJBs with Glassfish Server ( A simple shopping cart). I intended to use the CartBean for each Http Session. If my Cart Bean is following- public interface CartLocal { public ...
user2531191's user avatar
6 votes
2 answers
17k views

EJB 3 injection into spring beans

I've made a mavenized web application with spring, spring security... Now, I want to add ejb module for database access, I was looking on the internet but I didn't find something clear because it's ...
elpazio's user avatar
  • 697
5 votes
1 answer
2k views

How can i deploy Session Bean on another computer with Client JSP/Servlet

Hello Everybody i'm new in EJB3, i know how to deploy Session Bean (Stateless or stateful) on Glassfish server in one computer. My question is: how can i deploy session bean on Computer A and Deploy ...
Kency's user avatar
  • 660
4 votes
2 answers
9k views

New to EJB world... Null pointer exception in EJB client

I am learning EJB and I am trying to execute the Helloworld example given in EJB In Action book. My app server is JBoss, I created the Jar file for the bean class and interface in the right directory(...
Maximus's user avatar
  • 241
3 votes
2 answers
7k views

Declaring @Resource and @EJB at the class level in Java EE6

Is there any situation still ( given that Java EE6 has java:global/, app/, module/ naming standards) that necessitates declaring EJBs or Resources like the example below? @EJB (name = "ejb/PlaceBid",...
Onur's user avatar
  • 988
1 vote
3 answers
3k views

Howto secure webservices on GlassFish 2?

We have some staleless EJBs (EJB3) deployed on a GlassFish 2 server that expose some of their methods as webservices via the @Webmethod annotation. Now we want to secure these webservice methods so ...
Sylar's user avatar
  • 2,313
37 votes
2 answers
90k views

JPA and Table Views. Can it be done? [duplicate]

We currently have a Java EE system where we are mapping to our database using JPA. It is a fairly well developed system with about 20 entities. We now have been ordered to use Views for everything. ...
Oliver Watkins's user avatar
26 votes
8 answers
19k views

EJB3 Transaction Propagation

I have a stateless bean something like: @Stateless public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote { @PersistenceContext(unitName="myPC") private EntityManager mgr;...
Matt S.'s user avatar
  • 1,149
20 votes
6 answers
70k views

JPA entity has no primary key?

I have an Entity class: @Entity @Table(name="CMC_MAP_SERVER_INFO") @NamedQuery(name="CmcMapServerInfo.getMapServer", query="SELECT c FROM CmcMapServerInfo c") public class CmcMapServerInfo implements ...
Siddharth Trikha's user avatar
15 votes
2 answers
23k views

Mocking Reflection based calls

I am trying to mock some reflection based methods. Below you can see the details, Class Under Test public class TracerLog { @AroundInvoke public Object logCall(InvocationContext context) ...
Bala's user avatar
  • 1,203
13 votes
5 answers
24k views

JavaEE 6: javax.naming.NameAlreadyBoundException: Use rebind to override

I have a business interface being implemented by two EJBs. UserManagementService @Remote public interface UserManagementService { // ... } UserManagementServiceJpaImpl @Stateless(name="...
skip's user avatar
  • 12.4k
11 votes
5 answers
11k views

Where can I find good unit testing resources for EJB and J2EE? [closed]

Which online resources, tutorials or books can you recommended to get started with unit testing J2EE / EJB3 applications? So far I have found ejb3unit, Jakarta Cactus (retired 2011/08) and the Maven ...
mjn's user avatar
  • 36.4k
10 votes
4 answers
14k views

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 ...
Gerald Thaler's user avatar
10 votes
3 answers
15k views

Read Environment Variables in persistence.xml file

I want to read environment variables inside persistence.xml file. Idea is that i don't want my database details to be read from properties file as there is a change of getting properties file ...
Prathap's user avatar
  • 1,043
9 votes
1 answer
10k views

Can @Resource be used to inject primitives in EJB3.0?

Using Glassfish, I can setup a string jndi entry: JNDI name: "com/xyzcompany/echo/EchoServiceBean/viewName" Factory Class: org.glassfish.resources.custom.factory.PrimitivesAndStringFactory Properties:...
Jonathan S. Fisher's user avatar
8 votes
3 answers
5k views

CommonJ TimerManager versus EJB3 TimerService

I have to implement a simple (not clustered) timer for WebLogic and it seems there are two different 'standard' options Timer and Work Manager API (CommonJ) EJB3.0 TimerService Does anyone have any ...
fglez's user avatar
  • 8,462
8 votes
2 answers
16k views

EJBException when calling entityManager.getTransaction()

This is probably something trivial, but I'd love some help. I get: javax.ejb.EJBException: java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager 11:54:...
Simeon's user avatar
  • 7,692
7 votes
1 answer
2k views

Glassfish 2.1 EJB 3.0 Exposing local EJB to other applications running in the same domain/jvm

I have an existing project that I am in need of configuring different. This needs to happen without major code changes. I am actually hoping I could somehow do this only with configuration. I have ...
guyumu's user avatar
  • 3,517
7 votes
4 answers
16k views

logback with EJB3.1

I am using logback/slf4j to handle logging in my application. Everything was working perfectly until I started using EJBs. Once I added a stateless EJB to my app, the logger started ignoring my ...
kgrad's user avatar
  • 4,702
6 votes
5 answers
18k views

Understanding EJB3/JPA container-level transactions and isolation level

Consider this simplified view of some code with which I'm working: @Stateless(...) @Remote(...) @TransactionAttribute(TransactionAttributeType.MANDATORY) public class FirstEjbType { @EJB(...) ...
Steve Perkins's user avatar
6 votes
1 answer
3k views

How is the return-value of SessionContext.getBusinessObject() different from 'this' keyword used in the bean?

The SessionContext.getBusinessObject() is described in the docs as follows, Obtain an object that can be used to invoke the current bean through the given business interface. Parameters: ...
stratwine's user avatar
  • 3,681
5 votes
5 answers
15k views

Many-to-Many link tables in grails (GORM) / hibernate

I'm playing aroud with Grails and am finding the ORM stuff tedious because I don't fully understand what I'm doing when it comes to domain classes. I'm hoping someone can put me back on track ...
K2J's user avatar
  • 2,613
3 votes
3 answers
7k views

Cant retrieve an images from the WEB-INF folder ussing classLoader.getResourceAsStream()

The hold noon i was trying to make my app send both html+images via javamail, i only managed to send html, but with the image i am having a bit of problems. I decided to create a multipart message, ...
javing's user avatar
  • 12.4k
2 votes
3 answers
7k views

java.lang.ClassCastException with the same class object

This piece of code irritates me, sometimes it working and some other times it doesn't ! The NamedQuery : (name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") ...
bilelovitch's user avatar
  • 2,075

1
2 3 4 5 6