MySQL + WildFly 10.0 - One or more services were unable to start - mysql

I'm trying to connect with database while deploying, but I got some trouble with that, here is a code and stacktrace:
02:19:32,740 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 45) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.mysql]"
02:19:32,814 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path 'C:\Users \Damian\wildfly-10.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
02:19:32,839 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
02:19:32,840 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
02:19:32,925 INFO [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
02:19:32,925 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
02:19:33,157 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "FiranyCRM.war" (runtime-name: "FiranyCRM.war")
02:19:33,171 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "mysql-connector-java-5.1.37.jar" (runtime-name: "mysql-connector-java-5.1.37.jar")
02:19:33,186 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\Damian\wildfly-10.0.0.Final\standalone\deployments
02:19:33,232 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-6) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
02:19:33,506 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
02:19:33,771 INFO [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4)
02:19:33,827 INFO [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for firanyDS
02:19:33,880 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
02:19:33,882 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
02:19:33,916 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.37.jar_com.mysql.jdbc.Driver_5_1
02:19:33,917 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.37.jar_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
02:19:34,213 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "FiranyCRM.war")]) - failure description: {
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"FiranyCRM.war#firanyDS\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jdbc.firanyDS]",
"jboss.persistenceunit.\"FiranyCRM.war#firanyDS\" is missing [jboss.naming.context.java.jdbc.firanyDS]"
],
"WFLYCTL0288: 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.\"FiranyCRM.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.faces.webapp.FacesServlet\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.faces.webapp.FacetTag\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"managed-bean.com.firanycrm.controller.CurtainBean\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".component.\"managed-bean.com.firanycrm.controller.LoginBean\".START",
"jboss.deployment.unit.\"FiranyCRM.war\".deploymentCompleteService",
"jboss.deployment.unit.\"FiranyCRM.war\".jndiDependencyService",
"jboss.naming.context.java.module.FiranyCRM.FiranyCRM.DefaultDataSource",
"jboss.undertow.deployment.default-server.default-host./FiranyCRM",
"jboss.undertow.deployment.default-server.default-host./FiranyCRM.UndertowDeploymentInfoService"
],
"Services that may be the cause:" => [
"jboss.jdbc-driver.mysql",
"jboss.naming.context.java.jdbc.firanyDS"
]
}
}
02:19:34,214 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "firanyDS")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.firanyDS is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/firanyDS is missing [jboss.jdbc-driver.mysql]"
]}
02:19:34,216 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "firanyDS")
]) - failure description: {
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.firanyDS is missing [jboss.jdbc- driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/firanyDS is missing [jboss.jdbc-driver.mysql]",
"org.wildfly.data-source.firanyDS is missing [jboss.jdbc- driver.mysql]"
],
"WFLYCTL0288: 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.data-source.reference-factory.firanyDS",
"jboss.naming.context.java.jboss.datasources.firanyDS"
],
"Services that may be the cause:" => [
"jboss.jdbc-driver.mysql",
"jboss.naming.context.java.jdbc.firanyDS"
]
}
}
standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/firanyDS" pool-name="firanyDS">
<connection-url>jdbc:mysql://127.0.0.1:3307/firanycrm</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="org.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
module.xml (in modules folder, modules/org/mysql) :
<module xmlns="urn:jboss:module:1.0" name="org.mysql.driver">
<resources>
<resource-root path="mysql-connector-java-5.1.37.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.0">
<persistence-unit name="firanyDS" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/jdbc/firanyDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
</persistence>
In which place I made a mistake?

You have at least two problems:
In the standalone.xml, under the datasources subsystem, you set the driver module to "org.mysql" but the module name in the module.xml is "org.mysql.driver".
The jta-data-source element in persistence.xml should be the jndi name of your datasource: java:jboss/datasources/firanyDS. Besides, since you are using JTA, the transaction-type must be "JTA".
<persistence ...>
<persistence-unit name="firanyDS" transaction-type="JTA">
<jta-data-source>java:/jdbc/firanyDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
</persistence>

Related

EJB/Hibernate does not access MySQL Database

I'm trying to learn how to work with JavaEE/EJB and database persistence, I have a basic example where I want to save a String to a database via input field and read the list of saved items.
I have a MySQL server installed on localhost (V5.7 Community Edition) and my test server is WildFly 10.1.0 (via Eclipse). The whole project is an EAR container containing a Web and EJB Subproject.
I am using container managed transactions, as I understand it, transactions are automatically created when a method is called and flushed/committed as soon as the method exits.
The problem is, that no data is ever written to the actual database. But no errors are thrown either. I assume, the entity manager caches all supposed saves and directly reads them back on select, without even checking the database. As such, when I restart the server, nothing remains. Also, when I look into mysql db directly, nothing is there either (even while wildfly server is running, directly after supposed insert). I also tried adding some rows to db table directly, but select does not "see" them either.
As a result, it seemed to me that the database is not even accessed, despite it being configured in the persistence.xml. I tried to remove connection url/username/password there and it actually made no difference, the entity manager still throws no errors and everything seems to work. So where exactly is it saving the data and what do I have to change so that it accesses the supplied mysql database instead?
Handler (in Web Project):
#ManagedBean(name = "handlerBean")
#SessionScoped
public class HandlerBean {
#EJB
private TodoWorkerBeanRemote worker;
private String input;
public void add() {
if (input.compareTo("") != 0) {
TodoBean item = new TodoBean();
item.setText(input);
worker.saveItem(item);
input = "";
}
}
...
Session Bean / Transaction container (in EJB project)
#Stateless
#TransactionManagement(TransactionManagementType.CONTAINER)
public class TodoWorkerBean implements TodoWorkerBeanRemote {
#PersistenceContext(unitName = "EnterpriseTestEJB")
private EntityManager entityManager;
public TodoWorkerBean() {
}
#Override
#TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) // does not help
public void saveItem(TodoBean item) {
// entityManager.joinTransaction(); <- does not help
entityManager.persist(item); // tried .merge() as well
// entityManager.flush(); <-does not help
}
...
Entity Bean (in EJB project)
#Entity
#Table(name = "todobean")
#NamedNativeQueries({
#NamedNativeQuery(name = "TodoBean.getItems", query = "select * from todobean", resultClass = TodoBean.class),
#NamedNativeQuery(name = "TodoBean.clearItems", query = "delete from todobean") })
public class TodoBean implements Serializable {
private Integer id;
private String text;
...
persistence.xml (tried with hibernate.cfg.xml as well, no difference)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="EnterpriseTestEJB">
<class>de.dianasalsa.ejb.TodoBean</class>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/feedback" /> // not used
<property name="hibernate.connection.username" value="root" /> // not used
<property name="hibernate.connection.password" value="root" /> // not used
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="update" /> // tried "create" as well
</properties>
</persistence-unit>
</persistence>
Log:
....
15:42:59,602 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 66) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'EnterpriseTest.ear/EnterpriseTestEJB.jar#EnterpriseTestEJB'
15:42:59,952 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 65) WFLYCLINF0002: Started client-mappings cache from ejb container
15:42:59,973 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 66) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
15:43:00,102 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 66) Envers integration enabled? : true
15:43:00,101 INFO [org.jboss.as.protocol] (management I/O-1) WFLYPRT0057: cancelled task by interrupting thread Thread[management-handler-thread - 3,5,management-handler-thread]
15:43:00,604 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 66) HHH000228: Running hbm2ddl schema update
15:43:00,617 INFO [org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl] (ServerService Thread Pool -- 66) HHH000262: Table not found: todobean
15:43:00,619 INFO [org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl] (ServerService Thread Pool -- 66) HHH000262: Table not found: todobean
15:43:01,499 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 83) Mojarra 2.2.13.SP1 20160303-1204 für Kontext '/EnterpriseTestWeb' wird initialisiert.
15:43:02,379 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 83) WFLYUT0021: Registered web context: /EnterpriseTestWeb
15:43:02,414 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "EnterpriseTest.ear" (runtime-name : "EnterpriseTest.ear")
15:43:02,515 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:43:02,519 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:43:02,519 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 9581ms - Started 879 of 1127 services (422 services are lazy, passive or on-demand)
15:43:18,799 INFO [org.jboss.ejb.client] (default task-2) JBoss EJB Client version 2.1.4.Final
15:43:32,763 INFO [stdout] (default task-3) Hibernate:
15:43:32,763 INFO [stdout] (default task-3) /* insert de.dianasalsa.ejb.TodoBean
15:43:32,763 INFO [stdout] (default task-3) */ insert
15:43:32,763 INFO [stdout] (default task-3) into
15:43:32,763 INFO [stdout] (default task-3) todobean
15:43:32,763 INFO [stdout] (default task-3) (text)
15:43:32,763 INFO [stdout] (default task-3) values
15:43:32,764 INFO [stdout] (default task-3) (?)
15:43:32,786 INFO [stdout] (default task-3) Hibernate:
15:43:32,786 INFO [stdout] (default task-3) /* TodoBean.getItems */ select
15:43:32,786 INFO [stdout] (default task-3) *
15:43:32,787 INFO [stdout] (default task-3) from
15:43:32,787 INFO [stdout] (default task-3) todobean
sorry for my english...
you need to configure a JNDI name "jta-data-source", and say with "hibernate.hbm2ddl.auto" create new relations, like this example:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="EnterpriseTestEJB"
transaction-type="JTA">
<jta-data-source>java:jboss/datasources/some-name</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
wildfly has a "namesever" for that you work with the JNDI name to access from your annotation like "#PersistenceContext".
And in Wildfly at selfe you must configure a new MySql connection with that JNDI name.
For MySql connection download the jdbc driver and upload it to WildFly.
https://dev.mysql.com/downloads/connector/j/5.1.html
Inser MySqgl jdbc Driver
The connection will named with the JNDI name (java:jboss/datasources/some-name).
Add new MySql Connection (1)
Add new MySql Connection (2)
When you run your programm in Wildfly the programm will look over the JNDI name in wildfly for your MySql connection.
If you would like to look an example code i have one from my study here:
https://gitlab.com/Java_Project/JavaEE2.0
I'll hope it fixe your problem.

