[Persistence, JBoss/CMP, Hibernate, Database] - Problem with Session EJB - Hibernate
by OnurAktas
Hi, i am very new on Hibernate, and also EJB's. The problem is that i just want to save @ManyToOne related records based on different tables.
Please tell me if i am following a WRONG architecture? And also when i execute mainline,
i get an error of
java.lang.RuntimeException: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
| .
| .
| .
| .
| at com.las.client.MainLine.main(MainLine.java:52)
| Caused by: java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.las.pojo.BookEntity.categoryEN -> com.las.pojo.CategoryEntity
| at
|
I use MSSQL, PK Fields are identity.. Here are my codes..
CATEGORY has many BOOKs
Book Entity / Pojo
@Entity
| @Table(name="BOOK")
| public class BookEntity implements Serializable {
| @Id @GeneratedValue
| @Column(name="ID")
| private Long id;
|
| @Column(name="NAME")
| private String name;
|
| @ManyToOne
| @JoinColumn(name="CATEGORYID")
| private CategoryEntity categoryEN;
|
| public BookEntity() {
| }
|
| public void setId(Long id) {
| this.id = id;
| }
|
| public Long getId() {
| return id;
| }
|
| public void setName(String name) {
| this.name = name;
| }
|
| public String getName() {
| return name;
| }
|
| public void setCategoryEN(CategoryEntity categoryEN) {
| this.categoryEN = categoryEN;
| }
|
| public CategoryEntity getCategoryEN() {
| return categoryEN;
| }
| }
|
Category Entity / Pojo
| @Entity
| @Table(name="CATEGORY")
| public class CategoryEntity implements Serializable {
| @Id @GeneratedValue
| @Column(name="ID")
| private Long id;
|
| @Column(name="NAME")
| private String name;
|
| @OneToMany(mappedBy="categoryEN")
| private Set<BookEntity> bookList;
|
| public CategoryEntity() {
|
| }
|
| public CategoryEntity(String name) {
| this.name = name;
| }
| public void setId(Long id) {
| this.id = id;
| }
|
| public Long getId() {
| return id;
| }
|
| public void setName(String name) {
| this.name = name;
| }
|
| public String getName() {
| return name;
| }
|
| public void setBookList(Set<BookEntity> bookList) {
| this.bookList = bookList;
| }
|
| public Set<BookEntity> getBookList() {
| return bookList;
| }
| }
BookEJB
@Stateless(name="BookEJB")
| public class BookEJBBean implements BookEJB, BookEJBLocal {
|
| @PersistenceContext(unitName="lasDatabase")
| private EntityManager em;
|
| public BookEJBBean() {
|
| }
|
| public void Save(BookEntity BookEN) {
| em.persist(BookEN);
| }
| public void Delete(BookEntity BookEN) {
| }
| public List<BookEntity> getAll() {
| return em.createQuery("from BOOK")
| .getResultList();
| }
| public BookEntity getSimple(Long id) {
| return em.find(BookEntity.class, id);
| }
| }
CategoryEJB
@Stateless(name="CategoryEJB")
| public class CategoryEJBBean implements CategoryEJB, Serializable {
|
| @PersistenceContext(unitName="lasDatabase")
| private EntityManager em;
|
| public CategoryEJBBean() {
|
| }
|
| public void Save(CategoryEntity categoryEN) {
| em.persist(categoryEN);
| }
| public void Delete(CategoryEntity categoryEN) {
| }
| public List<CategoryEntity> getAll() {
| return em.createQuery("from CATEGORY")
| .getResultList();
| }
| public CategoryEntity getSimple(Long id) {
| return em.find(CategoryEntity.class, id);
| }
| }
CLIENT CODE
public class MainLine {
| public MainLine() {
| }
|
| public static void main(String[] args) {
| MainLine mainLine = new MainLine();
|
| try {
| Context context = new InitialContext();
|
| CategoryEJB categoryRemote = (CategoryEJB)context.lookup("lasejb/CategoryEJB/remote");
| BookEJB bookRemote = (BookEJB)context.lookup("lasejb/BookEJB/remote");
|
| CategoryEntity categoryEN = new CategoryEntity("Horror");
| categoryRemote.Save(categoryEN);
|
| BookEntity bookEN = new BookEntity();
| bookEN.setIsbn("123-321-333");
| bookEN.setName("ABC");
| bookEN.setCategoryEN(categoryEN);
|
| categoryRemote.Save(categoryEN);
| bookRemote.Save(bookEN);
| }
| catch(Exception ex) {
| ex.printStackTrace();
| }
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134661#4134661
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134661
18 years, 1 month
[Beginners Corner] - Re: application clients in JBOSS 4.2.2
by sajhak
thanks Peter ,
u r the one who has replied for almost all my questions so far .. :)
finally i got the problem solved ..
when JBOSS integrates with Netbeans 6.0 , it automatically detects the settings to be conformed with J2EE 1.4 specs.not J2EE 5...so il try with JBOSS 5.0 later..
so i had to edit the configuration files as well , and had to use JNDI as well.
but the same application is working in Glassfish server , without the need of any modification of config files , and without using JNDI lookups..
here , iam deploying the application client's jar also to the deploy directory , and after that clicks on RUN in Netbeans , so no classpath is involving here.Im that couldnt i use the @Local interface instead of the @Remote one ?
another question , what s the use of @EJB annotations ? are those only for local clients ? won't that be supports for Local clients ?
also , what is the use of the local interface (@Local) .. i couldnt find any example code which uses that interface..i tried even to use it..but it failed.so i gave that up..so please , if u have any simple example code which uses the @Local interface please send me ( through this or my mail sajhak(a)hotmail.com ) so that i can get a thorough idea of EJB ..
Thanks and Regards
Sajith
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134657#4134657
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134657
18 years, 1 month
[EJB 3.0] - @PersistenceUnit on private javax.persistence.EntityManager.
by JGF1
I've been following along with an example using EJB3/JBOSS from the book
Beginning Java EE 5 Platform and don't know why JBoss is complaining about an annotated private instance of an Entity Manager.
I was wondering if anyone can let me know where I am going wrong.
Here is the code:
| package beans;
|
| import javax.persistence.Entity;
| import java.io.Serializable;
| import javax.persistence.Id;
|
| @Entity
| public class Stock implements Serializable {
| // The persistent fields
| private String tickerSymbol;
| private String name;
|
| // Constructors
| public Stock() {}
| public Stock(String tickerSymbol, String name) {
| this.tickerSymbol = tickerSymbol;
| this.name = name;
| }
|
| // The access methods for persistent fields
| // tickerSymbol is the id
| @Id
| public String getTickerSymbol() {
| return tickerSymbol;
| }
|
| public void setTickerSymbol(String tickerSymbol) {
| this.tickerSymbol = tickerSymbol;
| }
|
| public String getName() {
| return name;
| }
|
| public void setName(String name) {
| this.name = name;
| }
| }
|
| package beans;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface StockList {
| // The public business methods on the StockList bean
| public String getStock(String ticker);
| public void addStock(String ticker, String name);
| public void updateStock(String ticker, String name);
| public void deleteStock(String ticker);
| }
|
| package beans;
|
| import beans.Stock;
| import javax.persistence.PersistenceContext;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
|
| @Stateless
| public class StockListBean implements StockList {
|
| // The reference to the entity manager
| @PersistenceContext
| private EntityManager _manager;
|
| // The public business methods. These must be coded in the
| // interface also
|
| public String getStock(String ticker) {
| Stock stock = _manager.find(Stock.class, ticker);
| return stock.getName();
| }
|
| public void addStock(String ticker, String name) {
| _manager.persist(new Stock(ticker, name));
| }
|
| public void updateStock(String ticker, String name) {
| Stock stock = _manager.find(Stock.class, ticker);
| stock.setName(name);
| }
|
| public void deleteStock(String ticker) {
| Stock stock = _manager.find(Stock.class, ticker);
| _manager.remove(stock);
| }
| }
|
I've deployed a jar called StockListApp.ejb3 with the classes compiled from this code and come up against the following error
------
2008-03-06 18:35:55,671 DEBUG [org.jboss.deployment.MainDeployer] Begin deployment start file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3
2008-03-06 18:35:55,671 DEBUG [org.jboss.ejb3.EJB3Deployer] start application, deploymentInfo: org.jboss.deployment.DeploymentInfo@fe1c38ab { url=file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3 }
deployer: MBeanProxyExt[jboss.ejb3:service=EJB3Deployer]
status: Starting
state: START_DEPLOYER
watch: file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3
altDD: null
lastDeployed: 1204828555656
lastModified: 1204828555656
mbeans:
, short name: StockListApp.ejb3, parent short name: null
2008-03-06 18:35:55,671 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:service=EJB3,module=StockListApp.ejb3
2008-03-06 18:35:55,671 DEBUG [org.jboss.ejb3.Ejb3Module] Starting jboss.j2ee:service=EJB3,module=StockListApp.ejb3
2008-03-06 18:35:55,671 DEBUG [org.jboss.system.ServiceController] stopping service: jboss.j2ee:jar=StockListApp.ejb3,name=StockListBean,service=EJB3
2008-03-06 18:35:55,671 WARN [org.jboss.system.ServiceController] Ignoring request to stop nonexistent service: jboss.j2ee:jar=StockListApp.ejb3,name=StockListBean,service=EJB3
2008-03-06 18:35:55,671 DEBUG [org.jboss.system.ServiceController] destroying service: jboss.j2ee:jar=StockListApp.ejb3,name=StockListBean,service=EJB3
2008-03-06 18:35:55,671 WARN [org.jboss.system.ServiceController] Ignoring request to destroy nonexistent service: jboss.j2ee:jar=StockListApp.ejb3,name=StockListBean,service=EJB3
2008-03-06 18:35:55,671 WARN [org.jboss.ejb3.JmxKernelAbstraction] jboss.j2ee:jar=StockListApp.ejb3,name=StockListBean,service=EJB3 is not registered
2008-03-06 18:35:55,671 DEBUG [org.jboss.ejb3.Ejb3Module] Starting failed jboss.j2ee:service=EJB3,module=StockListApp.ejb3
java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.
at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182)
at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:137)
at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)
at org.jboss.ejb3.SessionContainer.processMetadata(SessionContainer.java:140)
at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy33.start(Unknown Source)
at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy34.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
2008-03-06 18:35:55,671 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=StockListApp.ejb3
java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.
at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182)
at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:137)
at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)
at org.jboss.ejb3.SessionContainer.processMetadata(SessionContainer.java:140)
at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy33.start(Unknown Source)
at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy34.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
2008-03-06 18:35:55,765 INFO [org.jboss.ejb3.EJB3Deployer] Deployed: file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3
2008-03-06 18:35:55,765 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: StockListApp.ejb3
2008-03-06 18:35:55,765 DEBUG [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3
2008-03-06 18:35:55,765 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Watch URL for: file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3 -> file:/C:/apps/jboss-4.2.2.GA/server/all/deploy/StockListApp.ejb3
2008-03-06 18:35:55,765 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:service=EJB3,module=StockListApp.ejb3
State: FAILED
Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:service=EJB3,module=StockListApp.ejb3
State: FAILED
Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.
-----
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134654#4134654
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134654
18 years, 1 month
[JBoss jBPM] - Re: Do we really need
by deepuin9
Hi bungrudi ,
I was trying to do something similar to what you are talking about. My idea is to have a node using which I should be able to define the transitions at runtime.
Have a look at the sample process definition below, if you observe state 3 does not have any transition.
<?xml version="1.0" encoding="UTF-8"?>
| <process-definition xmlns="" name="statetrans">
| <start-state name="start-state1">
| <transition to="state1"></transition>
| </start-state>
|
| <state name="state1">
| <transition to="state2"></transition>
| </state>
|
| <state name="state2">
| <transition to="end-state1"></transition>
| <transition to="state1" name="to state1"></transition>
| </state>
|
| <state name="state3"></state>
|
| <end-state name="end-state1"></end-state>
| </process-definition>
In the below test case, I tried to added the transition at runtime and it worked :) . Now I am in the process of building my custom node :)
public void testAddingTransitionsToState3AtRuntime() {
| Node node3 = processDefinition.getNode("state3");
| Node node2 = processDefinition.getNode("state2");
| Node end = processDefinition.getNode("end-state1");
|
|
| Token token = processInstance.getRootToken();
| assertEquals("start-state1", token.getNode().getName());
|
| processInstance.signal();
| assertEquals("state1", token.getNode().getName());
|
| //Ideally I would like to add new transition from state1 to state3
| Transition trans = processInstance.getRootToken().getNode()
| .getDefaultLeavingTransition();
| Node to = trans.getTo();
| Node from = trans.getFrom();
| System.out.println("from " + from.getName() + " to " + to.getName());
|
| trans.setTo(node3);
| processInstance.signal();
| assertEquals("state3", token.getNode().getName());
| //As state 3 does not have any transition defined it will return null
| Transition leavingTransitionState3 = processInstance.getRootToken().getNode()
| .getDefaultLeavingTransition();
| //Creating new transition.
| leavingTransitionState3 = new Transition("test");
| leavingTransitionState3.setTo(node2);
| leavingTransitionState3.setFrom(node3);
| processInstance.getRootToken().getNode().addLeavingTransition(leavingTransitionState3);
| System.out.println("from " + leavingTransitionState3.getFrom().getName() + " to " + leavingTransitionState3.getTo().getName());
|
| processInstance.signal();
| assertEquals("state2", token.getNode().getName());
| processInstance.signal();
| assertEquals("end-state1", token.getNode().getName());
| }
| [/url]
Hope it helped.
Thanks
Sandeep
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134653#4134653
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134653
18 years, 1 month