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
Related
23:26:11,838 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "ejb3"),
("service" => "remote")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.ejb3.connector is missing
[jboss.remoting.remotingConnectorInfoService.http-remoting-connector]"]}
23:26:11,883 INFO [org.jboss.as.controller] (Controller Boot Thread)
WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql-connector-java-5_1_6_jar (missing)
dependents: [service jboss.data-source.java:/IncidentManagerDS, service
jboss.driver-demander.java:/IncidentManagerDS]
service jboss.remoting.remotingConnectorInfoService.http-remoting-
connector (missing) dependents: [service jboss.ejb3.connector]
WFLYCTL0186: Services which failed to start: service
jboss.undertow.listener.default: org.jboss.msc.service.StartException in service
jboss.undertow.listener.default: Could not start http listener
23:26:11,974 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http
management interface listening on http://0.0.0.0:9990/management
23:26:11,974 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin
console listening on http://0.0.0.0:9990
23:26:11,975 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly
Full 9.0.2.Final (WildFly Core 1.0.2.Final) started (with errors) in 2555ms -
Started 193 of 382 services (10 services failed or missing dependencies, 210
services are lazy, passive or on-demand)
It looks like you pasted a configuration snippet to your WILDFLY_HOME/standalone/configuration/standalone.xml and forgot to put the driver into classpath.
You can try one of these two options:
Your can put the JAR with MySQL driver (e.g. mysql-connector-java-5.1.37.jar) to WILDFLY_HOME/standalone/deployments like you would deploy WAR.
You can create a module in WILDFLY_HOME/modules with driver in it, for details see https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
Then you can refer to the driver in your datasources configuration or persistence.xml
Excerpt from standalone.xml, referring to driver deployed into deployments dir.
<datasource ...>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.37.jar_com.mysql.jdbc.Driver_5_1</driver>
...
</datasource>
Excerpt from standalone.xml, referring to driver as a module.
<datasources>
<datasource ...>
<driver>mysqljdbc</driver>
...
</datasource>
<drivers>
<driver name="mysqljdbc" module="com.mysql.jdbc">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
Anyway, this problem is not related to Eclipse Mars IDE, the server won't start even when run from command line.
I did a change in the deployment scanner of my Jboss 6.4 with the idea to change the path :
standalone.xml
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
<deployment-scanner name="MYWAR" path="usr\MYWAR\deployments" relative-to="jboss.server.base.dir" scan-enabled="true" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false" deployment-timeout="60"/>
</subsystem>
I can deploy without problems and it works, but the problem appears when I try to execute my rest services: I got a error 404. I cannot find any indication as to the source of the problem in the server log.
The same war in another jboss 6.4 with the default deployment path works perfectly.
Log:
13:42:41,228 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: mywar.war in Deployment-Verzeichnis gefunden. Um Deployment zustarten, erstellen Sie eine Datei namens mywar.war.dodeploy
13:42:44,721 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starte Deployment von "DocumenzCarlos" (runtime-name: "mywar")
13:42:44,783 INFO [org.jboss.as.server] (HttpManagementService-threads - 18) JBAS015859: "mywar" deployed (runtime-name: "mywar")
standalone.xml
<deployments>
<deployment name="mywar" runtime-name="mywar.war">
<fs-archive path="usr\mywar\deployments" relative-to="jboss.server.base.dir"/>
</deployment>
</deployments>
Any Idea where is the conflict?
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
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.
I'm deploying a really simple helloworld style EJB application. When doing so I get...
WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
13:15:54,638 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
13:15:55,094 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
13:15:55,175 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
13:15:56,587 INFO [org.xnio] XNIO Version 3.0.3.GA
13:15:56,592 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
13:15:56,602 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
13:15:56,614 INFO [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
13:15:56,655 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
13:15:56,661 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
13:15:56,707 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
13:15:56,793 INFO [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
13:15:56,822 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
13:15:56,839 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
13:15:56,881 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
13:15:56,889 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
13:15:56,898 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
13:15:56,933 INFO [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.6.final
13:15:56,989 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
13:15:57,324 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.1.GA
13:15:57,501 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
13:15:58,264 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /usr/bin/jboss-as-7.1.0.Final/standalone/deployments
13:15:58,265 INFO [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:4447
13:15:58,265 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999
13:15:58,272 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found HelloWorld.war in deployment directory. To trigger deployment create a file called HelloWorld.war.dodeploy
13:15:58,581 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.com_mysql (missing) dependents: [service jboss.data-source.java:jboss/datasources/EjbMySql]
13:15:58,589 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.0.Final "Thunder" started (with errors) in 4548ms - Started 131 of 204 services (2 services failed or missing dependencies, 70 services are passive or on-demand)
It looks like I need to add an include somewhere, my code is very simple...
package server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.MyUser;
/**
* Servlet implementation class HelloServlet
*/
#WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
#EJB HelloBean bean;
#PersistenceUnit
EntityManagerFactory emF;
/**
* #see HttpServlet#HttpServlet()
*/
public HelloServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.print("<html><body>");
MyUser user = (MyUser)emF.createEntityManager().createQuery("select * from myuser").getResultList().get(0);
out.println("Username = " + user.getName());
out.print("</body></html>");
}
/**
* #see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
Persistance.xml is shown below...
<?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="HelloWorld">
<jta-data-source>EjbMySql</jta-data-source>
<class>model.MyUser</class>
</persistence-unit>
</persistence>
modules/com/mysql/main/Modules.xml is as follows...
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the #author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Standalone.xml has the following entry...
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/EjbMySql" pool-name="EjbMySql" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/ejbdb</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql.jdbc"> <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class> </driver>
</drivers>
</datasources>
</subsystem>
In my project, I have the MySQL jar in /WebContent/META-INF/services/mysql-connector-java-5.1.18-bin.jar
Does anyone have any ideas?
Thanks!
EDIT: Tried...
<datasource jndi-name="java:jboss/datasources/EjbMySql" pool-name="EjbMySql" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/ejbdb</connection-url>
<driver>com.mysql.jdbc.Driver</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
comes back with the same error.
In <JBOSS_HOME>/standalone/configuration/standalone.xml find the <subsystem xmlns="urn:jboss:domain:datasources:1.0"> tag and add the following inside the <datasources> element:
<datasources>
<datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="MysqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/DATABASE_NAME</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>USERNAME</user-name>
<password>PASSWORD</password>
</security>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
Replace DATABASE_NAME,USERNAME and PASSWORD apporpriately.
Inside the <drivers> element add the following:
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
Now, go to <JBOSS_HOME>/modules and create the path com/mysql/mainput the driver's jar there (eg. mysql-connector-java-5.1.18-bin.jar) and create the file module.xml with the following contents:
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
That should do the trick.
I think you need to associate the datasource in standalone.xml with the driver-module like in the example below (taken from here:
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" pool-name="H2DS">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<pool></pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation></validation>
<timeout></timeout>
<statement></statement>
</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.jdbc"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver>
</drivers>
</datasources>
The driver-element in datasources herein references a driver definition in the drivers-element, which in itself references the module that you defined and the classes. That is how I use it, and it works for me on JBoss 7.1.
In JBoss 7, several configuration details changed for creating a data source and installing a JDBC driver. Take a look at this migration guide, in the sections "Define the datasource" and "Install the JDBC driver".
Is the version of driver. Change for a new version. Believe, is only it!!!
I changed the driver mysql-connector-java-5.0.4-bin.jar to mysql-connector-java-5.1.25-bin.jar, then the problem is solved.