Using CLI in @Startup resource
olpf Oct 16, 2012 7:13 AMHi,
I want to implement an automatically setup for the data sources upon environmental properties. Therefore I defined a class with @Startup and @Singleton (EJB) annotation and @PostConstruct method to setup the data sources on jboss startup. The code cleans and creates the data sources on every startup.
If I test my code outside the @Startup, @Singleton, @PostConstruct it works. Unfortunately it doesn't work on jboss startup. E. g. the registering of a data source is getting a timeout:
13:03:38,412 INFO [stdout] (MSC service thread 1-5) 2012-10-16 13:03:38,412 1482 INFO [package.jboss.DataSourceRegistrationImpl|registerDataSources] (MSC service thread 1-5) Going to register data sources list with size: 1
13:04:35,868 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "my-ear-x-SNAPSHOT.ear" was rolled back with failure message Operation cancelled
13:04:35,869 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period [60 seconds]. Check the server configuration file and the server logs to find more about the status of the deployment.
13:08:37,193 WARN [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffffc0a8040e:-742041f3:507d3efd:8 in state RUN
13:08:39,075 WARN [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012095: Abort of action id 0:ffffc0a8040e:-742041f3:507d3efd:8 invoked while multiple threads active within it.
13:08:39,077 WARN [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012108: CheckedAction::check - atomic action 0:ffffc0a8040e:-742041f3:507d3efd:8 aborting with 1 threads active!
13:08:39,078 WARN [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012121: TransactionReaper::doCancellations worker Thread[Transaction Reaper Worker 0,5,main] successfully canceled TX 0:ffffc0a8040e:-742041f3:507d3efd:8
Tried:
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
ctx.connectController("localhost", 9999);
and
ModelControllerClient mcc = ModelControllerClient.Factory.create("localhost", 9999);
with the same result.
Registration of a data source:
ModelNode requestCreateDs = new ModelNode();
requestCreateDs.get(ClientConstants.OP).set(ClientConstants.ADD);
requestCreateDs.get(ClientConstants.OP_ADDR).add("subsystem", "datasources");
requestCreateDs.get(ClientConstants.OP_ADDR).add("data-source", curDsName);
requestCreateDs.get("jndi-name").set(curDsJndiName);
requestCreateDs.get("connection-url").set(curDsDbUrl);
requestCreateDs.get("driver-class").set(driverClass);
requestCreateDs.get("driver-name").set(driverName);
requestCreateDs.get("user-name").set(curUserName);
requestCreateDs.get("password").set(curPassword);
//requestCreateDs.get("pool-name").set("pool_NewDatasource");
mcc.execute(request);
// close cc or mcc afterwards...
Any idea?
Regards,
Oliver