agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] Hello World example failure
5+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] Hello World example failure
@ 2006-09-08 22:29
2006-09-08 22:44 ` [Pljava-dev] Hello World example failure
2006-09-11 07:25 ` [Pljava-dev] Hello World example failure
0 siblings, 2 replies; 5+ messages in thread
From: @ 2006-09-08 22:29 UTC (permalink / raw)
Dear kind users,
I have installed PLJava and from all indications it appears to have been
successful. But I am NOT able to get the HELLO WORLD example to
execute. The following information is included in hopes that you can see
the problem and tell me what to change or what to correct to resolve the
error: java.lang.ClassNotFoundException:
com.mycompany.helloworld.HelloWorld that I am receiving from PSQL.
postgresql.conf contains:
dynamic_library_path = '$libdir;c:\\pljava;c:\\JavaJars'
custom_variable_classes = 'pljava' # list of custom variable
class names
pljava.classpath = 'C:\\pljava\\pljava.jar'
I create my class file as per the user guide (Hello World example):
C:\Java source>dir
Volume in drive C has no label.
Volume Serial Number is C815-11A0
Directory of C:\Java source
09/08/2006 04:00 PM <DIR> .
09/08/2006 04:00 PM <DIR> ..
09/08/2006 03:59 PM 123 helloWorld.class
2 File(s) 682 bytes
2 Dir(s) 73,859,919,872 bytes free
C:\Java source>more helloworld.class
package com.mycompany.helloworld;
public HelloWorld { public String helloWorld() { return "Hello
World"; }
}
C:\Java source>jar -cf helloworld.jar *.class
C:\Java source>
I next stop Postgresql on my Windows machine and restarted it. This
appears to work fine.
I next moved my JAR file into the directory 'c:\JavaJars'.
Next I execute psql to execute the "Hello World" example.
C:\JavaJars>dir
Volume in drive C has no label.
Volume Serial Number is C815-11A0
Directory of C:\JavaJars
09/08/2006 04:11 PM <DIR> .
09/08/2006 04:11 PM <DIR> ..
09/08/2006 04:05 PM 559 helloworld.jar
1 File(s) 559 bytes
2 Dir(s) 73,859,821,568 bytes free
C:\JavaJars>psql -U mfgadmin mlp204
Password for user mfgadmin:
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
Warning: Console code page (437) differs from Windows code page (1252)
8-bit characters may not work correctly. See psql reference
page "Notes for Windows users" for details.
mlp204=# select sqlj.install_jar('file:///JavaJars/helloworld.jar',
'helloworld_jar', false);
install_jar
-------------
(1 row)
mlp204=# select sqlj.set_classpath('public', 'helloworld_jar');
set_classpath
---------------
(1 row)
mlp204=# create or replace function helloworld()
mlp204-# returns "varchar" as
mlp204-# 'com.mycompany.helloworld.HelloWorld.helloWorld'
mlp204-# Language 'java' volatile;
CREATE FUNCTION
mlp204=# select * from helloworld();
ERROR: java.lang.ClassNotFoundException:
com.mycompany.helloworld.HelloWorld
mlp204=#
The following environment variables are set:
Path=C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\Program
Files\postgresql\8.1\bin;C:\Qt\3.3.6\bin;C:\Program
Files\Java\jre1.5.0_08\bin;C:\Program
Files\Java\jre1.5.0_08\bin\client;C:\Program Files\Java\jdk1.5.0_08\bin;
JAVA_HOME=C:\Program Files\Java\jre1.5.0_08
classpath=c:\JavaJars
At the present time I am at a loss as to why I am receiving the error
from psql: java.lang.ClassNotFoundException:
com.mycompany.helloworld.HelloWorld
Any enlightenment would be appreciated.
thanks Scott.
^ permalink raw reply [nested|flat] 5+ messages in thread
* [Pljava-dev] Hello World example failure
2006-09-08 22:29 [Pljava-dev] Hello World example failure
@ 2006-09-08 22:44 `
2006-09-12 16:14 ` [Pljava-dev] Hello World example failure
1 sibling, 1 reply; 5+ messages in thread
From: @ 2006-09-08 22:44 UTC (permalink / raw)
Scott Petersen wrote:
> dynamic_library_path = '$libdir;c:\\pljava;c:\\JavaJars'
>
Why do you have your jar directory in the dynamic_library_path? It's for
binary shared objects (.dll and .so), not jars.
> C:\Java source>jar -cf helloworld.jar *.class
>
>
This won't work. Your class has to be in a folder structure that matches
the package name.
Regards,
Thomas Hallgren
^ permalink raw reply [nested|flat] 5+ messages in thread
* [Pljava-dev] Hello World example failure
2006-09-08 22:29 [Pljava-dev] Hello World example failure
2006-09-08 22:44 ` [Pljava-dev] Hello World example failure
@ 2006-09-12 16:14 `
2006-09-12 20:40 ` [Pljava-dev] Hello World example failure
0 siblings, 1 reply; 5+ messages in thread
From: @ 2006-09-12 16:14 UTC (permalink / raw)
I have now corrected all of the installation issues and appreciate the
help. BUT, I am still receiving the error. The error is: *ERROR:
java.lang.ClassNotFoundException: com.mycompany.helloworld.HelloWorld
*
At a different point in the documentation for PLJava there is an example
function "getsysprop". I have been able to get that function to execute
with no problem. I believe that validates the installation.
For completeness I have included the source that I used for helloworld,
the creation of the JAR file, a dump of the jar_entry, jar_repository,
classpath_entry, and typemap_entry before and after pictures. After
creating the "JAR" file I moved the JAR from
/com/mycompany/helloworld/helloworld.jar to /JavaJars/helloworld.jar .
I am not trying to be difficult, but I am LOST and do not know how to
move forward with this simple test.
*C:\com\mycompany\helloworld>*type HelloWorld.class
package com.mycompany.helloworld;
public HelloWorld { public String helloWorld() { return "Hello World"; }
}
*C:\com\mycompany\helloworld>*dir
Volume in drive C has no label.
Volume Serial Number is C815-11A0
Directory of C:\com\mycompany\helloworld
09/12/2006 09:50 AM <DIR> .
09/12/2006 09:50 AM <DIR> ..
09/12/2006 09:20 AM 110 HelloWorld.class
1 File(s) 110 bytes
2 Dir(s) 74,092,773,376 bytes free
*C:\com\mycompany\helloworld>*jar -cf helloworld.jar *.class
*C:\com\mycompany\helloworld>*dir
Volume in drive C has no label.
Volume Serial Number is C815-11A0
Directory of C:\com\mycompany\helloworld
09/12/2006 09:50 AM <DIR> .
09/12/2006 09:50 AM <DIR> ..
09/12/2006 09:20 AM 110 HelloWorld.class
09/12/2006 09:50 AM 556 helloworld.jar
2 File(s) 666 bytes
2 Dir(s) 74,092,773,376 bytes free
*C:\com\mycompany\helloworld>*psql -U mfgadmin mlp204
Password for user mfgadmin:
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
Warning: Console code page (437) differs from Windows code page (1252)
8-bit characters may not work correctly. See psql reference
page "Notes for Windows users" for details.
*mlp204=#* select * from sqlj.jar_entry;
entryid | entryname | jarid | entryimage
---------+-----------+-------+------------
(0 rows)
*mlp204=# *select * from sqlj.jar_repository;
jarid | jarname | jarorigin | jarowner | jarmanifest | deploymentdesc
-------+---------+-----------+----------+-------------+----------------
(0 rows)
*mlp204=# *select * from sqlj.classpath_entry;
schemaname | ordinal | jarid
------------+---------+-------
(0 rows)
*mlp204=# *select * from
sqlj.install_jar('file:///javajars/helloworld.jar', 'helloworld_jar',
false);
install_jar
-------------
(1 row)
*mlp204=# *select * from sqlj.set_classpath('public', 'helloworld_jar');
set_classpath
---------------
(1 row)
*mlp204=# *create or replace function helloworld()
mlp204-# returns varchar as
mlp204-# 'com.mycompany.helloworld.HelloWorld.helloWorld'
mlp204-# language 'java' volatile;
CREATE FUNCTION
*mlp204=# *select * from helloworld();
*ERROR: java.lang.ClassNotFoundException:
com.mycompany.helloworld.HelloWorld*
*mlp204=# *select * from sqlj.jar_entry;
entryid | entryname | jarid |
entryimage
---------+------------------+-------+-------------------------------------------
--------------------------------------------------------------------------------
-
71 | HelloWorld.class | 15 | package
com.mycompany.helloworld;\015\012p
ublic HelloWorld { public String helloWorld() { return "Hello World";
}\015\012}
(1 row)
*mlp204=# *select * from sqlj.jar_repository;
jarid | jarname | jarorigin | jarowner |
jarmanifest |
deploymentdesc
-------+----------------+---------------------------------+----------+----------
---------------------------------------------------------------+----------------
15 | helloworld_jar | file:///javajars/helloworld.jar | mfgadmin |
Manifest-
Version: 1.0
Created-By: 1.5.0_08 (Sun Microsystems Inc.)
|
(1 row)
*mlp204=# *select * from sqlj.classpath_entry;
schemaname | ordinal | jarid
------------+---------+-------
public | 1 | 15
(1 row)
*mlp204=#* select * from sqlj.typemap_entry;
mapid | javaname | sqlname
-------+--------------------------------------------+-----------------------
2 | org.postgresql.pljava.example.ComplexTuple | javatest.complextuple
(1 row)
mlp204=#
^ permalink raw reply [nested|flat] 5+ messages in thread
* [Pljava-dev] Hello World example failure
2006-09-08 22:29 [Pljava-dev] Hello World example failure
2006-09-08 22:44 ` [Pljava-dev] Hello World example failure
2006-09-12 16:14 ` [Pljava-dev] Hello World example failure
@ 2006-09-12 20:40 `
0 siblings, 0 replies; 5+ messages in thread
From: @ 2006-09-12 20:40 UTC (permalink / raw)
Have you been *reading* any of the replies you've been receiving? I see
two mistakes below that others have already provided solutions for.
Additional details inline.
Scott Petersen wrote:
> I am not trying to be difficult, but I am LOST and do not know how to
> move forward with this simple test.
>
> *C:\com\mycompany\helloworld>*type HelloWorld.class
> package com.mycompany.helloworld;
> public HelloWorld { public String helloWorld() { return "Hello
> World"; } } *
Flip just told you that you don't put source code into a class file.
Source goes into a .java file and gets compiled, via javac, into a class
file. Suggest you get familiar with Java before trying to create a Java
stored procedure.
> *C:\com\mycompany\helloworld>*jar -cf helloworld.jar *.class
And Thomas explained in an earlier email that you can't just create a
jar file by jarring up your class files at this level. Your directory
structure in the JAR file must reflect the package. So, if you had a
valid class file (which you don't, see above), you would create the JAR
file by running the "jar" command at C:\, using the directory structure
you have above.
--
Guy Rouillier
^ permalink raw reply [nested|flat] 5+ messages in thread
* [Pljava-dev] Hello World example failure
2006-09-08 22:29 [Pljava-dev] Hello World example failure
@ 2006-09-11 07:25 `
1 sibling, 0 replies; 5+ messages in thread
From: @ 2006-09-11 07:25 UTC (permalink / raw)
Scott Petersen wrote:
> C:\Java source>more helloworld.class
> package com.mycompany.helloworld;
> public HelloWorld { public String helloWorld() { return "Hello
> World"; }
> }
>
It seems to me that you have not compiled your source code - you wrote it
directly to the class file.
The first thing you should do is
a) Write your source code to a file named "com/mycompany/HelloWorld.java"
b) Remove syntactic errors from the source code (it should start with
"public class HelloWorld" instead of "public HelloWorld"
c) Compile your source code to a class file using "javac
com/mycompany/HellowWorld.java"
d) Pack your class file into a jar file (don't foreget to include the
complete relative path com/mycompany/HelloWorld.class)
e) Install the jar file into correctly configured postgresql server
Tip: Try to run your HelloWorld examples without pljava first, using simple
java runtime. When you understand how it works, try to integrate it with
postgres.
Regards,
Filip Hrbek
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2006-09-12 20:40 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-08 22:29 [Pljava-dev] Hello World example failure
2006-09-08 22:44 `
2006-09-12 16:14 `
2006-09-12 20:40 `
2006-09-11 07:25 `
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox