This discussion is archived
12 Replies Latest reply: Oct 15, 2011 2:47 AM by Udo RSS

eclipse jboss jsp oracle xe connect error

892848 Newbie
Currently Being Moderated
hi
i am using eclipse ganymede 342 and my second configuration is:
jboss as 420 ga
oracle 10g xe
windows xp
jdk15

when i run my jsp file that contains instructions to connect to oracle 10g xe and query my database i got this error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 9

6: <body>
7: <%
8: try{
9: Class.forName("oracle.jdbc.driver.OracleDriver" );
10: //Class.forName("oracle.jdbc.OracleDriver" );
11: String url = "jdbc:oracle:thin:@//127.0.0.1:8080:xe";
12: Connection con = DriverManager.getConnection(url,"system","system" );


Stacktrace:
     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

javax.servlet.ServletException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
     org.apache.jsp.index_jsp._jspService(index_jsp.java:98)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
     java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
     java.lang.Class.forName0(Native Method)
     java.lang.Class.forName(Class.java:164)
     org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


why?

thanks for your help.
  • 1. Re: eclipse jboss jsp oracle xe connect error
    orafad Oracle ACE
    Currently Being Moderated
    Not sure if XE includes jdbc (it's client/app server related). Anyway, JDBC drivers may be downloaded from:

    http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
  • 2. Re: eclipse jboss jsp oracle xe connect error
    Udo Guru
    Currently Being Moderated
    Just a short addendum:
    You have to make sure you use the driver release that corresponds to your JDK. From your post I'd conclude you should be using the ojdbc5.jar and additionally the orai18n.jar for NLS support.
    If you'll have more than one application that need JDBC support you might consider putting these libraries into your JEE containers shared library path instead of bundling it with each application archive.
    If you intend to migrate to 11.2 XE you should start with 11.2 JDBC drivers right away. Since you probably don't use any deprecated feature these will work fine with your current 10.2 XE. You can find these here:
    http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

    -Udo
  • 3. Re: eclipse jboss jsp oracle xe connect error
    892848 Newbie
    Currently Being Moderated
    hi
    thanks for your reply
    i forgot to say i am using all my configuration into a virtual machine virtualbox

    then my configuration is:
    eclipse ganymede 342
    jboss as 420 ga
    oracle 10g xe
    jdk15
    windows xp oracle virtual machine virtualbox

    i load ojdbc5.jar orai18n.jar files in the folder WEB-INF/lib
    and when i run my project i got this new errors (not in the same time):
    Error: Exception d'E/S: The Network Adapter could not establish the connection
    or
    Error: Erreur d'E/S: Got minus one from a read call

    what is the real problem?
    it is possible that the problem come from using virtual machine?
    the code compiling is correct and my url connexion too

    this is my url connexion:
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:8085:xe","system","system");

    and i started my database oracle xe


    ??

    thanks
  • 4. Re: eclipse jboss jsp oracle xe connect error
    orafad Oracle ACE
    Currently Being Moderated
    Try current style db specifier, with:

    "...@//localhost/xe" in the jdbc url.

    http://download.oracle.com/docs/cd/E11882_01/java.112/e16548/getsta.htm#JJDBC28061

    Edited by: orafad on Oct 7, 2011 8:46 AM
  • 5. Re: eclipse jboss jsp oracle xe connect error
    Udo Guru
    Currently Being Moderated
    Hi,
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:8085:xe","system","system");
    Are you sure your database is using port 8085 for database connections? I think this is the port for the internal HTTP Server that hosts your APEX. The database uses port 1521 as default, possibly some slightly different one on your system.
    You could check which one is configured on your system by executing
    lsnrctl status
    at the command line.

    -Udo
  • 6. Re: eclipse jboss jsp oracle xe connect error
    892848 Newbie
    Currently Being Moderated
    hi orafad,
    i try current style db:
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost/xe","system","system");

    but i get this error:
    exception

    org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 17

    [....]
    17: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost/xe","system","system");
    [....]
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
    [....]
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    [....]
    javax.servlet.ServletException: java.lang.NoSuchMethodError: oracle.i18n.text.OraBoot.getCharsetMaxCharLen(Ljava/lang/String;)Ljava/lang/String;


    and then i tried this one:
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:8085:xe","system","system");

    and got this error:
    Error: Erreur d'E/S: The Network Adapter could not establish the connection

    so i think my url connection is good and may be the problem is elsewhere

    thanks for your listening

    ========================


    hi udo,
    i checked the lsnrctl status and this is the result:

    Microsoft Windows XP [version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\xp>lsnrctl status

    LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 07-OCT. -2011 14:02:49

    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    Connexion Ó (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
    STATUT du PROCESSUS D'ECOUTE
    ------------------------
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
    Date de dÚpart 06-OCT. -2011 23:04:12
    DurÚe d'activitÚ 0 jours 14 heures 58 min. 36 sec
    Niveau de trace off
    SÚcuritÚ ON: Local OS Authentication
    SNMP OFF
    Service par dÚfaut XE
    Fichier de paramÞtres du processus d'Úcoute C:\oraclexe\app\oracle\product\10.2.0\server\network\admin\listener.ora
    Fichier journal du processus d'Úcoute C:\oraclexe\app\oracle\product\10.2.0\server\network\log\listener.log
    RÚcapitulatif d'Úcoute des points d'extrÚmitÚ...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC_FOR_XEipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=compaq)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=8085))(Presentation=HTTP)(Session=RAW))
    RÚcapitulatif services...
    Le service "CLRExtProc" comporte 1 instance(s).
    L'instance "CLRExtProc", statut UNKNOWN, comporte 1 gestionnaire(s) pour ce service...
    Le service "PLSExtProc" comporte 1 instance(s).
    L'instance "PLSExtProc", statut UNKNOWN, comporte 1 gestionnaire(s) pour ce service...
    Le service "XEXDB" comporte 1 instance(s).
    L'instance "xe", statut READY, comporte 1 gestionnaire(s) pour ce service...
    Le service "XE_XPT" comporte 1 instance(s).
    L'instance "xe", statut READY, comporte 1 gestionnaire(s) pour ce service...
    Le service "xe" comporte 1 instance(s).
    L'instance "xe", statut READY, comporte 1 gestionnaire(s) pour ce service...
    La commande a rÚussi


    however, i want to say that i manually changed the http port for oracle (now port 8085) to avoid conflict with jbossAS which use port 8080 by default
    all changes goes correct

    so i change my url connexion like this:
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521:xe","system","system");

    and got the same error

    question: it is not a problem to run eclipse jboss oracle express edition in a virtual machine?
    or may be an error inside my jsp page:

    <%@ page language="java" import="java.sql.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Employes</title>
    </head>
    <body>
    <%
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:8085:xe","system","system");
    System.out.println("Connected sucessfully.<br /><br />\n");
    System.out.println("Return all the employees name.<br />\n");
    String sql = "SELECT ENAME FROM EMP";
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
    while (rs.next()) {
         out.println(" ename=" + rs.getString("ename") + "<br />\n");
    }
    stmt.close();
    stmt = null;
    conn.close();
    conn = null;
    out.println("<br />Disconnected sucessfully.<br /><br />\n");
    }
    catch (Exception ex) {
    out.println(" Error: " + ex.getLocalizedMessage() + "<br><br>\n");
    }
    %>
    </body>
    </html>


    thanks for your listening

    ==================================
    NB:
    i work into virtual machine oracle virtualbox with windows xp and my configuration is:
    eclipse
    jboss
    oracle express edition
    jdk
  • 7. Re: eclipse jboss jsp oracle xe connect error
    Udo Guru
    Currently Being Moderated
    Hi,
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC_FOR_XEipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=compaq)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=8085))(Presentation=HTTP)(Session=RAW))
    This is what we were looking for: You have three listening endpoints:
    1. local connection via IPC (inner process communication)
    2. TCP connection on post 1521 listening for hostname "compaq"
    3. HTTP connection on port 8085 listening for localhost

    So, port 8085 is (as I assumed earlier) the HTTP port and not suitable for database connections. Your database connections either have to use IPC (not suitable for JDBC URL) or TCP port 1521.
    However, it seems your listener is bound to the hostname compaq on port 1521. You could try to use that hostname instead of 127.0.0.1 to connect, e.g.
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@compaq:1521:XE","system","system");
    Note that if you don't have database and JBoss running on the same host you might have to open the port 1521 in the firewall of your database server.
    Also note that you cannot mix up the different URL syntax variants for the JDBC URL. Either put it simply like in the example above or use the "slashed" version like this
    jdbc:oracle:thin:@//compaq:1521/xe
    I think you should get it working that way...

    -Udo
  • 8. Re: eclipse jboss jsp oracle xe connect error
    892848 Newbie
    Currently Being Moderated
    thanks orafad
    thanks udo

    now i solved my problem
    in fact
    - the good url connexion is
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","system","system");
    where port 1521 is the port of database listening

    - in second way i checked the java ee dependencies ('deployment assembly' in latest eclipse) in my dynamic web project properties
    i found that the appropriate external JARs are not selected

    - i dont need to load the appropriates JARs in WEB-INF/lib folder

    - the virtual machine is not the problem

    greats thanks guys
  • 9. Re: eclipse jboss jsp oracle xe connect error
    892848 Newbie
    Currently Being Moderated
    Question Answered
  • 10. Re: eclipse jboss jsp oracle xe connect error
    Udo Guru
    Currently Being Moderated
    Hi,

    great to hear you got it working!
    If you want to help others coming by to spot relevant posts easily, you could also mark answers in this thread as "helpful" or "correct".

    Thanks,

    Udo
  • 11. Re: eclipse apache jsp oracle xe connect error
    888387 Newbie
    Currently Being Moderated
    Hi,

    Me too have the same problem while connecting to the database in jsp page.
    My version of Eclispse is Helios and using Oracle Database 11g Express Edition,Tomcat 7.0.22 and JDK 1.6.

    When im Running my jsp page im getting the following error

    exception

    org.apache.jasper.JasperException: Unable to compile class for JSP:

    An error occurred at line: 14 in the generated java file
    Only a type can be imported. oracle.jdbc.driver.OracleDriver resolves to a package

    An error occurred at line: 15 in the generated java file
    Only a type can be imported. oracle.jdbc.OracleDriver resolves to a package

    An error occurred at line: 17 in the jsp file: /DBConnection.jsp
    oracle.jdbc.driver.OracleDriver cannot be resolved to a type
    *14: <%*
    *15: try{          Connection con;*
    *16:*
    *17: DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());*
    *18: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:8085:xe","uday","kiran");*
    *19:      out.println("Connection created");*
    *20:      Statement stmt=con.createStatement();*


    Stacktrace:
    *     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)*
    *     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)*
    *     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)*
    *     org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)*
    *     org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)*
    *     org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)*
    *     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)*
    *     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)*
    *     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)*
    *     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)*
    *     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)*


    My code in the jsp is
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <%@page import="java.sql.*" %>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Employee Details</title>
    </head>
    <body>

    <%
    try{          
         
         Connection con=null;
         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
         Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost/xe","uday","kiran");
         out.println("Connection created");
         Statement stmt=con.createStatement();
                   ResultSet rs=stmt.executeQuery("select * from emp");
              while(rs.next())
              {   out.println(rs.getInt(1));
              }

              }catch (Exception e) {
                   // TODO: handle exception
              }%>

    </body>
    </html>

    Even when im accecing the connection from out side class also im getting the same problem.
    Even i included the jar file ojdbc14.jar,orai18n.jar and ojdbc6.jar. I am still encounter the same error.
    Please help me..
    Thanks in advance...

    Edited by: UdayKiran on Oct 15, 2011 9:56 AM
  • 12. Re: eclipse apache jsp oracle xe connect error
    Udo Guru
    Currently Being Moderated
    Hi Uday,

    I think your problem is not related to XE, so you might have posted to a forum for Java developers... And your error message indicates that you have a different problem than described in the original post, so you should have at least opened a new thread here, even if it had been an XE specific problem.

    Now, please take a look over your code, especially that part
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <%@page import="java.sql.*" %>
    <head>
    ... should not contain the JSP directive for the import as part of the HTML-section. You should move it out, e.g.
    <%@ page language="java" import="java.sql.*" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    which, by the way, the example from the original poster has correct...
    If this doesn't help, please use a new thread in the corresponding forum. If you encounter any XE-specific problem, don't hesitate to post in this forum again. But keep in mind that there are forums for general database or SQL-related problems as well. So always try to chose the right forum for your problem.

    Thanks,

    Udo

    Edited by: Udo on 15.10.2011 11:46

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points