[EJB 3.0] - Duplicate Key / SystemException
by toni
Hi,
In my application it's very likely that two entity beans with the same primary key (consisting of a string) get persisted at the same time. If that happens a "duplicate key" exception (PersistenceException/NonUniqueObjectException) is raised and the the current transaction is unfortuantely being rolled back.
The problem is that it does not seem to be possible to recover from this error gracefully. Trying to catch the exception nevertheless rolls back the transaction. I have read, that's because it's an SystemException and that those kind of RuntimeExceptinons always roll back the current transaction.
I have also read that, if we declare those RuntimeExceptions as application exceptions in the ejb-jar xml description and set the rollback tag to false, the current transaction is not being rolled back. I have tried this by inserting the following xml into my ejb-jar, but it does not prevent the transaction from being rolled back:
| <ejb-jar>
|
| <assembly-descriptor>
| <interceptor-binding>
| <ejb-name>*</ejb-name>
| <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
| </interceptor-binding>
|
| <application-exception>
| <exception-class>org.hibernate.NonUniqueObjectException</exception-class>
| <rollback>false</rollback>
| </application-exception>
|
| <application-exception>
| <exception-class>javax.persistence.PersistenceException</exception-class>
| <rollback>false</rollback>
| </application-exception>
|
| </assembly-descriptor>
|
| </ejb-jar>
|
|
My application heavily depends on gracefully dealing with those kind of duplicate key exceptions, because I need them to figure out, whether or not a certain entity already exists and I can't use a simple SELECT to find out, because of concurrency issues and I can't use an isolation level of Serializable, because of performance reasons.
How can I make sure that I catch those kind of duplicate key exceptions without the current transaction being rolled back when I call entityManager.persit(myEntityBean) ???
Toni
PS: This guy seems to have the same problem
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=84125
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087645#4087645
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087645
18 years, 7 months
[JBoss Seam] - Unauthenticated Principal
by toni
Hi,
how can I grant unauthenticated users access to parts of my webapplication? I have read that we have to use the tag <unauthenticated-principal> in order to do this. Here is my configuration, maybe somebody can help me out?
|
| ----------- important part of web.cml -------------------------
|
| <security-constraint>
| <web-resource-collection>
| <web-resource-name>Unsecure area</web-resource-name>
| <description>Unprotected Pages</description>
|
| <url-pattern>/homepage.seam</url-pattern>
| <url-pattern>/about.seam</url-pattern>
|
| <http-method>POST</http-method>
| <http-method>GET</http-method>
| </web-resource-collection>
| <auth-constraint>
| <description>All people</description>
| <role-name>guest</role-name>
| </auth-constraint>
| </security-constraint>
|
| <security-constraint>
| <web-resource-collection>
| <web-resource-name>Secure area</web-resource-name>
| <description>Security for Protected Pages</description>
|
| <url-pattern>*.seam</url-pattern>
| <url-pattern>*.jsp</url-pattern>
|
| <http-method>POST</http-method>
| <http-method>GET</http-method>
| </web-resource-collection>
| <auth-constraint>
| <description>All areas are restived</description>
| <role-name>Admin</role-name>
| </auth-constraint>
| </security-constraint>
|
| <login-config>
| <auth-method>FORM</auth-method>
| <realm-name>userDatabase</realm-name>
| <form-login-config>
| <form-login-page>/login.seam</form-login-page>
| <form-error-page>/loginError.seam</form-error-page>
| </form-login-config>
| </login-config>
|
| <security-role>
| <description>The role of an adminr</description>
| <role-name>Admin</role-name>
| </security-role>
|
| <security-role>
| <description>Any body</description>
| <role-name>guest</role-name>
| </security-role>
| </web-app>
|
| ---------------------- userDatabase login config ------------------------
|
| <application-policy name="userDatabase">
| <authentication>
| <login-module
| code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
| flag="required">
| <module-option name="unauthenticatedIdentity">guest</module-option>
| <module-option name="dsJndiName">
| java:/PostgresqlDS
| </module-option>
| <module-option name="principalsQuery">
| SELECT password FROM systemuser WHERE login=?
| </module-option>
| <module-option name="rolesQuery">
| SELECT r.rolename, r.p_group FROM systemuser as o, role as r, systemuser_role as pr WHERE o.login=pr.systemuser_login AND r.roleName = pr.roles_roleName AND o.login=?
| </module-option>
| </login-module>
|
| </authentication>
| </application-policy>
|
| -------------------------------- i also added jboss.xml to my ear archive ---
|
|
| <!DOCTYPE jboss PUBLIC
| "-//JBoss//DTD JBOSS 4.0//EN"
| "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
|
| <jboss>
|
| <security-domain>java:/jaas/userDatabase</security-domain>
| <unauthenticated-principal>guest</unauthenticated-principal>
|
| </jboss>
|
|
| -----------------------------------------------
|
| Unfortuantely unauthenticated people can't access "/homepage.seam" before loggin in.
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087644#4087644
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087644
18 years, 7 months
[JBoss jBPM] - Re: Task list of specified actor
by ebrahimsalehi
Dear member;
TaskMgmtSession which can be fetched from jbpmContext has got various methods to find task instances.
context.getTaskMgmtSession().findTaskInstances(actor);
This method finds all active task instances from all process definitions. If you want to get task instances of a specified process definition you need to get all process instances of that process definition and then call findTaskInstancesByProcessInstance(ProcessInstance processInstance).
The other alternative is to fetch all tokens from process instances of a process definition and call findTaskInstancesByToken(long tokenId). These two methods find all task instances of all actors. To narrow the result make a contribution of findTaskInstancesByProcessInstance(ProcessInstance processInstance) and findTaskInstances(actor) or simply modify findTaskInstancesByProcessInstance including actor id in its hql.
Best Wishes
Ebrahim Salehi
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087639#4087639
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087639
18 years, 7 months