Fail loading driver (SQL Server, JBoss, Maven) - java

I'm trying to load JBoss Server with SQL Server configuration in standalone.xml and -ds.xml, and when I start the server it returns the following error:
15:21:38,092 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 27) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "sqlserver")
]) - failure description: "JBAS010441: Failed to load module for driver [com.microsoft.sqlserver]"
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.sqlserver (missing) dependents: [service jboss.data-source.java:jboss/datasources/pontualpro-DS]
My pom.xml configuration:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
My -ds.xml configuration:
<datasource jndi-name="java:jboss/datasources/pontualpro-DS" pool-name="pontualpro" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://127.0.0.1:667</connection-url>
<driver>sqlserver</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
My standalone.xml configuration:
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sqlserver" module="com.microsoft.sqlserver">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>
</driver>
</drivers>
The sqljdbc jar file is already in repository file
.m2>repository>com>microsoft>sqlserver>sqljdbc4>4.0>sqljdbc4-4.0.jar
If someone can help me I will be greatfull.

Make sure that jar file is in server directory, usually it's something like
jboss/server/production/lib or similar path.
Jboss will not use jar from your build. It MUST be in it's lib path

I'm not familiar with the jboss application server but my guess would be that an SQL driver must be provided by the appication server. I think the sqljdbc4-4.0.jar must be added to the "libs" of your application server.

The driver class you gave is not correct. You should give the full name
com.microsoft.sqlserver
see the reference as an example here: https://docs.jboss.org/jbossas/docs/Installation_And_Getting_Started_Guide/5/html/Using_other_Databases.html#Using_other_Databases-Using_MySQL_as_the_Default_DataSource

Related

Apache Ignite datasource in WildFly

I am trying to setup Apache Ignite Cluster with WildFly 10.1.0, so I'm able to use JPA with Ignite. I have issues configuring the JDBC driver.
What I have done so far:
standalone-full.xml
<datasource jta="false" jndi-name="java:jboss/datasources/IgniteDS" pool-name="IgniteDS" enabled="true">
<connection-url>jdbc:ignite:thin://172.X.X.146,172.X.X.147,172.X.X.148</connection-url>
<driver>ignite</driver>
</datasource>
Later in the same file I set-up the driver
<driver name="ignite" module="org.ignite.jdbc">
<driver-class>org.apache.ignite.IgniteJdbcThinDriver</driver-class>
</driver>
Ignite Module
In {WILDFLY_HOME}/modules I created following structure
module.xml
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="org.ignite.jdbc">
<resources>
<resource-root path="ignite-core-2.6.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Unfortunately I get following error in WildFly log when I start the server
11:43:31,253 ERROR [org.jboss.as.controller.management-operation]
(Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address:
([
("subsystem" => "datasources"),
("data-source" => "IgniteDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" =>
["jboss.jdbc-driver.ignite"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/IgniteDS is missing [jboss.jdbc-driver.ignite]",
"org.wildfly.data-source.IgniteDS is missing [jboss.jdbc-driver.ignite]"
]
}
11:43:31,263 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address:
([
("subsystem" => "datasources"),
("data-source" => "IgniteDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.ignite",
"jboss.jdbc-driver.ignite"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/IgniteDS is missing [jboss.jdbc-driver.ignite]",
"org.wildfly.data-source.IgniteDS is missing [jboss.jdbc-driver.ignite]",
"org.wildfly.data-source.IgniteDS is missing [jboss.jdbc-driver.ignite]"
]
}
Your help is highly appreciated
Beware you have 2 kinds or drivers, the regular one (driver-class), or the XA one (xa-datasource):
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="postgresql" module="org.postgresql">
<driver-class>org.postgresql.Driver</driver-class>
</driver>
I've sometimes seen conf where the driver class name is...repeated inside the datasource declaration (but do not ask me why ;-)):
<datasource jta="false" jndi-name="java:jboss/datasources/sqlDataSource" pool-name="sqlDataSource" enabled="true" use-ccm="false">
<connection-url>... </connection-url>
<driver-class>com.sybase.jdbc4.jdbc.SybDriver</driver-class>
<driver>sybase</driver>
Ultimately, give a try with jta="false" (on datasource level) in case it makes some differences (I doubt but)
May be not the root cause, but the namespace of your "module.xml" file is not correct (urn should be of version 1.3 for WF 10):
<module xmlns="urn:jboss:module:1.3" name="org.ignite.jdbc">
This may prevent the module from being loaded ?
The problem was in the folder structure I've used in {WILDFLY_HOME}/modules.
My path is org/ignite/main which means the name in module.xml should be changed from name="org.ignite.jdbc" to name="org.ignite"
Same change applies in driver tag in standalone-full.xml

Unable to instantiate driver SQLServerDriver in Wildfly 10

I am having the following error:
15:02:34,434 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "sqlserver")
]) - failure description: "WFLYJCA0034: Unable to instantiate driver class \"com.microsoft.jdbc.sqlserver.SQLServerDriver\". See log (WARN) for more details"
The module.xml in $JBOSS_HOME\modules\com\microsoft\sqlserver\main:
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver" slot="main">
<resources>
<resource-root path="sqljdbc42.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
This is the content of sqljdbc42.jar
And the driver definition in standalone.xml
<driver name="sqlserver" module="com.microsoft.sqlserver">
<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
</driver>
Please help me find out what I'm not seeing
UPDATE:
For historic context: the "com.microsoft.jdbc.sqlserver" package is
from the old SQL Server 2000 JDBC driver, they changed it somewhere
around 2005 to "com.microsoft.sqlserver.jdbc" by Mark Rotteveel
From what i can see from the jar content the class package in your driver is wrong, try with
<driver name="sqlserver" module="com.microsoft.sqlserver">
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>

Class Not Found Exception for com.mysql.jdbc.Driver in Wildfly 10

I'm using Wildfly 10 and my datasource in the standalone.xml is:
<datasources>
<datasource jta="true" jndi-name="java:/MySqlDS" pool-name="MySQL_AAA" enabled="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/aaa</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.35-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
I'm running this code in my Java bean:
Class.forName("com.mysql.jdbc.Driver");
and I get this error message:
10:29:59,210 ERROR [stderr] (default task-15) java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "deployment.AAA_5.war:main" from Service Module Loader]
10:29:59,210 ERROR [stderr] (default task-15) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
I read documentation that said I needed to have the driver in my lib folder but that didn't work. I'm sure the solution is simple but I don't see it. Can someone point me in the right direction. Some documentation that I can use as a resource would be great.
Drop mysql driver in the deployments folder in your wildfly , it will be deployed automatically , then it will become available.
EDIT:
installing mysql JDBC driver in wildfly as deployment will not give you access to mysql classes because of class-loaders behaviors, you can access the database connections through jndi datasources only, and you will not need to use Class.forName().
InitialContext context=new InitialContext();
DataSource d=(DataSource)context.lookup(yourDataSourceName);
However, if you still need to use mysql specific classes in your project , you have to drop the driver in your web-project/WEB-INF/lib folder.(but be careful about this since it will not be related to the deployed driver)

