0

JBoss 6 AS を介して MySQL データベースからデータを取得する JSP ページを使用して、Eclipse を使用して単純なプロジェクトを作成しています。エラーなしで起動し、次のメッセージが表示されるため、MySQL データベースが JBoss に適切にバインドされているように見えます。

17:09:43,782 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/MyDatabase]

ただし、index.jsp ページを起動しようとすると、次のエラーが発生します。

exception 


javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get 
connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for 
jdbc/MyDatabase"


org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)


root cause 

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid:   "java.sql.SQLException: No suitable driver found for jdbc/MyDatabase"
  org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:318)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:201)
org.apache.jsp.index_jsp._jspx_meth_sql_005fquery_005f0(index_jsp.java:133)
org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

JSPページがDBから読み取れるようにするために、この全体の最後のステップが機能しない理由を理解できないようです。

参照用ファイル:

JBoss Standalone.xml

    <subsystem xmlns="urn:jboss:domain:datasources:1.1">
        <datasources>
            <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</connection-url>
                <driver>h2</driver>
                <security>
                    <user-name>sa</user-name>
                    <password>sa</password>
                </security>
            </datasource>
            <datasource jta="true" jndi-name="java:jboss/datasources/MyDatabase" pool-name="MyDatabase" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost:3306/MyDatabase</connection-url>
                <driver>mysql</driver>
                <security>
                    <user-name>root</user-name>
                    <password>root</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>

JBOSS_HOME/modules/com/mysql/main にある Module.xml ファイル

<?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.25-bin.jar"/>
</resources>
<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>

JBOSS_HOME/modules/com/mysql/main の中に mysql-connector-java-5.1.25-bin.jar があります

Web.xml の内容

 <display-name>TicketApp</display-name>

 <welcome-file-list>
   <welcome-file>index.jsp</welcome-file>
   <welcome-file>response.jsp</welcome-file>
 </welcome-file-list>

Jboss-Web.xml の内容

 Blank for now

また、resource-ref タグを web.xml ファイルと jboss-web.xml ファイルの両方に追加すると、すべてが失敗し、JBoss から次のエラーが発生するようです。

17:18:29,519 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1)       JBAS015876: Starting deployment of "MyApp.war"
17:18:29,994 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-11) MSC000001:        Failed to start service jboss.deployment.unit."MyApp.war".POST_MODULE: org.jboss.msc.service.StartException in service     jboss.deployment.unit."MyApp.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "MyApp.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)      [rt.jar:1.7.0_21]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
at      org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.getResourceRefEntries(ResourceReferenceProcessor.java:159)
at    org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.processDescriptorEntries(ResourceReferenceProcessor.java:73)
at org.jboss.as.ee.component.deployers.AbstractDeploymentDescriptorBindingsProcessor.deploy(AbstractDeploymentDescriptorBindingsProcessor.java:100)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
... 5 more
   Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module "deployment.TicketApp.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.3.GA-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA-redhat-1]
at org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.getResourceRefEntries(ResourceReferenceProcessor.java:157)
... 8 more

   17:18:30,009 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "MyApp.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MyApp.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MyApp.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"MyApp.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module \"deployment.MyApp.war:main\" from Service Module Loader]"}}
 17:18:30,014 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment MyApp.war in 7ms
 17:18:30,019 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MyApp.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MyApp.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"MyApp.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module \"deployment.MyApp.war:main\" from Service Module Loader]"}}}}
4

1 に答える 1