error servlet deployment with Wildfly

During deployment I'm getting the following errors. I use wildfly 8.x.
When it loads the server i get 404 error page.
04:39:07,010 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-11) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_73]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_73]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_73]
Caused by: java.lang.IllegalArgumentException: JBAS017354: Could not find the port number listening for protocol javax.ws.rs.core.Application
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:648)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.start(UndertowDeploymentInfoService.java:256)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more
+
04:39:14,333 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "projectTeam2v2.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService: Failed to start service
Caused by: java.lang.IllegalArgumentException: JBAS017354: Could not find the port number listening for protocol javax.ws.rs.core.Application"}}
+
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService: Failed to start service
+
JBAS014775: New missing/unsatisfied dependencies:
service jboss.deployment.unit."projectTeam2v2.war".component."com.ibm.controller.CDController".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./projectTeam2v2, service jboss.deployment.unit."projectTeam2v2.war".deploymentCompleteService]
service jboss.deployment.unit."projectTeam2v2.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./projectTeam2v2, service jboss.deployment.unit."projectTeam2v2.war".deploymentCompleteService]
service jboss.deployment.unit."projectTeam2v2.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./projectTeam2v2, service jboss.deployment.unit."projectTeam2v2.war".deploymentCompleteService]
service jboss.deployment.unit."projectTeam2v2.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.unit."projectTeam2v2.war".deploymentCompleteService]
service jboss.undertow.deployment.default-server.default-host./projectTeam2v2 (missing) dependents: [service jboss.deployment.unit."projectTeam2v2.war".deploymentCompleteService]
service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./projectTeam2v2]
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService
+
JBAS014776: Newly corrected services:
service jboss.deployment.unit."projectTeam2v2.war".component."com.ibm.controller.CDController".START (no longer required)
service jboss.deployment.unit."projectTeam2v2.war".component."com.sun.faces.config.ConfigureListener".START (no longer required)
service jboss.deployment.unit."projectTeam2v2.war".component."javax.faces.webapp.FacetTag".START (no longer required)
service jboss.deployment.unit."projectTeam2v2.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (no longer required)
service jboss.undertow.deployment.default-server.default-host./projectTeam2v2 (no longer required)
service jboss.undertow.deployment.default-server.default-host./projectTeam2v2.UndertowDeploymentInfoService (no longer required)
+
04:46:20,148 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) Exception in thread "xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0" java.nio.file.ClosedWatchServiceException
04:46:20,149 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) at sun.nio.fs.AbstractWatchService.checkOpen(AbstractWatchService.java:80)
04:46:20,149 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) at sun.nio.fs.AbstractWatchService.checkKey(AbstractWatchService.java:92)
04:46:20,149 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:119)
04:46:20,149 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) at org.xnio.nio.WatchServiceFileSystemWatcher.run(WatchServiceFileSystemWatcher.java:85)
04:46:20,150 ERROR [stderr] (xnio-file-watcher[Watcher for C:\Users\IMC\wildfly-8.2.1.Final\standalone\deployments\SpringMVC.war/]-0) at java.lang.Thread.run(Thread.java:745)
In the web.xml i don't have mysql dependency. Could this be the problem?
Thank you for your time :).
i removed web.xml and it works now. can any1 explain me why?
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Integration CRUD JSP Project</display-name>
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>lang</param-value>
</context-param>
<servlet>
<servlet-name>CDController</servlet-name>
<servlet-class>com.ibm.controller.CDController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CDController</servlet-name>
<url-pattern>/CDController</url-pattern>
</servlet-mapping>
</web-app>
this is the web.xml