Wildfly configuration with DataSource

this is the first time I am trying to setup datasource in my Wildfly server. I tried to follow some tutorials which I found on Google but it still doesn't work.
I am working on a web service but I keep getting some errors when I deploy my .war file.
Here is the latest log when app is deployed:
22:16:33,049 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment IslamicPostsWS.war (runtime-name: IslamicPostsWS.war) in 7ms
22:16:33,184 INFO [org.jboss.as.server] (XNIO-1 task-2) JBAS018558: Undeployed "IslamicPostsWS.war" (runtime-name: "IslamicPostsWS.war")
22:16:33,186 INFO [org.jboss.as.controller] (XNIO-1 task-2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."IslamicPostsWS.war".POST_MODULE
22:16:35,518 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Stopped deployment IslamicPostsWS (runtime-name: IslamicPostsWS) in 7ms
22:16:35,660 INFO [org.jboss.as.server] (XNIO-1 task-6) JBAS018558: Undeployed "IslamicPostsWS" (runtime-name: "IslamicPostsWS")
22:16:38,358 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015018: Deployment IslamicPostsWS was previously deployed by this scanner but has been removed from the server deployment list by another management tool. Marker file C:\Users\Ilhami\workspace-services\.metadata\.plugins\org.jboss.ide.eclipse.as.core\WildFly_8.0_Runtime_Server1396040937545\deploy\IslamicPostsWS.undeployed is being added to record this fact.
22:17:00,406 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "IslamicPostsWS.war" (runtime-name: "IslamicPostsWS.war")
22:17:00,540 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "IslamicPostsWS.war")]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.ExampleDS]"],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.faces.webapp.FacetTag\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".deploymentCompleteService",
"jboss.deployment.unit.\"IslamicPostsWS.war\".jndiDependencyService",
"jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.env.jdbc.TestDB",
"jboss.undertow.deployment.default-server.default-host./IslamicPostsWS",
"jboss.undertow.deployment.default-server.default-host./IslamicPostsWS.UndertowDeploymentInfoService"
],
"Services that may be the cause:" => [
"jboss.jdbc-driver.com_mysql_jdbc_Driver",
"jboss.naming.context.java.jboss.datasources.ExampleDS"
]
}
}
22:17:00,683 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "IslamicPostsWS.war" (runtime-name : "IslamicPostsWS.war")
22:17:00,683 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.ExampleDS (missing) dependents: [service jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.DefaultDataSource]
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="JPADB">
<jta-data-source>java:jboss/datasources/DBTest</jta-data-source>
<properties>
<property name="showSql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>
Just tell me if you need more files.
Go into your wildfly console (something like localhost:9990) and edit the Configuration->Container->EE->Default Bindings section. Set the default datasource to the JNDI name of some valid datasource.
I removed the default one that was there and just pointed it to my main datasource since the server exists to run one app only.
You probably have the ds declaration "java:jboss/datasources/ExampleDS" missing in your standalone.xml xmlns "urn:jboss:domain:datasources:2.0" section, just and it will work (here's the example from the default configuration):
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Or you can also add through the UI as mentioned by other response.
can you post your datasource definition?
I think it would be the best to test the datasource deployment 'standalone'. I mean separated from an actual application deployment, just to test whether your datasource works or not.
You can test this f.i. using the web console (localhost:9990/console).
It also looks like there are problems with the pre-configured example DS of wildfly. Did you remove this DS? In standalone.xml there is also a reference on ExampleDS which might be broken.
Assuming you are using a MySQL DB, you can create a DS in the following way:
(1) Download the mysql driver from here:
http://dev.mysql.com/downloads/connector/j/
(2) Copy the mysql driver to:
WILDFLY_HOME/modules/system/layers/base/com/mysql/main
(3) From the JBoss (or Wildfly) console, run the command:
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql, driver-module-name=com.mysql, driver-class-name=com.mysql.jdbc.Driver)
(4) Then, again from the JBoss (or Wildfly) console, run command:
/subsystem=datasources/data-source=YourDS:add(driver-name=mysql, user-name=USERNAME, password=PASSWORD, connection-url=jdbc:mysql://localhost:3306/YOURDATABASE, min-pool-size=5, max-pool-size=15, jndi-name=java:jboss/datasources/YourDS, enabled=true, validate-on-match=true, 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)
Voila. Now you have a Datasource with a JNDI path of:
java:jboss/datasources/YourDS
Check if default-bindings configuration references to correct datasource: https://docs.jboss.org/author/display/WFLY8/Default+EE+Bindings+Configuration
I had
service jboss.naming.context.java.jboss.datasourservice jboss.naming.context.java.jboss.datasources.ExampleDS (missing) dependents:...
on wildfly-8.1.0.Final.
IMHO
in standalone/configuration/standalone-full.xml it had
<default-bindings ... datasource="java:jboss/datasources/ExampleDS" ...
and
<datasource jndi-name="java:/datasources/ExampleDS"...
jndi-name mismatch!
I created ExampleDS2 with jndi-name="java:jboss/datasources/ExampleDS". This solved my problem.

JBoss: can not connect to MySQL database

I am running JBoss as standalone version. I would like to connect to my local mysql database
I copied the mysql connector in modules folder
me#air~/Downloads/jboss/standalone/configuration - 10:56:18 $ ls ../../modules/org/mysql/main/
mysql-connector-java-5.1.22-bin.jar
Next I changed the standalone.xml in jboss/standalone/configuration as
<drivers>
<driver name="com.mysql" module="org.mysql" />
<driver name="h2" module="com.h2database.h2"> <!-- default provided-->
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Then I added the datasource as
<datasource jndi-name="java:/bb" pool-name="bb-pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>bb</user-name>
<password>bb</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
I am using JBoss AS 7.1.
When I start the server on console, I see errors
10:54:47,458 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:54:47,671 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/bb]
10:54:47,676 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
10:54:47,676 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2000ms - Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)
and when I hit Ctrl+C, I see
^C10:54:54,998 INFO [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011942: Stopping OSGi Framework
10:54:55,004 INFO [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
10:54:55,007 INFO [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
10:54:55,008 INFO [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager
10:54:55,010 INFO [org.apache.catalina.core.StandardContext] Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/] has not been started
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Pausing Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Stopping Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,043 INFO [org.jboss.as.controller] JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.jdbc-driver.mysql (new available)
10:54:55,044 INFO [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 47ms
I am new to JBoss and don't know how to fix this issue or to understand what is that I am doing wrong here
I think in your datasource you are referencing the driver mysql, but you named the driver com.mysql.
Try changing one the driver name to mysql.
Just a note: it is best to use the CLI to install the drivers and use the CLI or Web Console to build your datasources. The intention with AS7 is that these tools are used for all of your config and there are very few reasons why you should touch the XML yourself.
I had exactly the same mistake. Took me hours to find out how dumb it was.
In my case I was running jboss as a service under the jboss-as user, nice and easy. Except that when I created the mysql/main directory, along with the files within, I was under another user. No permissions there for jboss-as guy.
A simple chown on modules/ directory did the job.
First of all, your driver definition name doesn't match the driver name under the <datasource> definition. Replace <driver name="com.mysql" ... with <driver name="mysql" ... for it to work.
Second, have you added the module.xml file? It's not enough to copy the MySQL connector jar in the ./modules/com/mysql/main folder, you also have to add the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.26-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Also, I had a strage similar problem when using the MySQL connector version 5.0.8, where the driver was not found / recognized. It disappeared when I switched to the newer 5.1.26 version.
Make sure you are using latest version of mysql jdbc connector , i solve same issue of mine with replacing latest mysql connetor

Categories

Resources