-
Enhancement
-
Resolution: Won't Do
-
Optional
-
PLINK_2.5.2.FInal
We are using JBoss EAP 6.2 in domain mode in CLUSTER. We use the two instance that conform the cluster in the same machine in DEV and INT environment.
In production we use LDAP based identity store with each instance in a separate machine, but in DEV and INT we use file based identity store, we switch from one config to the other depending on the environment thanks to Apache Deltaspike @Exclude annotation.
We use this:
@Startup
@Singleton
@Exclude(ifProjectStage = Production.class)
public class IDMInitializer {
@Inject
private PartitionManager partitionManager;
/**
- <p>Initializes the identity store with some default users and roles.</p>
*/
@PostConstruct
public void createDefaultUsers() { createUser("administrador", ApplicationRole.ADMINISTRADOR); createUser("gestio", ApplicationRole.GESTIO); createUser("operacio", ApplicationRole.OPERACIO); }
private void createUser(String loginName, ApplicationRole roleName) {
IdentityManager identityManager = this.partitionManager.createIdentityManager();
User user = getUser(identityManager, loginName);
if (user == null)
{ user = new User(loginName); identityManager.add(user); Password password = new Password(loginName + "123"); identityManager.updateCredential(user, password); }Role role = getRole(identityManager, roleName.name());
if (role == null)
{ role = new Role(roleName.name()); identityManager.add(role); }RelationshipManager relationshipManager = this.partitionManager.createRelationshipManager();
if (!hasRole(relationshipManager, user, role))
{ grantRole(relationshipManager, user, role); }}
}
In DEV and INT the IDM doesn't start because both instances try to write at the same time to /tmp/pl-idm where PL manages the databases.
We get this error:
15:33:21,573 INFO [stdout] (ServerService Thread Pool – 71) Hibernate:
15:33:21,574 INFO [stdout] (ServerService Thread Pool – 71) create sequence hibernate_sequence
15:33:21,639 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool – 71) HHH000230: Schema export complete
15:33:23,957 INFO [org.apache.deltaspike.jsf.impl.scope.mapped.MappedJsf2ScopeExtension] (MSC service thread 1-4) JSF2 bean was converted to a CDI bean. Type: cat.tmb.tdo.ocicommerce.view.utils.JSFResources original scope: javax.faces.bean.ApplicationScoped
15:33:27,808 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool – 75) MSC000001: Failed to start service jboss.deployment.unit."ocicommerce.war".component.IDMInitializer.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."ocicommerce.war".component.IDMInitializer.START: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_21]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_21]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:126)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:141)
at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
... 7 more
Caused by: javax.ejb.EJBException: org.picketlink.idm.IdentityManagementException: PLIDM000602: Could not add AttributedType [org.picketlink.idm.model.basic.User@e595f800]..
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:189)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:274)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:368)
at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
... 11 more
Caused by: org.picketlink.idm.IdentityManagementException: PLIDM000602: Could not add AttributedType [org.picketlink.idm.model.basic.User@e595f800].
at org.picketlink.idm.internal.ContextualIdentityManager.add(ContextualIdentityManager.java:86)
at cat.tmb.tdo.ocicommerce.services.security.IDMInitializer.createUser(IDMInitializer.java:73)
at cat.tmb.tdo.ocicommerce.services.security.IDMInitializer.createDefaultUsers(IDMInitializer.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_21]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_21]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_21]
at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:73)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:272)
... 20 more
Caused by: org.picketlink.idm.IdentityManagementException: Error flushing changes to file system.
at org.picketlink.idm.file.internal.FileDataSource.performFlush(FileDataSource.java:304)
at org.picketlink.idm.file.internal.FileDataSource.flush(FileDataSource.java:282)
at org.picketlink.idm.file.internal.FileDataSource.flush(FileDataSource.java:269)
at org.picketlink.idm.file.internal.FileDataSource.flushAttributedTypes(FileDataSource.java:132)
at org.picketlink.idm.file.internal.FileIdentityStore.storeIdentityType(FileIdentityStore.java:696)
at org.picketlink.idm.file.internal.FileIdentityStore.addAttributedType(FileIdentityStore.java:95)
at org.picketlink.idm.internal.AbstractIdentityStore.add(AbstractIdentityStore.java:64)
at org.picketlink.idm.internal.ContextualIdentityManager.add(ContextualIdentityManager.java:81)
... 39 more
Caused by: java.io.FileNotFoundException: /tmp/pl-idm/ee53b050-aa45-4b8a-bfaf-1211829b02ea/pl-idm-identity-types.db (No such file or directory)
at java.io.RandomAccessFile.open(Native Method) [rt.jar:1.7.0_21]
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233) [rt.jar:1.7.0_21]
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:118) [rt.jar:1.7.0_21]
at org.picketlink.idm.file.internal.FileDataSource.performFlush(FileDataSource.java:292)
... 46 more
15:33:28,104 ERROR [org.jboss.as.server] (host-controller-connection-threads - 33) JBAS015870: Deploy of deployment "ocicommerce.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"ocicommerce.war\".component.IDMInitializer.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"ocicommerce.war\".component.IDMInitializer.START: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: javax.ejb.EJBException: org.picketlink.idm.IdentityManagementException: PLIDM000602: Could not add AttributedType [org.picketlink.idm.model.basic.User@e595f800].
Caused by: org.picketlink.idm.IdentityManagementException: PLIDM000602: Could not add AttributedType [org.picketlink.idm.model.basic.User@e595f800].
Caused by: org.picketlink.idm.IdentityManagementException: Error flushing changes to file system.
Caused by: java.io.FileNotFoundException: /tmp/pl-idm/ee53b050-aa45-4b8a-bfaf-1211829b02ea/pl-idm-identity-types.db (No such file or directory)"}}
15:33:28,245 INFO [org.jboss.as.jpa] (ServerService Thread Pool – 93) JBAS011403: Stopping Persistence Unit Service 'ocicommerce.war#ociCommercePersistenceUnit'
15:33:28,244 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016009: Stopping weld service for deployment ocicommerce.war
15:33:28,272 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool – 93) HHH000227: Running hbm2ddl schema export
Is the a way to manage this situation? If we use JPA based identity store there is no problem.