Can't resolve Services with missing/Available dependencies Wildfly 8.1 and MySQL 5.7 JBAS014613: Operation ("add") failed

I'm trying to configure a data source in Wildfly 8.1 with MySQL. I'm on a local environment on windows and I keep getting errors when I start the server. The datasource is registered, but fails when i test it.
I have the mysql connector jar file in C:\wildfly\modules\system\layers\base\com\mysql\main
standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/bookdb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>*******</password>
</security>
<timeout>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>600</query-timeout>
</timeout>
</datasource>
<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>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
module.xml C:\wildfly\modules\system\layers\base\com\mysql\main
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.38-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
00:46:17,927 ERROR [org.jboss.as.controller.management-operation](ServerService Thread Pool -- 27) JBAS014613: Operation ("add") failed - address: ([("subsystem" => "datasources"), ("jdbc-driver" => "mysql") ]) - failure description: "JBAS010441: Failed to load module for driver [com.mysql]"
00:46:17,912 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = h2
00:46:18,171 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017525: Started server default-server.
00:46:18,165 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path C:\wildfly/welcome-content
00:46:18,498 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017531: Host default-host starting
00:46:18,558 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.3.Final
00:46:18,694 INFO org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory C:\wildfly\standalone\deployments
00:46:18,701 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on /127.0.0.1:8080
00:46:18,863 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
00:46:19,112 INFO [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
00:46:19,122 ERROR [org.jboss.as.controller.management-operation (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([("subsystem" => "datasources"), ("data-source" => "MySQLDS") ]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.java:jboss/datasources/MySQLDS is missing [jboss.jdbc-driver.mysql]","jboss.driver-demander.java:jboss/datasources/MySQLDS is missing [jboss.jdbc-driver.mysql]" ]}
00:46:19,155 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([("subsystem" => "datasources"),("data-source" => "MySQLDS") ]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.java:jboss/datasources/MySQLDS is missing [jboss.jdbc-driver.mysql]","jboss.driver-demander.java:jboss/datasources/MySQLDS is missing [jboss.jdbc-driver.mysql]"],"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.data-source.reference-factory.MySQLDS", "jboss.naming.context.java.jboss.datasources.MySQLDS"], "Services that may be the cause:" => ["jboss.jdbc-driver.mysql"] } }
00:46:19,254 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.driver-demander.java:jboss/datasources/MySQLDS, service jboss.data-source.java:jboss/datasources/MySQLDS]
00:46:19,616 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
00:46:19,628 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
00:46:19,643 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.1.0.Final "Kenny" started (with errors) in 4876ms - Started 185 of 238 services (4 services failed or missing dependencies, 81 services are lazy, passive or on-demand)
00:51:40,780 ERROR [org.jboss.as.controller.management-operation](management-handler-thread - 4) JBAS014613: Operation ("add") failed - address: ([ ("subsystem" => "datasources"), ("jdbc-driver" => "mysql-5-driver") ]) - failure description: "JBAS010441: Failed to load module for driver [mysql]"
00:51:47,961 ERROR [org.jboss.as.controller.management-operation](management-handler-thread - 6) JBAS014613: Operation ("add") failed - address: ([("subsystem" => "datasources"), ("jdbc-driver" => "mysql-5-driver") ]) - failure description: "JBAS010441: Failed to load module for driver [mysql]"
00:53:21,929 ERROR [org.jboss.as.controller.management-operation](management-handler-thread - 8) JBAS014613: Operation ("add") failed - address: ([("subsystem" => "datasources"), ("jdbc-driver" => "mysql-5-driver") ]) - failure description: "JBAS010441: Failed to load module for driver [com.mysql]"
01:01:49,324 ERROR [org.jboss.as.controller.management-operation](XNIO-1 task-7) JBAS014613: Operation ("test-connection-in-pool") failed - address: ([("subsystem" => "datasources"), ("data-source" => "MySQLDS") ]) - failure description: "JBAS010440: failed to invoke operation: JBAS010442: failed to match pool. Check JndiName: java:jboss/datasources/MySQLDS"
Thanks!
Uploading the MySQL connector .jar file via the browser console as a deployment fixed the issue.
My data source is working in WildFly 10x, so I don't know if there was an issue with version 8.1.
Here's a decent video on 3 ways to add a data source to Wildfly: https://www.youtube.com/watch?v=xSHXMcRsF0A

How to fix Module Not Found Exception in WildFly 9.0.1

I am getting this exception while trying to start my app on the WildFly 9.0.1 Final release. My WAR file consists only of an application that builds on Spring Framework. My server log file is below.
12:53:57,109 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service
jboss.module.service."deployment.SpringExample.war".main:org.jboss.msc.service.StartException in service
jboss.module.service."deployment.SpringExample.war".main: WFLYSRV0179:
Failed to load module: deployment.SpringExample.war:main at
org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91) at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) 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.modules.ModuleNotFoundException: com.mysql:main at
org.jboss.modules.Module.addPaths(Module.java:1042) at
org.jboss.modules.Module.link(Module.java:1398) at
org.jboss.modules.Module.relinkIfNecessary(Module.java:1426) at
org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:238) at
org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadServic
e.java:68) ... 5 more 12:53:57,115 ERROR
[org.jboss.as.controller.management-operation] (DeploymentScanner-threads
- 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment"
=> "SpringExample.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.SpringExample.war\".main" => "org.jboss.msc.service.StartException in service
jboss.module.service.\"deployment.SpringExample.war\".main: WFLYSRV0179:
Failed to load module: deployment.SpringExample.war:main Caused by: org.jboss.modules.ModuleNotFoundException: com.mysql:main"}} 12:53:57,199
INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "SpringExample.war" (runtime-name : "SpringExample.war") 12:53:57,200 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) WFLYCTL0183: Service status report
WFLYCTL0185: Newly corrected services: service jboss.module.service."deployment.SpringExample.war".main (new available) WFLYCTL0186: Services which failed to start: service
jboss.module.service."deployment.SpringExample.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.SpringExample.war".main: WFLYSRV0179:
Failed to load module: deployment.SpringExample.war:main 12:54:57,515 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment SpringExample.war (runtime-name: SpringExample.war) in 51ms 12:54:57,516 INFO
[org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "SpringExample.war" (runtime-name: "SpringExample.war") 12:54:58,966 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service
jboss.module.service."deployment.SpringExample.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.SpringExample.war".main: WFLYSRV0179: Failed to load module: deployment.SpringExample.war:main at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91) at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) 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.modules.ModuleNotFoundException: com.mysql:main at org.jboss.modules.Module.addPaths(Module.java:1042) at org.jboss.modules.Module.link(Module.java:1398) at org.jboss.modules.Module.relinkIfNecessary(Module.java:1426) at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:238) at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:68) ... 5 more 12:54:58,969 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.SpringExample.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.SpringExample.war\".main: WFLYSRV0179: Failed to load module: deployment.SpringExample.war:main Caused by: org.jboss.modules.ModuleNotFoundException: com.mysql:main"}} 12:54:59,002
INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "SpringExample.war" with deployment "SpringExample.war" 12:54:59,002 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report WFLYCTL0184: New missing/unsatisfied dependencies: service
jboss.module.service."deployment.SpringExample.war".main (unavailable) dependents: [service jboss.deployment.unit."SpringExample.war".FIRST_MODULE_USE] WFLYCTL0186: Services which failed to start: service
jboss.module.service."deployment.SpringExample.war".main service
jboss.module.service."deployment.SpringExample.war".main: org.jboss.msc.service.StartException in service
jboss.module.service."deployment.SpringExample.war".main: WFLYSRV0179: Failed to load module: deployment.SpringExample.war:main
Firstly, you have to look module concept of WildFly on documentation. Moreover, defining mySQL module link could be helpful.

Adding MySql to JBoss 8.1 (Wildfly)

So I have followed this tutorial: https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/
I have done everything as described in the tutorial; yet I keep getting this error on start up:
14:42:19,442 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "ExpensesDataSourcePool")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]"
]}
14:42:19,450 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "ExpensesDataSourcePool")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]"
],
"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.data-source.reference-factory.ExpensesDataSourcePool",
"jboss.naming.context.java.ExpensesDataSource"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
}
}
14:42:19,489 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "mysql-connector-java-5.1.34.jar" (runtime-name : "mysql-connector-java-5.1.34.jar")
14:42:19,491 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:/ExpensesDataSource, service jboss.driver-demander.java:/ExpensesDataSource]
This is the structure of my modules dir in the Jboss folder: modules/com/mysql/main with two files module.xml and mysql-connector-java-5.1.34.jar
This is my module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.34.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
I have also added the mysql jar in standalone/deployments
This is the configuration of my datasource and driver in my standalone.xml under standalone/configuration
<datasource jndi-name="java:/ExpensesDataSource" pool-name="ExpensesDataSourcePool" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/expenses</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
<driver name="mysql" module="com.mysql"/>
I found my error, I had to put my module.xml and jar under system modules instead of creating a new com folder