[JBoss Seam] - the never ending flow of optimistic locking questions
by beligum
Hi all,
This question must be getting boresome to some of you experts here,
but please help an intermediate developer along with some answers to a few simple questions regarding the subject.
I use the @Version annotation in my EJB3 entity bean (Seam, JTA), and, while a user edits the bean-contents, it's possible the info is updated through a JMS-callback from an external source.
Now, I would like to select a few (modified-behind-the-scenes) fields from the database, and let them precede the user-input whatsoever.
So, when I call my entityManager.flush() method (Seam-managed em), it throws a StaleObjectStateException, because of the JMS-update. In this post (http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3919517#3919517), Gavin points out that it's possible to present the user with the changes made in the DB, by starting up a new context/transaction. He even points out how to do it, but in his own expert-style, the explanation is still quite cryptic to me.
Can anyone elaborate on the:
anonymous wrote : To "get" a new PC/txn to work with, call a session bean in the context of a REQUIRES_NEW transaction (if it is stateful, it needs to be a newly instantiated SFSB).
This is my relevant code (a conversation-scoped SFSB in a long-running conversation/transaction):
| public String updateEntity()
| {
| ...
| try {
| entityManager.merge(getSelectedInode());
| entityManager.flush();
|
| return "success";
| }
| catch (OptimisticLockException e) {
| VersionConflictManager conflictManager = (VersionConflictManager)Component.getInstance("versionConflictManager");
| File dbFile = (File)conflictManager.getConflictingDbObject(File.class, getSelectedInode().getFileSystemEntity().getId());
| System.out.println("test");
| }
| }
|
And here's my VersionConflictManager
| @Stateful
| @Scope(CONVERSATION)
| @Name("versionConflictManager")
| public class VersionConflictManager implements Serializable
| {
|
| //-----VARIABLES-----
| @In(create=true)
| EntityManager entityManager;
|
| //-----CONSTRUCTORS-----
| public VersionConflictManager()
| {
| }
|
| //-----GETTERS/SETTERS------
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Object getConflictingDbObject(Class entityClass, int id)
| {
| return entityManager.find(entityClass, id);
| }
|
| @Remove
| @Destroy
| public void destroy()
| {
| }
| }
|
Apparently, I'm missing something, because I get a StaleObjectStateException when I try to instantiate the VersionConflictManager in the catch-code.
Any help is appreciated,
bram
PS: I'm cross-posting this from the Persistence,JBoss/CMP, Hibernate, ... forum, to raise my chances in getting a response (http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055537#4055537), please forgive me my insolence
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055542#4055542
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055542
18Â years, 10Â months
[Installation, Configuration & Deployment] - Unable to deploy persistence entity on JBOss : Please Help
by ashusri000
Dear All ,
I am trying to deploy make a simple flow as :
Servlet ---> (invokes) Stateless Bean ---- > (invokes) Entity Bean(persistence object )
But I am unable to deploy this Entity Bean on JBoss 4.xx. I have packed this entity bean as an ear . The persistence.xml has following entries :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testApp" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/XAOracleDS</jta-data-source>
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Emp
Employee
Software
SoftwareFile
<!-- Provider-specific connection properties -->
<!-- Provider-specific settings -->
<!-- other values are: drop-and-create-tables|none -->
</persistence-unit>
I have put the Oracle jdbc libraries in the jboss/server/lib directory and have also configured the oracle-xa-ds.xml file for the system user and password .
The ear contains the application.xml file which has the entry for persistence.jar as :
sample.jar
<web-uri>
</web-uri>
<context-root>
sample
</context-root>
persist.jar
Now when I go for the deployment I get this error on the Server console :---
ERROR [PersistenceXmlLoader] Error parsing XML: XML InputStream(5) cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
15:53:37,093 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=persist.jar
javax.persistence.PersistenceException: invalid persistence.xml
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:66)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:73)
at org.jboss.ejb3.Ejb3Deployment.initializePersistenceUnits(Ejb3Deployment.java:602)
at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:465)
at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:125)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
PLEASE HELP ME FIGURE OUT WHERE THE ERROR IS :?????????
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055541#4055541
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055541
18Â years, 10Â months
[EJB/JBoss] - Unable to deploy persistence entity on JBOss : Please Help
by ashusri000
Dear All ,
I am trying to deploy make a simple flow as :
Servlet ---> (invokes) Stateless Bean ---- > (invokes) Entity Bean(persistence object )
But I am unable to deploy this Entity Bean on JBoss 4.xx. I have packed this entity bean as an ear . The persistence.xml has following entries :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testApp" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/XAOracleDS</jta-data-source>
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Emp
Employee
Software
SoftwareFile
<!-- Provider-specific connection properties -->
<!-- Provider-specific settings -->
<!-- other values are: drop-and-create-tables|none -->
</persistence-unit>
I have put the Oracle jdbc libraries in the jboss/server/lib directory and have also configured the oracle-xa-ds.xml file for the system user and password .
The ear contains the application.xml file which has the entry for persistence.jar as :
sample.jar
<web-uri>
</web-uri>
<context-root>
sample
</context-root>
persist.jar
Now when I go for the deployment I get this error on the Server console :---
ERROR [PersistenceXmlLoader] Error parsing XML: XML InputStream(5) cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
15:53:37,093 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=persist.jar
javax.persistence.PersistenceException: invalid persistence.xml
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:66)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:73)
at org.jboss.ejb3.Ejb3Deployment.initializePersistenceUnits(Ejb3Deployment.java:602)
at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:465)
at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:125)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
PLEASE HELP ME FIGURE OUT WHERE THE ERROR IS :?????????
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055540#4055540
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055540
18Â years, 10Â months
[EJB 3.0] - Unable to deploy persistence entity on JBOss : Please Help
by ashusri000
Dear All ,
I am trying to deploy make a simple flow as :
Servlet ---> (invokes) Stateless Bean ---- > (invokes) Entity Bean(persistence object )
But I am unable to deploy this Entity Bean on JBoss 4.xx. I have packed this entity bean as an ear . The persistence.xml has following entries :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testApp" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/XAOracleDS</jta-data-source>
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Emp
Employee
Software
SoftwareFile
<!-- Provider-specific connection properties -->
<!-- Provider-specific settings -->
<!-- other values are: drop-and-create-tables|none -->
</persistence-unit>
I have put the Oracle jdbc libraries in the jboss/server/lib directory and have also configured the oracle-xa-ds.xml file for the system user and password .
The ear contains the application.xml file which has the entry for persistence.jar as :
sample.jar
<web-uri>
</web-uri>
<context-root>
sample
</context-root>
persist.jar
Now when I go for the deployment I get this error on the Server console :---
ERROR [PersistenceXmlLoader] Error parsing XML: XML InputStream(5) cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
15:53:37,093 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=persist.jar
javax.persistence.PersistenceException: invalid persistence.xml
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:66)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:73)
at org.jboss.ejb3.Ejb3Deployment.initializePersistenceUnits(Ejb3Deployment.java:602)
at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:465)
at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:125)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
PLEASE HELP ME FIGURE OUT WHERE THE ERROR IS :?????????
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055539#4055539
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055539
18Â years, 10Â months
[JBoss jBPM] - BPEL process doesn't respond
by Kantti_
Hello.
I'm farely new to BPEL and WS but I have managed to get the BPEL tutorials up and running.
I'm using:
JBoss AS 4.0.5.GA
JBossWS 1.2.1.GA
jbpm-bpel 1.1.Beta5
I have done the HelloWorld process with BPEL Designer 0.2.0.
The files I've made are (otherwise the code is from the original tutorial):
HELLO.BPEL:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
| <bpws:process xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/" xmlns:tns="http://jbpm.org/examples/hello" exitOnStandardFault="yes" name="HelloWorld" suppressJoinFailure="yes" targetNamespace="http://jbpm.org/examples/hello">
| <bpws:import importType="http://schemas.xmlsoap.org/wsdl/" location="hello.wsdl" namespace="http://jbpm.org/examples/hello"/>
| <bpws:partnerLinks>
| <bpws:partnerLink myRole="Greeter" name="caller" partnerLinkType="tns:Caller-Greeter"/>
| </bpws:partnerLinks>
| <bpws:variables>
| <bpws:variable messageType="tns:nameMessage" name="request"/>
| <bpws:variable messageType="tns:greetingMessage" name="response"/>
| </bpws:variables>
| <bpws:sequence>
| <bpws:receive name="Receive" operation="sayHello" partnerLink="caller" portType="tns:Greeter" variable="request"/>
| <bpws:assign name="Assign" validate="no">
| <bpws:copy>
| <bpws:from><![CDATA[concat('Hello, ', bpws:getVariableData('request', 'name'), '!')]]></bpws:from>
| <bpws:to part="greeting" variable="response"/>
| </bpws:copy>
| </bpws:assign>
| <bpws:reply name="Reply" operation="sayHello" partnerLink="caller" portType="tns:Greeter" variable="response"/>
| </bpws:sequence>
| </bpws:process>
HELLO.WSDL:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
| <wsdl:definitions xmlns:tns="http://jbpm.org/examples/hello" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="hello" targetNamespace="http://jbpm.org/examples/hello" xmlns:p="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
| <wsdl:message name="nameMessage">
| <wsdl:part name="name" type="xsd:string"></wsdl:part>
| </wsdl:message>
| <wsdl:message name="greetingMessage">
| <wsdl:part name="greeting" type="xsd:string"></wsdl:part>
| </wsdl:message>
| <wsdl:portType name="Greeter">
| <wsdl:operation name="sayHello">
| <wsdl:input message="tns:nameMessage"></wsdl:input>
| <wsdl:output message="tns:greetingMessage"></wsdl:output>
| </wsdl:operation>
| </wsdl:portType>
| <p:partnerLinkType name="Caller-Greeter">
| <p:role portType="tns:Greeter" name="Greeter"></p:role>
| </p:partnerLinkType>
| </wsdl:definitions>
Could the problem be in the code above? The war-file deploys nicely but the junit test just freezes. The ws is called but it doesn't send a response.
Thanks for the help.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055538#4055538
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055538
18Â years, 10Â months
[Persistence, JBoss/CMP, Hibernate, Database] - the never ending flow of optimistic locking questions
by beligum
Hi all,
This question must be getting boresome to some of you experts here,
but please help an intermediate developer along with some answers to a few simple questions regarding the subject.
I use the @Version annotation in my EJB3 entity bean (Seam, JTA), and, while a user edits the bean-contents, it's possible the info is updated through a JMS-callback from an external source.
Now, I would like to select a few (modified-behind-the-scenes) fields from the database, and let them precede the user-input whatsoever.
So, when I call my entityManager.flush() method (Seam-managed em), it throws a StaleObjectStateException, because of the JMS-update. In this post (http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3919517#3919517), Gavin points out that it's possible to present the user with the changes made in the DB, by starting up a new context/transaction. He even points out how to do it, but in his own expert-style, the explanation is still quite cryptic to me.
Can anyone elaborate on the:
anonymous wrote : To "get" a new PC/txn to work with, call a session bean in the context of a REQUIRES_NEW transaction (if it is stateful, it needs to be a newly instantiated SFSB).
This is my relevant code (a conversation-scoped SFSB in a long-running conversation/transaction):
| public String updateEntity()
| {
| ...
| try {
| entityManager.merge(getSelectedInode());
| entityManager.flush();
|
| return "success";
| }
| catch (OptimisticLockException e) {
| VersionConflictManager conflictManager = (VersionConflictManager)Component.getInstance("versionConflictManager");
| File dbFile = (File)conflictManager.getConflictingDbObject(File.class, getSelectedInode().getFileSystemEntity().getId());
| System.out.println("test");
| }
| }
|
And here's my VersionConflictManager
| @Stateful
| @Scope(CONVERSATION)
| @Name("versionConflictManager")
| public class VersionConflictManager implements Serializable
| {
|
| //-----VARIABLES-----
| @In(create=true)
| EntityManager entityManager;
|
| //-----CONSTRUCTORS-----
| public VersionConflictManager()
| {
| }
|
| //-----GETTERS/SETTERS------
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Object getConflictingDbObject(Class entityClass, int id)
| {
| return entityManager.find(entityClass, id);
| }
|
| @Remove
| @Destroy
| public void destroy()
| {
| }
| }
|
Apparently, I'm missing something, because I get a StaleObjectStateException when I try to instantiate the VersionConflictManager in the catch-code.
Any help is appreciated,
bram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055537#4055537
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055537
18Â years, 10Â months