[JBoss Seam] - Re: When to use @PersistenceContext vrs @In EntityManager (S
by msystems
"kasim" wrote : "msystems" wrote : Use @PersistenceContext if you are using EJB3 and if you need a new transaction (@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) ) - Seam ref:
| |
| | anonymous wrote :
| | | If you are using EJB3 and mark your class or method @TransactionAttribute(REQUIRES_NEW) then the trans-
| | | action and persistence context shouldn't be propagated to method calls on this object. However as the Seam-
| | | managed persistence context is propagated to any component within the conversation, it will be propagated to
| | | methods marked REQUIRES_NEW. Therefore, if you mark a method REQUIRES_NEW then you should access the en-
| | | tity manager using @PersistenceContext.
| | |
| |
| | otherwise use SMPC.
| |
|
| What you are saying at the top part is true.
|
| However i don't believe the doco is saying use SMPC all the time.
|
| Take a look at the first paragraph of the section. It basically refers to if you are using the component outside of a Java EE5 environment or if you have many loosly coupled components. Which as long as they are all SB the PersisetnceCOntext should transfer. However the doco is 100% right if you are going to have a mix of SB and POJOS .... then yeah doing the EntityManager injection is the only way to go.
|
| So you can stick with the @PersistenceContext in most situations. Its going to be a situation where you are wanting to transact against non-EJB components you will want to use the @IN EntityManger.
|
| Of course that being said i am not sure the harm it would cause using the @In EntityManager more often.
Of course you don't have to use SMPC if you don't want to use it !
But there is an advantage in using SMPC if you have a lot of conversations with loosly coupled components.
98% of the time I'm using a SMPC and the last 2% of the time I'm using a persistence context (@PersistenceContext) - of course together with Seam-managed transactions.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127541#4127541
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127541
18 years, 2 months
[JBoss jBPM] - Problem with nodes with async=
by osganian
Hi i have the following process def:
| <process-definition>
| <start-state name='start-state1'>
| <description>start of the process</description>
| <transition name='start-to-check' to='One' />
| </start-state>
| <node name='One' async='true'>
| <script name='script_filecheck'>
| System.out.println(1);
| executionContext.leaveNode();
| </script>
| <transition name='check-to-fork' to='End'></transition>
| </node>
| <end-state name='End' />
| </process-definition>
|
And the following java test code:
| ProcessDefinition processDefinition = saveAndReload(processDefinition);
|
| ProcessInstance processInstance = new ProcessInstance(processDefinition);
| processInstance.signal();
| jbpmContext.save(processInstance);
|
| assertEquals(processDefinition.getNode("One"),
| processInstance.getRootToken().getNode());
|
The process gets to the "One" node but I don't know how to signal it to continue. If I start a new transaction nothing happens and if I try and signal again I get " org.jbpm.JbpmException: this token is locked by job[8]"
What am I doing wrong?
Thanks for any help
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127537#4127537
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127537
18 years, 2 months
[Security & JAAS/JBoss] - Re: JBoss Federated SSO: Does it support?
by sohil.shah@jboss.com
Arjun-
anonymous wrote :
| .. Why would I run two instances of the server to test? To test shouldnt I be just deploying a random test WAR and have the "VALVE" configured. Any request to that application/WAR would require SSO. If I need to run SSO instances on each application server, whats the point?
|
You can certaily deploy all your wars that are part of the SSO Federation in the same instance of JBoss Server and have them all work just fine.
This example of deploying in a different instance is used to demonstrate that your applications can be deployed anywhere you like including in completely different physical servers in a completely different web domain.
In a nutshell, SSO between apps within the same server is trivial (In fact for this setup, you can probably just use the Tomcat SSO). Its when they can be completely location/domain independent, and then the framework truly shines ;)
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127530#4127530
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127530
18 years, 2 months
[JBoss Seam] - FlushMode=MANUAL -- not immediately commited to db?
by tynor
Seam 2.0.0.GA
Hibernate 3.2.4.sp1
MySQL 5.0.16
I am using EJB3/JPA persistence and am having trouble with a manually flushed transaction. Even after a call to em.flush(), the data is not visible to an external db client -- it seems that even though manually flushed, the transaction is not committed until after the outer backing bean action method returns.
I need to ensure that my pending changes to the db are commited to the db so that I can invoke another application which uses that data from the database -- all before actually returning from the backing bean action.
I've tried to call em.getTransaction().commit(), but get a runtime error:
| Caused by: javax.faces.el.EvaluationException: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
|
Is it possible to commit the transaction without returning from an action method?
Thanks!
Report.java:
| @Begin(flushMode=FlushModeType.MANUAL, join=true)
| public void wire() {
| // nop - placeholder function here only to allow manual flushing config
| }
| ...
| public void generate () {
| entityManager.persist(foo);
| entityManager.persist(bar);
| ...
| entityManager.flush();
| log.debug("committed"); <-----------
|
If I set breakpoint after the flush, I cannot see the new data persisted to the database from an external client until I exit all the way back out of the top level action function (report.generate()).
Report.page.xml (the page that invokes the backing bean action):
| <?xml version="1.0" encoding="UTF-8"?>
| <page xmlns="http://jboss.com/products/seam/pages"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
| <!-- wire up manually flushed transaction for reports -->
| <action execute="#{report.wire}"/>
| </page>
|
|
persistence.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- Persistence deployment descriptor for dev profile -->
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="myproject">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/myprojectDatasource</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="update"/>
| <property name="hibernate.cache.use_query_cache" value="true"/>
| <property name="hibernate.show_sql" value="false"/>
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/myprojectEntityManagerFactory"/>
| </properties>
| </persistence-unit>
| </persistence>
|
components.xml:
| <persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/myprojectEntityManagerFactory"
|
myproject-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
|
| <local-tx-datasource>
| <jndi-name>myprojectDatasource</jndi-name>
| <connection-url>jdbc:mysql:///myproject</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>myproject</user-name>
| <password>myproject</password>
| </local-tx-datasource>
|
| </datasources>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127529#4127529
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127529
18 years, 2 months
[JBoss jBPM] - JBPM Running Process without jbpm-console
by RichardC
Hi:
I am using http://labs.jboss.com/downloading/?projectId=jbossjbpm&url=http://downloa...
Java version jdk1.6.0_03. I am running Windows XP SP2. The changes I've made to the default configuration is adding PHP support based on http://labs.jboss.com/file-access/default/members/jbossweb/freezone/modul....
I am wondering if anyone may point me to some documentation or resources, or another thread I didn't find, or give me an explanation on how to deploy a process created by the graphical process designer (GPD) such that it can be run without using the jbpm-console?
Specifically, first I would like to verify what the correct directory structure should be for the .war file. Creating the process project using the GPD, I have the following structure:
| + projectname/
| + src/main/java
| + *.java files created for action,task,decision handlers
| + src/main/config
| + default files created when creating process project(hibernate.cfg.xml, jbpm.cfg.xml, etc.)
| + src/main/jpdl
| + default files created when creating new process definition(processdefinition.xml, gpd.xml)
| + *.xhtml files, forms.xml, created when generating task forms.
|
When saving the process archive locally without deploying, it produces the following directory structure:
| + /
| + files from src/main/jpdl
| + classes/
| + files from src/main/config
| + projectname/
| + files from src/main/jpdl
| + directory structure with *.class files based on the package structure
|
Based on the jbpm-console.war file, the directory structure is:
| + /
| + sa, ua directory which contains .xhtml files.
| + META-INF/
| + MANIFEST.MF
| + WEB-INF/
| + faces-config.xml, jboss-web.xml, web.xml, jbpm4jsf-config.xml
| + lib/
| + .jar files from jbpm library
| + classes/
| + similar files that are in src/main/config
| + (and when I deploy my process, I must copy the compiled *.class files from src/main/java) to this directory to be able to test it using jbpm-console)
|
So do I follow the directory structure of the jbpm-console.war file when trying to create the .war file to be deployed on the server? If so, the process project doesn't contain faces-config.xml, jboss-web.xml, web.xml, jbpm4jsf-config.xml files so do I just copy and use the ones from the jbpm-console.war file?
I assumed the directory structure should be similar to the jbpm-console.war file so I created a build.xml script to copy the necessary files from the process project + the required *.jar files to the necessary directories and created the .war file. I then copied the .war file to the deploy folder of the server and the console prints out a bunch of stuff about deploying the web application until it says that it is ready and I can see the web application in http://localhost:8080/status?full=true
When the web application becomes 'ready', does it mean that the process definition has been loaded into the database and it is ready to create process instances? Or do we still have to register the process definition in the database?
I'll start with these questions and hopefully some explanations may help clarify other questions I have.
Thank you for your time.
Regards,
Richard[/url]
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127525#4127525
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127525
18 years, 2 months