agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] Strange error on linux but not on windows
10+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-19 08:56  
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-19 08:56 UTC (permalink / raw)

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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-19 12:19  
  parent: 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-19 12:19 UTC (permalink / raw)

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/





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-19 14:33  
  parent: 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-19 14:33 UTC (permalink / raw)

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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-20 14:32  
  parent: 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-20 14:32 UTC (permalink / raw)

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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-20 15:11  
  parent: 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-20 15:11 UTC (permalink / raw)

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/





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-21 17:26  
  parent: 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2011-09-21 17:26 UTC (permalink / raw)

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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-24 07:20  
  parent: 
  0 siblings, 2 replies; 10+ messages in thread

From:  @ 2011-09-24 07:20 UTC (permalink / raw)

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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-24 07:29  
  parent: 
  1 sibling, 0 replies; 10+ messages in thread

From:  @ 2011-09-24 07:29 UTC (permalink / raw)

> 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;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-24 07:49  
  parent: 
  1 sibling, 1 reply; 10+ messages in thread

From:  @ 2011-09-24 07:49 UTC (permalink / raw)

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





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [Pljava-dev] Strange error on linux but not on windows
@ 2011-09-24 11:08  
  parent: 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2011-09-24 11:08 UTC (permalink / raw)

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-d...;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110924/dd422944/attachment.html;



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2011-09-24 11:08 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-19 08:56 [Pljava-dev] Strange error on linux but not on windows 
2011-09-19 12:19 ` 
2011-09-19 14:33   ` 
2011-09-20 14:32     ` 
2011-09-20 15:11       ` 
2011-09-21 17:26         ` 
2011-09-24 07:20           ` 
2011-09-24 07:29             ` 
2011-09-24 07:49             ` 
2011-09-24 11:08               ` 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox