Problem Deploying Application On JBOSS with multiple data source - java

Hi I am trying to deploy two war files on JBOSS EAP 7.1.
Both of these are spring boot Applications for which i have configured JNDI Look up.
My Standalone.xml file looks like something like this..
<datasources>
<datasource jndi-name="java:/JNDI1" pool-name="JNDIPool1" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/test_schema</connection-url>
<driver>mysql</driver>
<security>
<user-name>test1</user-name>
<password>test1</password>
</security>
</datasource>
<datasource jndi-name="java:/JNDI2" pool-name="JNDIPool2" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/test_schema_2</connection-url>
<driver>mysql</driver>
<security>
<user-name>test2</user-name>
<password>test2</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>
Each of thes war files uses different JNDI look up.When I deploy them at the same time One of the War gets deployed where as the other gets failed with the following error. Any help would be appreciated.
Thanks.
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."Test.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."TEST.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "TEST.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.undertow.deployment.default-server.default-host./.session is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158)
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235)
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:768)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.lambda$processDeployment$0(UndertowDeploymentProcessor.java:405)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.processDeployment(UndertowDeploymentProcessor.java:405)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor.deploy(UndertowDeploymentProcessor.java:190)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more

Please allocate different context-root for each application in web.xml. I am guessing you are using default <context-root>/</context-root>, causing DuplicateServiceException for second war. Change it to <context-root>/app1</context-root> & <context-root>/app2</context-root>

Related

fail to migration from jboss as 6 to jboss eap 7.1 with -ds.xml configuration

this is the first time for question.
Please help me to solve this problem.
I've been completed to migration from AS6 to EAP7.1. but, It still has problem with -ds.xml
10:26:01,286 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "mySource.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"mySource.war\".FIRST_MODULE_USE" => "WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"mySource.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJCA0064: Exception deploying datasource java:jboss/datasources/jt400
Caused by: java.lang.IllegalArgumentException: Empty name segment is not allowed for jdbc-driver"}}
upper is the problem log when i tried to debug my source on the JBoss EAP 7.x.
and below is one of my jt400.xml file contents.
<datasource connectable="false" enabled="true" jndi-name="java:jboss/datasources/jt400" jta="true" pool-name="jt400" spy="false" use-ccm="true" use-java-context="true">
<connection-url>jdbc:as400://127.0.0.1</connection-url>
<driver-class>com.ibm.as400.access.AS400JDBCDriver</driver-class>
<datasource-class/>
<driver/>
<transaction-isolation>TRANSACTION_NONE</transaction-isolation>
<pool>
<min-pool-size>0</min-pool-size>
<initial-pool-size>0</initial-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation>
<check-valid-connection-sql>SELECT * FROM SYSIBM.SYSDUMMY1</check-valid-connection-sql>
<use-fast-fail>false</use-fast-fail>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<xa-resource-timeout>0</xa-resource-timeout>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
finally, I was copy the driver file (jt400.jar) into the standalone/lib path.
I don't have any idea to solve this problem...
Please anybody help me... It seriously headache for me haha...
Thankyou!
I think that your problem is this line driver. It can't be empty, you need to define the driver. By example:
<driver>mysql</driver>
and after the just define the driver itself, in this example:
<drivers>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
If you add that area you will resolve the error message.

JBoss - How to set default data source in multi-database environment?

I am migrating my project from JBoss EAP 6.4 to JBoss EAP 7.2.
So I am getting this kind of error,
15:45:50,571 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "my.war")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.DefaultDataSource"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.dummy.env.myDS is missing [jboss.naming.context.java.module..DefaultDataSource]"]
}
I got to know that this error occurs because default data source is not defined in standalone.xml. In previous versions of JBoss EAP removing DefaultDataSource was not giving this issue. In this version defining DefaultDataSource is mandatory even though those applications do not need that default data source.
So I tried giving default data source as an already existing datasource. In this kind of statement:
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:/jdbc/existing" />
And this worked fine.
Now my problem is our environment has multiple databases and their respective data sources.
So we can't define a particular data source as a default. As this will interfere with our applications regular flow. And can create major issues.
We want the application to use their specific data sources only not the default one.
But JBoss EAP 7 is forcing us to specify default data source.
So we can define a dummy default data source? or is there any other alternative way?
default datasource option is present in default binding in standalone.xml
default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/jdbc/jndi-name" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/
Applicable to both JBoss EAP 7.2 and Wildfly :
Modify this part of standalone.xml to set the default datasource :
<?xml version="1.0" encoding="UTF-8"?>
<subsystem xmlns="urn:jboss:domain:datasources:3.0">
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/default" pool-name="default" enabled="true" use-java-context="true" use-ccm="true" statistics-enabled="true">
<connection-url>jdbc:mysql://localhost:3306/default?autoReconnect=true&useSSL=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
JBoss/Wildfly will pick up this as an default datasource.
Hope this helps you :)

