ejb-3.0

“detached entity passed to persist error” with JPA/EJB code

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 02:34:36
问题 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.setPassword("passwd1"); em.persist(user); } I get this error: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.JPA.Database Any ideas? I search on the internet and the reason I found was: This was caused by how you created the objects, i.e

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

断了今生、忘了曾经 提交于 2019-12-16 20:13:58
问题 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's information securely. There seems to be conflicting ideas on whether it should be maintained in a JSF session bean or a stateful session EJB. I'm trying to use a stateful session EJB because it is more secure that way. The problem is that my application seems to be creating multiple instances of

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

跟風遠走 提交于 2019-12-16 20:13:27
问题 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's information securely. There seems to be conflicting ideas on whether it should be maintained in a JSF session bean or a stateful session EJB. I'm trying to use a stateful session EJB because it is more secure that way. The problem is that my application seems to be creating multiple instances of

EJB dependency injection of remote service fails on Glassfish

£可爱£侵袭症+ 提交于 2019-12-14 01:27:12
问题 I am unable to get dependency injection to work for my remote service and I cannot figure out why. I want an instance of RemoteService so I wrote. @EJB(name="RemoteService") private RemoteService service; And the Bean itself is defined with mappedName="RemoteService: @Stateless(mappedName = "RemoteService") public class RemoteServiceBean implements RemoteService When I try to run this code I get an InjectionException: EJB5070: Exception creating stateless session bean : [{0}] com.sun

Migration of Legacy Application : EJB3 or Spring

喜你入骨 提交于 2019-12-14 00:37:14
问题 I have legacy application using struts & ejb2.0 , hibernate v3.0 running on JBoss v4.0 and now we have do migration of that application to new technology stack. We are exploring pros and cons of different technology stack and right now we have two options to decide from: EJB3.0 & JSF , Hibernate v4 on Jboss 7 or Spring & Hibernate v4 on tomcat. What parameters should I be considering to select one or the other or vice-versa? Update: Which of EJB3.0 and Spring has efficient community support,

Connecting two MySQL data source using a single Connection object

时光总嘲笑我的痴心妄想 提交于 2019-12-13 21:18:58
问题 Actually I need to connect two mysql datasource which are created in my application server. I'm using JPA2.0 I tried the following code. but i'm getting exception " java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources. ". import com.google.common.collect.Lists; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.annotation.Resource; import javax.sql.DataSource; public

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

混江龙づ霸主 提交于 2019-12-13 19:43:14
问题 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. The basic application connects to a main method where I need to get the details of the book using appclient. Here I am getting an error "javax.ejb.EJBException: java.rmi.MarshalException:" Please look into the below snippets for more

Db migrate - Hibernate/JPA - hbm2ddl - diff tools

安稳与你 提交于 2019-12-13 16:21:41
问题 I use: EJB3 / JPA (Hibernate) MySQL 5 I have to set up a system to help database migrations. Tried to use LiquiBase but it seems not enough mature yet to be used with Hibernate. What I would like to do is: I have version 1.0 of the application in production I have version 2.0 of the application developed and tested I want to update the application database in production without losing data Actually I would like to use the new persistence.xml and the production database to be able to generate

EJB remove entity not working

二次信任 提交于 2019-12-13 16:15:22
问题 I'm using netbeans and generate entity class from database. All of my merge calls to insert and update entities are working perfectly, but when I try to remove an entity, it doesn't delete it from the database, and no exception is thrown. Can someone help me solved. My code below: AbstractFacade.java public abstract class AbstractFacade<T> { private Class<T> entityClass; public AbstractFacade(Class<T> entityClass) { this.entityClass = entityClass; } protected abstract EntityManager

unit testing code which uses JPA & JTA

牧云@^-^@ 提交于 2019-12-13 15:34:29
问题 I use 2 separate database, so i have to use JTA to handle distributed transactions.So either either both db have to commit or both rollback. I use open JPA and JTA.Now to unit test the code using junit ? I get the following error when i try to run my code which handles distributed transcations.I had posted similar question on this site and someone asked me to refer http://knol.google.com/k/how-to-unit-test-enterprise-java-beans-ejb# But i dint understand any thing from there. <openjpa-1.2.1