java:jsp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java:jsp [2014/12/24 09:42] – external edit 127.0.0.1 | java:jsp [2022/12/02 21:02] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Java Server Pages ====== | ====== Java Server Pages ====== | ||
- | ===== Error "La uri absoluta no puede resolverse" | + | ===== JNDI de Oracle + Tomcat |
- | Acabo de instalar Tomcat 6, y al realizar la primera prueba de páginas JSP me he encontrado | + | I don't know why, but the docummentation about **how to properly set a JNDI oracle entry in Tomcat** is not |
- | con este desagradable error: | + | correctly specified. Many documentns scattered here and there, but no one with a full working, modern example. |
- | < | + | In this page I will put the basic files and configuration needed to set a test page in Tomcat that loads a |
- | Estado HTTP 500 - | + | simple JNDI with the oracle driver (no connection pooling by now). |
- | type Informe de Excepción | + | Moreover, here is the whole project, with dependencies: |
- | mensaje | + | {{ : |
- | descripción El servidor encontró un error interno () que hizo que no pudiera rellenar este requerimiento. | + | ===== Create a web application under tomcat webapps directory ===== |
- | excepción | + | In this case, I've create a directory called " |
- | org.apache.jasper.JasperException: La uri absoluta: http://java.sun.com/ | + | {{:java:jndi-test-directories.png?400|}} |
- | org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) | + | |
- | org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409) | + | And now, put the following contents: |
- | org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116) | + | |
- | org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315) | + | ==== index.jsp ==== |
- | org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java: | + | |
- | org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java: | + | <code jsp> |
- | org.apache.jasper.compiler.Parser.parseDirective(Parser.java: | + | < |
- | org.apache.jasper.compiler.Parser.parseElements(Parser.java:1444) | + | <html lang=" |
- | org.apache.jasper.compiler.Parser.parse(Parser.java: | + | <%@ page language=" |
- | org.apache.jasper.compiler.ParserController.doParse(ParserController.java: | + | <%@ page import=" |
- | org.apache.jasper.compiler.ParserController.parse(ParserController.java: | + | javax.naming.InitialContext, |
- | org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:154) | + | javax.sql.DataSource, |
- | org.apache.jasper.compiler.Compiler.compile(Compiler.java: | + | java.sql.Connection, |
- | org.apache.jasper.compiler.Compiler.compile(Compiler.java: | + | java.sql.Statement, |
- | org.apache.jasper.compiler.Compiler.compile(Compiler.java: | + | java.sql.ResultSet, |
- | org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java: | + | oracle.jdbc.driver.OracleDriver" |
- | org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java: | + | |
- | org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java: | + | <h1>JNDI With Oracle test page</h1> |
- | org.apache.jasper.servlet.JspServlet.service(JspServlet.java: | + | |
- | javax.servlet.http.HttpServlet.service(HttpServlet.java: | + | < |
+ | <% | ||
+ | Context initCtx = new InitialContext(); | ||
+ | %> | ||
+ | |||
+ | < | ||
+ | <% | ||
+ | Context envCtx = (Context) initCtx.lookup("java:comp/ | ||
+ | %> | ||
+ | |||
+ | < | ||
+ | <% | ||
+ | DataSource jndi = (DataSource) envCtx.lookup(" | ||
+ | %> | ||
+ | |||
+ | < | ||
+ | <% | ||
+ | // Allocate and use a connection from the pool | ||
+ | Connection conn = jndi.getConnection(); | ||
+ | %> | ||
+ | |||
+ | < | ||
+ | <% | ||
+ | try( Statement cmd = conn.createStatement() ){ | ||
+ | ResultSet rs = cmd.executeQuery( " | ||
+ | rs.next(); | ||
+ | out.println( "< | ||
+ | out.println( "< | ||
+ | } | ||
+ | %> | ||
+ | |||
+ | <p>Y finalmente cerramos la conexion....</p> | ||
+ | <% | ||
+ | // and finally, close the connection to be a good citizen | ||
+ | conn.close(); | ||
+ | %> | ||
+ | </ | ||
- | nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/ | ||
</ | </ | ||
+ | ==== WEB-INF\web.xml ==== | ||
+ | |||
+ | <code xml> | ||
+ | <?xml version=" | ||
+ | <web-app xmlns: | ||
+ | xmlns=" | ||
+ | xsi: | ||
+ | id=" | ||
+ | version=" | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ==== META-INF\context.xml ==== | ||
+ | |||
+ | <code xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | |||
+ | < | ||
+ | auth=" | ||
+ | type=" | ||
+ | maxActive=" | ||
+ | maxIdle=" | ||
+ | maxWait=" | ||
+ | username=" | ||
+ | password=" | ||
+ | driverClassName=" | ||
+ | url=" | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
- | **¿Cómo resolverlo?? | ||
- | El problema es que no está instalado el soporte de las JSTL (Java Standard Template Library). Para instalar el soporte, he encontrado [[http:// | + | ==== WEB-INF/lib ==== |
- | ==== Descargar las librerías y ficheros JSTL ==== | + | Put the contents of the JDBC oracle driver of choice **but removing the files xmlparserv2.jar and xmlparserv2_sans_jaxp_services.jar because they collide with the tomcat libs**. I've used Oracle 11's. This have been tested in Tomcat 8 and JDK 1.8. |
- | En el sitio web de sun [[https:// | ||
- | He comprobado que en el fichero jstl-impl-1.2.jar están las librerías tld, por lo que entiendo que ya no hace falta instalarlos tal y como dice en otras fuentes. | ||
- | ==== Copiar los ficheros JAR de la JSTL al directorio " | ||
- | Qué tontería: primero habrá que identificar cual es ese directorio " | ||
- | Y con eso a mí me ha funcionado. | ||
java/jsp.1419414127.txt.gz · Last modified: 2022/12/02 21:02 (external edit)