[Pljava-dev] Found, but not solved - Re: Strange error on linux but not on windows

From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Found, but not solved - Re: Strange error on linux but not on windows
Date: 2011-09-19 14:52:47
Message-ID: CALtUeZbJs6oj5QvhDbWcc3vThBYKg_Fz+AsP1PAkx4dNDB210A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

OK, the Debug message "INFO: 18 Sep 11 06:58:16
org.postgresql.pljava.sqlj.Loader Failed to load class", led me into the
right direction. If I add the classpath manully with my own classloader,
then it is working like expected.

select stdout from quick_eval($$

System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog",
"fatal");
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import net.sourceforge.pgnetted.*;

// the follwoing line will do the trick!

addClassPath("/var/lib/postgresql/pgnetted/pgnetted-svn/PgNetted/PgNetted/lib/htmlunit29_n_hue11.jar");

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
print("END");
$$);

It seems that the classloader on windwos acts different then the classloader
on linux dies ... not sure how I should solve this ... the class - in fact -
is in the classpath:

postgres=# select jarid, entryname from sqlj.jar_entry where entryname like
'%WebClient%';
jarid | entryname
-------+--------------------------------------------------------------------
7 | com/gargoylesoftware/htmlunit/util/WebClientUtils$1.class
7 | com/gargoylesoftware/htmlunit/util/WebClientUtils.class
7 | com/gargoylesoftware/htmlunit/WebClient$1.class
7 | com/gargoylesoftware/htmlunit/WebClient$CurrentWindowTracker.class
7 | com/gargoylesoftware/htmlunit/WebClient$LoadJob.class
7 | com/gargoylesoftware/htmlunit/WebClient.class
(6 rows)

postgres=# select * from sqlj.classpath_entry;
schemaname | ordinal | jarid
------------+---------+-------
pgbsh | 1 | 6
pgbsh | 2 | 7
pgnetted | 1 | 6
pgnetted | 2 | 7
public | 1 | 6
public | 2 | 7

Any Ideas?

Thanks
Chris

2011/9/19 Vorarlberger <vorarlberger at gmail.com>

> Hi
>
>
>
> > You could try to debug it with dbx from Solaris Studio on Linux and
> > put a break point on elog. Instructions can be found here:
>
> >
> http://my.opera.com/myrkraverk/blog/2010/12/11/debugging-pl-java-with-dbx
>
> > If you are able to build your own server with debug information, and
> > then PL/Java as well you'll have debug builds of both.
>
> This sounds like a lot of work to me ... I will try this tomorrow if I can
> not figure it out by today ...
>
>
> Did you check the server's log?
>>
>
> Yes but there were no additional information. But, now I got all log
> settings in postgresql.conf set to DEBUG5 and now it seems to be verbose
> enough to go into a direction .. I think ... maybe you can read more out of
> it .. I look at the marked line:
>
>
> postgres=# select stdout from quick_eval($$
> postgres$#
> System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog",
> "fatal");
> postgres$# import com.gargoylesoftware.htmlunit.*;
> postgres$# import com.gargoylesoftware.htmlunit.html.*;
> postgres$# import net.sourceforge.pgnetted.*;
> postgres$#
> postgres$# WebClient webClient = new
> WebClient(BrowserVersion.FIREFOX_3_6);
> postgres$# print("END");
> postgres$# $$);
> DEBUG: StartTransactionCommand
> DEBUG: StartTransaction
> DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR,
> xid/subid/cid: 0/1/0, nestlvl: 1, children:
> DEBUG: find_in_dynamic_libpath: trying
> "/usr/lib/postgresql/9.1/lib/pljava"
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: find_in_dynamic_libpath: trying
> "/usr/lib/postgresql/9.1/lib/pljava.so"
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Using integer_datetimes
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Added JVM option string
> "-Dsqlj.defaultconnection=jdbc:default:connection"
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Added JVM option string "vfprintf"
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Creating JavaVM
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: JavaVM created
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Getting Backend class pljava.jar
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Backend class was there
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: className = 'net.sourceforge.pgbsh.PgBsh', methodName = 'init',
> parameters = 'null', returnType = 'null'
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: 18 Sep 11 06:58:12 org.postgresql.pljava.sqlj.Loader Creating
> typeMappings for schema pgbsh
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Loading class net.sourceforge.pgbsh.PgBsh
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: Obtaining method net.sourceforge.pgbsh.PgBsh.init ()Z
> CONTEXT: PL/pgSQL function "quick_eval" line 6 at assignment
> DEBUG: className = 'net.sourceforge.pgbsh.PgBsh', methodName = 'eval',
> parameters = 'null', returnType = 'null'
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> DEBUG: Loading class net.sourceforge.pgbsh.PgBsh
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
>
>
> DEBUG: Obtaining method net.sourceforge.pgbsh.PgBsh.eval
> (Ljava/lang/String;Ljava/sql/ResultSet;)Z
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> DEBUG: Exception in function ereport
> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> DEBUG: An attempt was made to call a PostgreSQL backend function after an
> elog(ERROR) had been issued
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> INFO: 18 Sep 11 06:58:16 org.postgresql.pljava.sqlj.Loader Failed to load
> class
>
> java.sql.SQLException: An attempt was made to call a PostgreSQL backend
> function after an elog(ERROR) had been issued
> at org.postgresql.pljava.internal.Oid._forSqlType(pljava.so)
> at org.postgresql.pljava.internal.Oid.forSqlType(pljava.so)
> at org.postgresql.pljava.jdbc.SPIPreparedStatement.setObject(pljava.so)
> at org.postgresql.pljava.jdbc.SPIPreparedStatement.setInt(pljava.so)
> at org.postgresql.pljava.sqlj.Loader.findClass(pljava.so)
> at java.lang.ClassLoader.loadClass(libgcj.so.12)
> at java.lang.ClassLoader.loadClass(libgcj.so.12)
> at java.lang.Class.forName(libgcj.so.12)
> at java.lang.Class.initializeClass(libgcj.so.12)
> at bsh.Parser.Block(Parser.java:2763)
> at bsh.Parser.Statement(Parser.java:2674)
> at bsh.Parser.WhileStatement(Parser.java:3016)
> at bsh.Parser.Statement(Parser.java:2715)
> at bsh.Parser.BlockStatement(Parser.java:2812)
> at bsh.Parser.Line(Parser.java:200)
> at bsh.Interpreter.Line(Interpreter.java:1012)
> at bsh.Interpreter.eval(Interpreter.java:649)
> at bsh.Interpreter.eval(Interpreter.java:756)
> at bsh.Interpreter.eval(Interpreter.java:745)
> at bsh.TargetError.xPrintTargetError(TargetError.java:126)
> at bsh.TargetError.printTargetError(TargetError.java:101)
> at bsh.TargetError.getMessage(TargetError.java:81)
> at java.lang.Throwable.getLocalizedMessage(libgcj.so.12)
> at java.lang.Throwable.toString(libgcj.so.12)
> at java.lang.Throwable.stackTraceString(libgcj.so.12)
> at java.lang.Throwable.printStackTrace(libgcj.so.12)
> at net.sourceforge.pgbsh.PgBshInterpreter.eval(PgBshInterpreter.java:94)
> at net.sourceforge.pgbsh.PgBsh.eval(PgBsh.java:88)
>
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> DEBUG: An attempt was made to call a PostgreSQL backend function after an
> elog(ERROR) had been issued
>
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> ERROR: java.sql.SQLException: An attempt was made to call a PostgreSQL
> backend function after an elog(ERROR) had been issued
> CONTEXT: PL/pgSQL function "quick_eval" line 7 at assignment
> postgres=# --
>
> Here is the very same on windows:
>
> postgres=# select stdout from quick_eval($$
> postgres$#
> System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog",
> "fatal");
> postgres$# import com.gargoylesoftware.htmlunit.*;
> postgres$# import com.gargoylesoftware.htmlunit.html.*;
> postgres$# import net.sourceforge.pgnetted.*;
> postgres$#
> postgres$# WebClient webClient = new
> WebClient(BrowserVersion.FIREFOX_3_6);
> postgres$# print("END");
> postgres$# $$);
> DEBUG: StartTransactionCommand
> DEBUG: StartTransaction
> DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR,
> xid/subid/cid: 0/1/0, nestlvl: 1, children:
> DEBUG: find_in_dynamic_libpath: trying "C:/Program
> Files/PostgreSQL/9.0/pljava/pljava"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: find_in_dynamic_libpath: trying "C:/Program
> Files/PostgreSQL/9.0/pljava/pljava.dll"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Using integer_datetimes
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Added JVM option string "-Djava.class.path=C:\Program
> Files\PostgreSQL\9.0\pljava\deploy
> .jar;C:\Program Files
> (x86)\PostgreSQL\pgJDBC\postgresql-8.4-702.jdbc4.jar;C:\Program
> Files\PostgreSQL\9.0\pljava\pgnett
> ed.jar;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Added JVM option string
> "-Dsqlj.defaultconnection=jdbc:default:connection"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Added JVM option string "vfprintf"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Added JVM option string "-Xrs"
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Creating JavaVM
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: JavaVM created
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Getting Backend class pljava.jar
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Backend class was there
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: 19 Sep 11 16:30:38 org.postgresql.pljava.internal.Backend Using
> SecurityManager for untrusted language
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: className = 'net.sourceforge.pgbsh.PgBsh', methodName = 'init',
> parameters = 'null', returnType = 'null'
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: 19 Sep 11 16:30:38 org.postgresql.pljava.sqlj.Loader Creating
> typeMappings for schema pgbsh
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Loading class net.sourceforge.pgbsh.PgBsh
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: Obtaining method net.sourceforge.pgbsh.PgBsh.init ()Z
> KONTEXT: PL/pgSQL function "quick_eval" line 5 at Zuweisung
> DEBUG: className = 'net.sourceforge.pgbsh.PgBsh', methodName = 'eval',
> parameters = 'null', returnType = 'null'
> KONTEXT: PL/pgSQL function "quick_eval" line 6 at Zuweisung
> DEBUG: Loading class net.sourceforge.pgbsh.PgBsh
> KONTEXT: PL/pgSQL function "quick_eval" line 6 at Zuweisung
> DEBUG: Obtaining method net.sourceforge.pgbsh.PgBsh.eval
> (Ljava/lang/String;Ljava/sql/ResultSet;)Z
> KONTEXT: PL/pgSQL function "quick_eval" line 6 at Zuweisung
> DEBUG: className = 'net.sourceforge.pgbsh.PgBsh', methodName = 'fin',
> parameters = 'null', returnType = 'null'
> KONTEXT: PL/pgSQL function "quick_eval" line 7 at Zuweisung
> DEBUG: Loading class net.sourceforge.pgbsh.PgBsh
> KONTEXT: PL/pgSQL function "quick_eval" line 7 at Zuweisung
> DEBUG: Obtaining method net.sourceforge.pgbsh.PgBsh.fin ()Z
> KONTEXT: PL/pgSQL function "quick_eval" line 7 at Zuweisung
> DEBUG: CommitTransactionCommand
> DEBUG: CommitTransaction
> DEBUG: name: unnamed; blockState: STARTED; state: INPROGR,
> xid/subid/cid: 0/1/0, nestlvl: 1, children:
> stdout
> --------
> END\r +
>
> (1 Zeile)
>
>
> postgres=#
> If you want to have a look into the source "
> net.sourceforge.pgbsh.PgBsh.eval", you can do so here:
>
> http://sourceforge.net/p/pgnetted/svn/35/tree/trunk/PgNetted/PgBsh/src/net/sourceforge/pgbsh/
>
> Thanks
> Chris
>
> PS I am using pljava 1.4.2-4ubuntu1 and postgres 9.1 on my linux test host.
> on my windows machine I am on postgres 9.0 and pljava 1.4.2. w64. I use
> openjdk 6 on linux and oracle jdk 6 on windows.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110919/48eb6aa0/attachment.html>

Browse pljava-dev by date

  From Date Subject
Next Message Vorarlberger 2011-09-20 14:32:42 [Pljava-dev] Strange error on linux but not on windows
Previous Message Vorarlberger 2011-09-19 14:33:52 [Pljava-dev] Strange error on linux but not on windows