[
https://issues.jboss.org/browse/SEAMSECURITY-91?page=com.atlassian.jira.p...
]
Richard Barabe commented on SEAMSECURITY-91:
--------------------------------------------
Hi, I managed to fix this ! (finally). I had the same problem, using seam-security
3.1.0.Final, with the eclipse link that comes with glassfish 3.1.1.
The problem seems to be that eclipselink doesn't like when you execute a query via the
criteria api whil already building another one. And this is done in
org.jboss.seam.security.management.picketlink.JpaIdentityStore#removeRelationships(IdentityStoreInvocationContext,IdentityObject,IdentityObject,
boolean). While creating a criteria query, lookupIdentity is called, which also build and
execute a query using the criteria api.
To fix it, just call the lookupIdentity method before attempting to build the remove
relationships queries. Here's the diff :
{code}
index fbef3a7..78610ec 100644
---
a/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
+++
b/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
@@ -1439,7 +1439,14 @@ public class JpaIdentityStore implements
org.picketlink.idm.spi.store.IdentitySt
IdentityObject identity1, IdentityObject identity2, boolean named)
throws IdentityException {
EntityManager em = getEntityManager(ctx);
-
+
+ Object loadedIdentity1 = null;
+ if(identity1 != null)
+ lookupIdentity(identity1, em);
+ Object loadedIdentity2 = null;
+ if(identity2 != null)
+ lookupIdentity(identity2, em);
+
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<?> criteria = builder.createQuery(relationshipClass);
Root<?> root = criteria.from(relationshipClass);
@@ -1451,12 +1458,12 @@ public class JpaIdentityStore implements
org.picketlink.idm.spi.store.IdentitySt
if (identity1 != null) {
predicates.add(builder.equal(root.get(relationshipFromProp.getName()),
- lookupIdentity(identity1, em)));
+ loadedIdentity1));
}
if (identity2 != null) {
predicates.add(builder.equal(root.get(relationshipToProp.getName()),
- lookupIdentity(identity2, em)));
+ loadedIdentity2));
}
criteria.where(predicates.toArray(new Predicate[predicates.size()]));
@@ -1473,12 +1480,12 @@ public class JpaIdentityStore implements
org.picketlink.idm.spi.store.IdentitySt
if (identity2 != null) {
predicates.add(builder.equal(root.get(relationshipFromProp.getName()),
- lookupIdentity(identity2, em)));
+ loadedIdentity2));
}
if (identity1 != null) {
predicates.add(builder.equal(root.get(relationshipToProp.getName()),
- lookupIdentity(identity1, em)));
+ loadedIdentity1));
}
criteria.where(predicates.toArray(new Predicate[predicates.size()]));
{code}
I would have submitted a patch file but had problem with my local git repo so I hope the
diff will do.
The diff have been taken from the 3.1.0.Final tag.
Also, a dude on stackoverflow had a similar problem with eclipse link, but did not quite
understand his solution :
http://stackoverflow.com/questions/7290678/eclipselink-jpa-can-i-run-mult...
cannot delete user/role/group in idmconsole example on
glassfish3.1.1
---------------------------------------------------------------------
Key: SEAMSECURITY-91
URL:
https://issues.jboss.org/browse/SEAMSECURITY-91
Project: Seam Security
Issue Type: Bug
Affects Versions: 3.1.0.Beta1
Environment: glassfish3.1.1, seam-security-3.1.0.Beta2
Reporter: Tomas Remes
Assignee: Shane Bryzak
deletion fails:
Exception [EclipseLink-6089] (Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.QueryException
Exception Description: The expression has not been initialized correctly. Only a single
ExpressionBuilder should be used for a query.
For parallel expressions, the query class must be provided to the ExpressionBuilder
constructor, and the query's ExpressionBuilder must
always be on the left side of the expression.
Expression: [
Base org.jboss.seam.security.examples.idmconsole.model.IdentityObjectRelationship]
Query: ReadAllQuery(referenceClass=IdentityObjectRelationship )
at
org.eclipse.persistence.exceptions.QueryException.noExpressionBuilderFound(QueryException.java:877)
at
org.eclipse.persistence.expressions.ExpressionBuilder.getDescriptor(ExpressionBuilder.java:195)
at
org.eclipse.persistence.internal.expressions.DataExpression.getMapping(DataExpression.java:214)
at
org.eclipse.persistence.internal.expressions.QueryKeyExpression.getMapping(QueryKeyExpression.java:388)
at
org.eclipse.persistence.internal.expressions.RelationExpression.isObjectComparison(RelationExpression.java:452)
at
org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:517)
at
org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1300)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:516)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1602)
at
org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:705)
at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:642)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:598)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:839)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:560)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:797)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at
org.jboss.seam.security.management.picketlink.JpaIdentityStore.removeRelationships(JpaIdentityStore.java:1404)
at
org.jboss.seam.security.management.picketlink.JpaIdentityStore.removeIdentityObject(JpaIdentityStore.java:1243)
at
org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository.removeIdentityObject(WrapperIdentityStoreRepository.java:158)
at
org.picketlink.idm.impl.api.session.managers.PersistenceManagerImpl.removeUser(PersistenceManagerImpl.java:231)
at org.jboss.seam.security.management.action.UserAction.deleteUser(UserAction.java:116)
at
org.jboss.seam.security.management.action.org$jboss$weld$bean-WEB-INF$lib$seam-security-3$1$0$Beta2-ManagedBean-org$jboss$seam$security$management$action$UserAction$@javax$enterprise$context$ConversationScoped()@javax$inject$Named(value=)${org$jboss$seam$security$management$action$UserAction$conversation$@javax$inject$Inject()$$org$jboss$seam$security$management$action$UserAction$identitySession$@javax$inject$Inject()$$org$jboss$seam$security$management$action$UserAction$deleteUser$@org$jboss$seam$transaction$Transactional(value=REQUIRED)@org$jboss$seam$transaction$TransactionalInterceptorBinding()$(java$lang$String)$org$jboss$seam$security$management$action$UserAction$save$@org$jboss$seam$transaction$Transactional(value=REQUIRED)@org$jboss$seam$transaction$TransactionalInterceptorBinding()$()$}_$$_WeldClientProxy.deleteUser(org$jboss$weld$bean-WEB-INF$lib$seam-security-3$1$0$Beta2-ManagedBean-org$jboss$seam$security$management$action$UserAction$@javax$enterprise$context$ConversationScoped()@javax$inject$Named(value=)${org$jboss$seam$security$management$action$UserAction$conversation$@javax$inject$Inject()$$org$jboss$seam$security$management$action$UserAction$identitySession$@javax$inject$Inject()$$org$jboss$seam$security$management$action$UserAction$deleteUser$@org$jboss$seam$transaction$Transactional(value=REQUIRED)@org$jboss$seam$transaction$TransactionalInterceptorBinding()$(java$lang$String)$org$jboss$seam$security$management$action$UserAction$save$@org$jboss$seam$transaction$Transactional(value=REQUIRED)@org$jboss$seam$transaction$TransactionalInterceptorBinding()$()$}_$$_WeldClientProxy.java)
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 javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254)
at com.sun.el.parser.AstValue.invoke(AstValue.java:228)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at
org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIData.broadcast(UIData.java:1093)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at
org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:62)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at
org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira