[Pljava-dev] Strange error on linux but not on windows

Lists: pljava-dev
From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-19 08:56:39
Message-ID: CALtUeZYVhb3aySBt1GVZay4D-wiUUDmsACOQ+2VFB-+RQnHbQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi!

I develop my application on windows, but the test, production env. will be
linux. On my windows box everything is working very well, but on linux I wil
receive this error:

> ERROR: java.sql.SQLException: An attempt was made to call a PostgreSQL
backend function after an elog(ERROR) had been issued

The codebase is pretty large, so I am not sure if I am able to provide a
code snipped. But can anyone tell me how I can look what got written into
the "elog(ERROR)"? because I can not see anything in the console. This is
all you can see:

postgres at ubuntu:~/pgnetted/pgnetted-svn/PgNetted$ psql -U postgres
psql (9.1.0)
Type "help" for help.

postgres=# select 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); // <- this line is raising the
exception!!
postgres$# print("END");
postgres$# $$);
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=#

If we comment the bad line, everything is fine again:
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$# $$);

stdout
--------
END +

This problem is not existent on windows ... strange ...

??? no idea ...

Any hint is welcome!

Thanks and cheers
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110919/df162634/attachment.html>


From: johann at 2ndquadrant(dot)com (Johann 'Myrkraverk' Oskarsson)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-19 12:19:56
Message-ID: x6pqiwvi4z.fsf@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi,

Vorarlberger <vorarlberger at gmail.com> writes:

> The codebase is pretty large, so I am not sure if I am able to
> provide a code snipped. But can anyone tell me how I can look what
> got written into the "elog (ERROR)"? because I can not see anything
> in the console. This is all you can see:

Did you check the server's log?

Unfortunately, I don't have a clue why elog(ERROR) would happen on
Linux and not Windows.

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.

--
Johann Oskarsson http://www.2ndquadrant.com/ |[]
PostgreSQL Development, 24x7 Support, Training and Services --+--
|
Blog: http://my.opera.com/myrkraverk/blog/


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

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/a6e9631e/attachment.html>


From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-20 14:32:42
Message-ID: CALtUeZZSNx7LdzQDBbji76Lo=KfPFtwH5tG9wUwtooMFnNUPKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Finally I was able to reproduce the same behavior on linux and windows. Then
I have added a new URL protocol and (re)load the missing classes via custom
classloader and sql. the Classpath is fine now.

But yet I am trapped in a security issue. I mean since I am going to read
from http(s) this is the best guess :-)

java.lang.IllegalStateException: Failure initializing default SSL context

This is not the case if I call my java from the linux command line instead
of a pljava postgres server process.

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.*;
WebClient webClient;

//every thing works unil here
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
HtmlPage page = webClient.getPage("http://www.google.ch/search?q=lala");
print("something " + page.toString());
print("END");
$$);

Caused by:
java.lang.IllegalStateException
+
at
gnu.javax.net.ssl.provider.X509KeyManagerFactory.engineGetKeyManagers(libgcj.so.12)
+
at
javax.net.ssl.KeyManagerFactory.getKeyManagers(libgcj.so.12)
+
at
org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:187)
+
at
org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:209)

Any Ideas how to get around this?

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/20110920/fe65e9c1/attachment.html>


From: johann at 2ndquadrant(dot)com (Johann 'Myrkraverk' Oskarsson)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-20 15:11:28
Message-ID: x68vpjuu3j.fsf@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Vorarlberger <vorarlberger at gmail.com> writes:

> Finally I was able to reproduce the same behavior on linux and
> windows. Then I have added a new URL protocol and (re)load the
> missing classes via custom classloader and sql. the Classpath is
> fine now.
>
> But yet I am trapped in a security issue. I mean since I am going to
> read from http(s) this is the best guess :-)

> Any Ideas how to get around this?

Do you define the function as LANGUAGE JAVAU? If that doesn't get
around the security issue you have found a bug I guess.

--
Johann Oskarsson http://www.2ndquadrant.com/ |[]
PostgreSQL Development, 24x7 Support, Training and Services --+--
|
Blog: http://my.opera.com/myrkraverk/blog/


From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-21 17:26:56
Message-ID: CALtUeZZ5VEMHjgs9HTvGZZRrcbSxkdxG2NhHtiZUQ7BFDV9L4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi

Do you define the function as LANGUAGE JAVAU? If that doesn't get
> around the security issue you have found a bug I guess.
>

Yes I did. And in fact I think I found a bug. Check out this small java
code:

package net.sourceforge.pgbsh;

import java.io.*;
import javax.net.ssl.*;

public class Test {
public static boolean testSSL() throws IOException {
int port = 443;
String hostName = "www.sun.com" ;

SSLSocketFactory sslFact = (SSLSocketFactory)
SSLSocketFactory.getDefault ();
SSLSocket socket = (SSLSocket) sslFact.createSocket(hostName, port);
InputStream in = socket . getInputStream ();
OutputStream out = socket . getOutputStream ();

// la la la ...

in.close ();
out.close ();

return true;
}
}

And create the SQL function:
CREATE OR REPLACE FUNCTION test_ssl()
RETURNS boolean
AS 'net.sourceforge.pgbsh.Test.testSSL'
LANGUAGE javau;

Now, when you do this on windows, there is no problem:
postgres=# select test_ssl();
test_ssl
----------
t
(1 Zeile)

postgres=#

But when you do exactly the same on linux, you can not:
postgres=# select test_ssl();
ERROR: java.io.IOException

... I think it depends on the "only root can listen on ports < 1000" thing
...

Cheers
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110921/45cefb84/attachment.html>


From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-24 07:20:59
Message-ID: CALtUeZZRXa1+fHHbHXadmsuX09sLC0eBa+s4hAFAMzX+S-mT1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: PostgreSQL : PostgreSQL 메일 링리스트 : 2011-09-24 이후 무지개 토토Dev

Hi Johann

I wannted to track down details into this issue so ... I have tried several
ways to get pg_ctl run with root provileges. And I have also tried to bypass
the ports < 1024 issue with tools like privbind or setcap. I had no success
...

Today I have filed a bug (#1011095) and hope you can implement a fix. As a
workaround (if someone has a similar problem) you can use a proxy server
(i.e. polipo) and redirect all connections on a port > 1024. This is working
very well.

Thanks and cheers
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110924/821bf0db/attachment.html>


From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-24 07:29:26
Message-ID: CALtUeZat6HSSGHK4cJBC0FUhT2mA4-Jz=K5vEgxvV=LDLfoG3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

> Today I have filed a bug (#1011095) and hope you can implement a fix. As a
> workaround (if someone has a similar problem) you can use a proxy server
> (i.e. polipo) and redirect all connections on a port > 1024. This is working
> very well.
>

No, I must correct myself. It is not working even trough a proxy ... :-(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110924/3941a08d/attachment.html>


From: pierce at hogranch(dot)com (John R Pierce)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-24 07:49:25
Message-ID: 4E7D8B85.7080104@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

On 09/24/11 12:20 AM, Vorarlberger wrote:
> I wannted to track down details into this issue so ... I have tried
> several ways to get pg_ctl run with root provileges. And I have also
> tried to bypass the ports < 1024 issue with tools like privbind or
> setcap. I had no success ...

the first one is easy...

su -l postgres -c "pg_ctl start -D ... "

There are no good reasons for running a database server daemon as root
such that its ignoring file protection.

And, I fail to see why would you want to run postgres on a low port?

--
john r pierce N 37, W 122
santa cruz ca mid-left coast


From: vorarlberger at gmail(dot)com (Vorarlberger)
To:
Subject: [Pljava-dev] Strange error on linux but not on windows
Date: 2011-09-24 11:08:13
Message-ID: CALtUeZbenrhSiqHoqv9RpvgsoyO=YJqQsnTA8wrHa+USHFww6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Thanks!

And, I fail to see why would you want to run postgres on a low port?
>

I do not really want to run postgres on a low port. I want to grap http(s)
content trough a java function (in detail I want to use htmlunit). It seems
that hmtlunit is opening a socket connection reader on ports 80/443 which
pljava does not like. I just made a guess that this depends on the "only
root can open low port sockes" thing - because its no problem doing this on
my windows develop environment. So running postgres with root should just be
the proof for that :-)

Thanks
Chris

>
> --
> john r pierce N 37, W 122
> santa cruz ca mid-left coast
>
>
> ______________________________**_________________
> Pljava-dev mailing list
> Pljava-dev at pgfoundry.org
> http://pgfoundry.org/mailman/**listinfo/pljava-dev<http://pgfoundry.org/mailman/listinfo/pljava-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110924/dd422944/attachment.html>