[EJB 3.0] - @EJB problem
by ziqew
When I run jboss ejb 3.0 tutorial,there is a java file like this:
package org.jboss.tutorial.extended.bean;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Remove;
import javax.ejb.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
/**
* comment
*
* @author Bill Burke
*/
@Stateful
@Remote(ShoppingCart.class)
public class ShoppingCartBean implements ShoppingCart
{
@PersistenceContext(type=PersistenceContextType.EXTENDED) EntityManager em;
@EJB StatelessLocal stateless;
private Customer customer;
public long createCustomer()
{
customer = new Customer();
customer.setName("William");
em.persist(customer);
return customer.getId();
}
public void update()
{
customer.setName("Bill");
}
public void update2()
{
customer.setName("Billy");
}
public void update3()
{
stateless.update(customer);
}
public Customer find(long id)
{
return em.find(Customer.class, id);
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void never()
{
customer.setName("Bob");
}
@Remove
public void checkout()
{
}
}
i can not compile this file ,the error message is can not find symbol
[javac] symbol? class EJB
jboss-ejb3x.jar in the classpath
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963719#3963719
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963719
19 years, 9 months
[JBoss jBPM] - swimlane user assigment seems to doesn't work
by antitrust1982
Hi all,
I created a process where I have two differents swimlane role:
| <swimlane name='Swimlane1' >
| <assignment expression='user(ernie)'/>
| </swimlane>
|
| <swimlane name='Swimlane2' >
| <assignment expression='user(bert)'/>
| </swimlane>
|
I affect for each role a task in order to see if the swimlane works:
| <task-node name='DeclarationSinistre'>
| <task swimlane='FONCIA'>
| </task>
| <transition name='' to='EnregistrementSinistre'>"+"</transition>
| </task-node>
|
| <task-node name='EnregistrementSinistre'>
| <task swimlane='Assurimo'>
| </task>
| <transition name='' to='ControlePrime'></transition>
| </task-node>
In my java file I initialise the context and declare my swimlane:
| ProcessInstance processInstance = new ProcessInstance(processDefinition);
| JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
|
| try {
| jbpmContext.deployProcessDefinition(processDefinition);
| ///////////////////////////////////////////////////////////////
| Swimlane s = new Swimlane("Swimlane1");
| processInstance.getProcessDefinition().getTaskMgmtDefinition().addSwimlane(s);
| System.out.println(s);
| s.addTask(processInstance.getProcessDefinition().getTaskMgmtDefinition().getTask("DeclarationSinistre"));
|
For see if my swimlane works I put in the JbpmContext the user of the second swimlane, and execute my process:
| jbpmContext.setActorId("bert");Token token = processInstance.getRootToken();
| nameProcess=processInstance.getProcessDefinition().getName();
| System.out.println("nom de l'utilisateur est:"+ jbpmContext.getActorId());
| this.setNameProcess(nameProcess);
| token.signal();
| currentNode=token.getNode().getName();
| this.setCurrentNode(currentNode);
| System.out.println("noeud courant:"+currentNode);
| jbpmContext.save(token);
| jbpmContext.save(processInstance);
| Map session = (Map) ActionContext.getContext().get("session");
| session.put("process",processInstance); session.put("processName",nameProcess);
| }
| finally {
| System.out.println("dans finally");
| jbpmContext.close();
| System.out.println("fermeture du context");
| }
|
When I execute my process, my task is execute while the user is a user of swimlane2, and in the anothers tasks where the swimlane role is different (alternance of swimlane1 and swimlane2) the process continue to be executed like there isn't any swimlane role.
Somebody can help me to put in the context the user in order to be seen by the swimlane, please.
I hope, I explain well because it's difficult to explain exactly my problem. I will try to summary now:
I have two swimlane role I declare in my processdefinition the both and when I execute my process the changement of role in ignored. And the assigment by setActorId too.
can you help me to resolve my problem please
antitrust1982
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963714#3963714
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963714
19 years, 9 months
[EJB 3.0] - Re: Simple EJB3 Transaction Question
by grdzeli_kaci
thanks. It's working but i have another problem :(
working code :
| @TransactionManagement(TransactionManagementType.BEAN)
| @Remote(Fasade.class)
| public @Stateless class FasadeBean implements Fasade
| {
| @PersistenceContext(unitName = "TEST")
| private EntityManager oracleManager;
| @Resource public UserTransaction utx;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void addTest(Test t) throws IllegalStateException, SecurityException, SystemException
| {
| try {
| System.out.println("============== Income =============");
| utx.begin();
| System.out.println("EntityManager = "+oracleManager);
| System.out.println("UserTransaction = "+utx);
|
| System.out.println("Test = "+t);
| oracleManager.persist(t);
|
| utx.commit();
| System.out.println(" =============== Persisted =======");
| } catch (Exception e) {
| utx.rollback();
| e.printStackTrace();
| }
| }
|
|
and then i did some changes on this :
remove commit from this method and create new methot :
| public void commit() throws IllegalStateException, SecurityException, SystemException
| {
| try {
| utx.commit();
| System.out.println(" =============== Commited =======");
| } catch (Exception e) {
| utx.rollback();
| e.printStackTrace();
| }
| }
|
i want that one method begis transactions and another finish it.
but i get an error :
| javax.ejb.EJBException: Application error: BMT stateless bean FasadeBean should complete transactions before returning (ejb1.1 spec, 11.6.1)
| at org.jboss.ejb3.tx.BMTInterceptor.checkStatelessDone(BMTInterceptor.java:184)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963711#3963711
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963711
19 years, 9 months