2

我正在使用以下规范创建一个基于 Web 的应用程序:Glassfish 服务器 3.1.1 - SQL Server 2012 Express - Netbeans 7.01 - JDK 1.7 - Sql Server 4.0 的 JDBC 驱动程序

我已经创建了一个连接资源和连接池,并且可以从 glassfish 管理 Web 界面成功 ping 池。然后我在连接池的 xml 文件中创建了一个数据资源(数据源)。

为了测试数据资源,我在 WEB-INF 文件夹之外创建了一个测试 JSP,并使用在上一步中创建的数据源添加了一个 DB 报告。

运行测试 JSP 时收到以下错误:

TYPE:异常报告

信息:

描述:服务器遇到内部错误 (),导致它无法完成此请求。

异常:org.apache.jasperException:java.lang.unsupportedOperationException:不支持此操作。

根本原因:java.lang.UnsupportedOperationException:不支持此操作。

在过去的 2-3 天里,我一直在网上搜索解决方案,但我可以找到的所有示例都在异常描述中的“不支持此操作”之后提供了额外的详细信息/错误代码。

我检查了 glassfish,他们没有提供有关上述错误的其他详细信息。

希望有人遇到过同样的问题并且能够解决这个问题。

这是堆栈跟踪:

INFO: RAR7114: Unable to get ClientInfo for connection 
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.UnsupportedOperationException: This operation is not supported.
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.setClientInfo(SQLServerConnection.java:2890)
            at com.sun.gjc.spi.jdbc40.ConnectionHolder40.setClientInfo(ConnectionHolder40.java:322)
            at com.sun.gjc.spi.jdbc40.ConnectionHolder40.close(ConnectionHolder40.java:530)
            at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doFinally(QueryTagSupport.java:278)
            at org.apache.jsp.test.newjsp_jsp._jspx_meth_sql_query_0(newjsp_jsp.java:126)
            at org.apache.jsp.test.newjsp_jsp._jspService(newjsp_jsp.java:68)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            at java.lang.Thread.run(Thread.java:722)

任何帮助都将得到应用。如果有人有推荐,我会使用另一种连接方法。谢谢!

JSP test.jsp。我将从数据库中存在的视图创建类,因此 JSP 中的 sql 相对简单。该报告是为了确保 JSP 可以与 sql server 数据库进行通信的测试。

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%-- 
Document   : test
Created on : Jan 11, 2013, 8:06:27 PM
Author     : Developer
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    <sql:query var="result" dataSource="jdbc/TestAddOn">
        select * from tblCustomer
    </sql:query>

    <table border="1">
        <!-- column headers -->
        <tr>
        <c:forEach var="columnName" items="${result.columnNames}">
            <th><c:out value="${columnName}"/></th>
        </c:forEach>
    </tr>
    <!-- column data -->
    <c:forEach var="row" items="${result.rowsByIndex}">
        <tr>
        <c:forEach var="column" items="${row}">
            <td><c:out value="${column}"/></td>
        </c:forEach>
        </tr>
    </c:forEach>
</table>
    </body>
</html>

XML 参考

<resource-ref>
        <res-ref-name>jdbc/TestAddOn</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

glassfish 资源 xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
  <jdbc-resource enabled="true" jndi-name="jdbc/TestAddOn" object-type="user" pool-name="TestAddOnConnectionPool">
    <description/>
  </jdbc-resource>
  <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="TestAddOnConnectionPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.ConnectionPoolDataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
    <property name="URL" value="jdbc:sqlserver://Localhost:1433;databaseName= MyDatabaseName"/>
    <property name="User" value="*******"/>
    <property name="Password" value="*******"/>
 </jdbc-connection-pool>
</resources>
4

0 回答 0