2013-07-02 4 views
0

J'utilise Netbeanse 7.3.1 + Glassfish 4. J'ai écrit application web simple à l'aide JSTLGlassFish 4 & MySQL & JSTL

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> 

     <sql:query var="txt" dataSource="jdbc/mrm_db"> 
      SELECT * FROM T2 
     </sql:query> 

<%@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> 
     <table> 
     <c:forEach var="row" items="${txt.rows}"> 
      <tr><td><c:out value="${row.txt}"/></td></tr> 
     </c:forEach> 
     </table> 
    </body> 
</html> 

Aussi j'ai ajouté Galssfish JDBC ressources et pool de connexion configurée et JDBC. Ajout de références de ressources web.xml et config.

Et quand j'essaie commencer mon applicatio une erreur get

Type Exception report 

messageInternal Server Error 

descriptionThe server encountered an internal error that prevented it from fulfilling this request. 

exception 

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused." 

root cause 

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused." 

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs. 

Il est ressemble que Glassfish utilisation try jdbc/__ par défaut, mais pas mon point d'émission.

Si je crée ce projet dans Netbeans 7.2 et Glassfish 3.2, cela fonctionne très bien.

Pouvez-vous m'aider, qu'est-ce que je fais mal?

Merci!

Répondre

2

Incluez la définition de ressource suivante dans votre fichier web.xml et cela devrait fonctionner correctement.

<resource-ref> 
    <res-ref-name>jdbc/SOMETHING</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    <mapped-name>jdbc/SOMETHING</mapped-name> 
</resource-ref>