2014-03-30 148 views
5

這是我第一次嘗試在我的Wildfly服務器中設置數據源。我試圖遵循我在Google上找到的一些教程,但仍然無效。使用DataSource配置蜻蜓

我正在使用Web服務,但在部署我的.war文件時,我不斷收到一些錯誤。

這裏是最近的記錄,當應用程序部署:

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> 

只要告訴我,如果你需要更多的文件。

回答

6

你可以發佈你的數據源定義嗎?

我認爲這將是最好的測試數據源部署'獨立'。我的意思是與實際應用程序部署分離,只是爲了測試您的數據源是否工作。 你可以測試這個f.i.使用Web控制檯(localhost:9990/console)。

它也看起來像野蠅的預配置示例DS有問題。你刪除了這個DS嗎?在standalone.xml中,還有一個關於ExampleDS的參考可能會被破壞。

+0

重新安裝Wild and,並再次遇到問題,但修復它們。我必須創建一個module.xml並將驅動程序.jar放在同一個文件夾中。這需要一些時間,但現在起作用。 – Ilhami

+0

有三種方式使用它,你可以簡單地創建數據源到wildfly 1.使用管理控制檯 2.手動添加到standalone.xml 3.創建數據源文件,該文件是xml文件 參考,此鏈接查看詳細信息:HTTP:/ /pvrworld-wildfly.blogspot.in/ – PVR

1

假設你使用的是MySQL數據庫,您可以通過以下方式創建DS:

(1)從這裏下載MySQL驅動程序: http://dev.mysql.com/downloads/connector/j/

(2)MySQL驅動程序複製到: WILDFLY_HOME /模塊/系統/層/基層/ COM/MySQL的/主

(3)從在JBoss(或Wildfly)控制檯,運行下面的命令:

/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql, driver-module-name=com.mysql, driver-class-name=com.mysql.jdbc.Driver) 

(4)然後,再次從JBoss(或Wildfly)控制檯運行命令:

/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) 

瞧。現在你有一個JNDI路徑的數據源: 的Java:JBoss的/數據源/ YourDS

1

服務的JBoss。 naming.context.java.jboss.datasourservice jboss.naming.context.java.jboss.datasources.ExampleDS(失蹤)的家屬:...

上wildfly-8.1.0.Final。

恕我直言

standalone/configuration/standalone-full.xml它有

<default-bindings ... datasource="java:jboss/datasources/ExampleDS" ...

<datasource jndi-name="java:/datasources/ExampleDS"...

JNDI名稱不匹配!

我用jndi-name =「java:jboss/datasources/ExampleDS」創建了ExampleDS2。這解決了我的問題。

13

進入你的wildfly控制檯(如localhost:9990)並編輯Configuration-> Container-> EE-> Default Bindings部分。將默認數據源設置爲某個有效數據源的JNDI名稱。

我刪除了那裏的默認值,並將它指向我的主數據源,因爲服務器僅用於運行一個應用程序。

+0

這也解決了我的問題。我認爲這肯定是一個錯誤?錯誤消息不具體描述。 – ThePerson

+0

這解決了它!謝謝 –

9

您可能在standalone.xml xmlns「urn:jboss:domain:datasources:2.0」部分缺少ds聲明「java:jboss/datasources/ExampleDS」,只是它會起作用(這裏是來自默認配置):

  <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> 

或者,你也可以通過添加UI由其他響應提及。