Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 997
Ilhami Avatar asked Mar 30 '14 20:03

Ilhami


People also ask

What is datasource in Wildfly?

A Datasource is the component used by Enterprise applications to connect to the database. The datasource, in turn, uses a Driver to communicate with the underlying database. For this reason, for WildFly to provide database integration, it needs a Driver and a Datasource.

What is a XA datasource?

An XA datasource is used instead of the datasource if the target Jboss application: Uses the Java Transaction API (JTA) Includes multiple database updates within a single transaction. Accesses multiple resources, such as a database and the Java Messaging Service (JMS), during a transaction.


2 Answers

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.

like image 99
user3402489 Avatar answered Oct 12 '22 21:10

user3402489


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.

like image 41
Nabil M Avatar answered Oct 12 '22 21:10

Nabil M