How to fix the "tables are already present using metadata" camunda process engine exception?

I am using wildfly 14.0.1 Application server and Camunda V 7.11.0. I have configured mysql db instead of the default camunda h2 db and added the below data-sources to the standalone.xml file. But I get the below exception at deployment. How do I get this exception fixed?
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/camunda11?jdbcCompliantTruncation=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/camunda11?sessionVariables=sql_mode='NO_ENGINE_SUBSTITUTION'&jdbcCompliantTruncation=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
11:47:10,206 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 72) MSC000001: Failed to start service org.camunda.bpm.platform.process-engine.default: org.jboss.msc.service.StartException in service org.camunda.bpm.platform.process-engine.default: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03018 Could not check if tables are already present using metadata.
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$1.run(MscManagedProcessEngineController.java:98)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1349)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03018 Could not check if tables are already present using metadata.
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.checkDatabaseTableException(EnginePersistenceLogger.java:241)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.sql.DbSqlSession.isTablePresent(DbSqlSession.java:494)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.sql.DbSqlSession.isEngineTablePresent(DbSqlSession.java:434)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.AbstractPersistenceSession.dbSchemaUpdate(AbstractPersistenceSession.java:218)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:56)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:34)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:107)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.ProcessEngineImpl.executeSchemaOperations(ProcessEngineImpl.java:120)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:93)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:798)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startProcessEngine(MscManagedProcessEngineController.java:178)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:132)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.util.Tccl.runWithTccl(Tccl.java:54)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.util.Tccl.runUnderClassloader(Tccl.java:46)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startInternal(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$1.run(MscManagedProcessEngineController.java:91)
... 8 more
Caused by: org.apache.ibatis.exceptions.PersistenceException:
I used the mysql-connector-java-5.1.44.jar instead of the 5.1.6 version to fix the exception.

Unable to fill pool: when starting jboss application

My project jboss project is based on spring mvc. When I run the app I get the following error:
Unable to fill pool
Datasource configuration
<!-- JNDI setup -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:jboss/datasources/SSDiaryDS</value>
</property>
</bean>
mysql mapping in jboss standalone.xml
<datasource jndi-name="java:jboss/datasources/SSDiaryDS" pool-name="SSDiaryDSPool">
<connection-url>jdbc:mysql://localhost:3306/schooldairy</connection-url>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
I encountered the same problem with the following stacktrace:
00:18:41,862 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: javax.resource.ResourceException: Could not create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:277)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:235)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.fillToMin(SemaphoreArrayListManagedConnectionPool.java:706) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
Caused by: java.sql.SQLException: I/O Error: Connection reset
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2311)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:345)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:249)
... 5 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196) [rt.jar:1.7.0_79]
at java.net.SocketInputStream.read(SocketInputStream.java:122) [rt.jar:1.7.0_79]
at java.io.DataInputStream.readFully(DataInputStream.java:195) [rt.jar:1.7.0_79]
at java.io.DataInputStream.readFully(DataInputStream.java:169) [rt.jar:1.7.0_79]
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:846)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:727)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2206)
... 10 more
My solution was to terminate other java processes in my machine.
This can be caused by many things, I was wrong with this because of the mysql docker version. I changed the version from 8.0 to 5.7, it worked.
I suggest you check hostname, port, user, password and versions again.

Registering driver : java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource

I need to have H2 in the classpath. I'm using these values :
# driver=org.h2.jdbcx.JdbcDataSource # it doesn't work
driver=org.h2.Driver # it doesnt work too...
url=jdbc:h2:tcp://localhost/~/mydb;AUTO_SERVER=TRUE
login=sa
password=
And I have declared datasource in my standalone.xml :
<datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://localhost/~/mydb</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
</security>
<datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
And I have the default module.xml for H2 in JBoss A7.
But when registering the JDBC using this :
Class.forName(driver);
I get this exception :
java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource
And the same for the other value :
java.lang.ClassNotFoundException: org.h2.Driver
Please can you help me get the solution?
Thank you a lot!
There is normally no need to register the driver, if your (web) application runs in an application server context. You just use the data source. The application server registers the driver for you, and that's why the driver's class is not necessarily visible to your application.
As for JBoss 7, the H2 driver is provided as a module. So if you really need to register it, you could declare a module dependency (in an .ear or in a .war deployment) by adding a jboss-deployment-structure.xml file.
References (regarding to module dependencies):
What's the module name if deploy jdbc in Jboss AS 7 as web application
Add an Explicit Module Dependency to a Deployment
I have the same problem and fixed when added this dependency in maven
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<scope>runtime</scope>
</dependency>
source

Categories