users@glassfish.java.net

Oracle DB and GlassFish (anyone have it working?)

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Jan 2009 15:21:56 PST

GF: Sun Java System Application Server 9.1_02 (build b04-fcs)
Java: Sun JDK 1.6.0_11
OS: Windows XP

I am trying to configure Oracle datasources in a GF domain. I have the JAR files in ext, and I have the latest drivers. I have tried pooled and plain DataSources. The setup goes fine, but then when I try to ping the connection it hangs, and I do not get a timeout or an error. I then decided I would try this from a JSP page directly, so I wrote the following in a JSP page:
<%
        String URL = "jdbc:oracle:thin:@10.1.98.26:3700:DEV";
        oracle.jdbc.pool.OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
        ds.setURL(URL);
        ds.setUser("xxxxx");
        ds.setPassword("xxxxx");
        Connection con = ds.getConnection();
        Statement s = con.createStatement();
        ResultSet rs = s.executeQuery("select * from suntrack.codes");
        int count = 0;
        while (rs.next()) {
            String desc = rs.getString("description");
            count++;
            out.print("Desc: "+desc+"<br/>");
            if (count > 100) {
                break;

            }
        }
        rs.close();
        s.close();
        con.close();
        ds.close();

%>

It just sits there spinning its wheels, and either the browser or something else in the Java server starts to use more CPU (per the thread dump I assume the CPU utilization is caused by something else though). Next I wrote a plain Java SE application, pointed to all the EE jars in GlassFish/lib, and wrote the following code in a main method of a class:
    public static void main(String[] args){
        Connection con = null;
        try{
        String URL = "jdbc:oracle:thin:@10.1.98.26:3700:DEV";
        oracle.jdbc.pool.OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
        ds.setURL(URL);
        ds.setUser("xxxxx");
        ds.setPassword("xxxxx");
        con = ds.getConnection();
        Statement s = con.createStatement();
        ResultSet rs = s.executeQuery("select * from suntrack.codes");
        int count = 0;
        while (rs.next()) {
            String desc = rs.getString("description");
            count++;
            System.out.println("Desc: "+desc);
            if (count > 100) {
                break;

            }
        }
        rs.close();
        s.close();
        con.close();
        ds.close();
        }catch(Throwable e){
            e.printStackTrace(System.err);
        }finally{
            try{con.close();}catch(Throwable e){}
        }
    }

and that works like a charm. There is no hang or high CPU usage. Anyways, I really need to get converted over to GF from Oracle AS. I'm even willing to debug the code where the issue is occurring. I wanted to ask if someone knows what it may be or may have had a similar experience and fixed it already without patching some code.

Too, if some devs can point me to where to start with the sources on the issue that would be great. This is on Windows, so if GF sources have any issues with debugging them on Windows that would be helpful to know ahead of time.

The thread dump shows:
"httpSSLWorkerThread-8080-1" daemon prio=10 tid=0x2fa11800 nid=0x74 in Object.wait() [0x309be000..0x309bfb14]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0d6bd608> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:485)
        at com.sun.enterprise.server.ss.ASSocketService._waitOnClientConnection(ASSocketService.java:500)
        - locked <0x0d6bd608> (a java.lang.Object)
        at com.sun.enterprise.server.ss.ASSocketService.waitOnClientConnection(ASSocketService.java:491)
        at com.sun.enterprise.server.ss.ASSocketServiceProxy.waitOnClientConnection(ASSocketServiceProxy.java:114)
        at com.sun.enterprise.server.ss.provider.ASPlainSocketImpl.connect(ASPlainSocketImpl.java:296)
        at com.sun.enterprise.server.ss.provider.ASClientSocketImpl.connect(ASClientSocketImpl.java:267)
        at java.net.Socket.connect(Socket.java:519)
        at java.net.Socket.connect(Socket.java:469)
        at java.net.Socket.<init>(Socket.java:366)
        at java.net.Socket.<init>(Socket.java:180)
        at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:123)
        at oracle.net.nt.ConnOption.connect(ConnOption.java:122)
        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:302)

to be the issue. I'll attach two different thread dumps. The first is one when ping is being used. The next will be one where I make the call directly from the JSP page. Either way this seems to be a bug in GF as the database connection is being run through some of its logic apparently. Where ever ASSocketService.java is defined is at least part of the problem. Some kind of a synchronization issue.

Thanks for any help,

Wade
[Message sent by forum member 'wadechandler' (wadechandler)]

http://forums.java.net/jive/thread.jspa?messageID=324404