agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] Classloader/Classpath problem with Ressource Files
2+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] Classloader/Classpath problem with Ressource Files
@ 2011-07-06 18:15
2011-07-28 12:39 ` [Pljava-dev] Classloader/Classpath problem with Ressource Files
0 siblings, 1 reply; 2+ messages in thread
From: @ 2011-07-06 18:15 UTC (permalink / raw)
Hi
I want to use html-unit from pg using pljava. But the problem is, that
pljava reports a file not found error when somebody try to access classpath
trough classloader.
see my pgadim console:
SELECT test.getDoTest();
FEHLER: 06 Jul 11 19:49:09
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1 Exception while
initializing JavaScript for the page
org.postgresql.pljava.internal.ServerException: 06 Jul 11 19:49:09
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration
Error when loading JavascriptConfiguration.xml
java.lang.NullPointerException
at
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getConfigurationFileAsReader(JavaScriptConfiguration.java:260)
if you look at the file
http://htmlunit.svn.sourceforge.net/viewvc/htmlunit/trunk/htmlunit/src/main/java/com/gargoylesoftwar...
you can see
final Class< ? > clazz = JavaScriptConfiguration.class;
final String name = clazz.getPackage().getName().replace('.', '/') + '/' +
"JavaScriptConfiguration.xml";
InputStream inputStream =
clazz.getClassLoader().getResourceAsStream(name);
But the file is in the jar as expected, so it must be a class loader path
problem.
Interestingly when I check the classpath ...
select sqlj.get_ClassPath('test');
"apachemime4j:commonscodec:commonscollections:commonsio:commonslang:commonslogging:cssparser:htmlunit:htmlunitcore:httpclient:httpcore:httpmime:nekohtml:sac:serializer:xalan:xercesImpl:xmlapis:hui"
ok, but when I do
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
public class FileUtils {
public static String getClasspath (int variante) {
//Get the System Classloader
final Class< ? > clazz = FileUtils.class;
ClassLoader sysClassLoader;
switch(variante) {
case 1: sysClassLoader = clazz.getClassLoader(); break;
case 2: sysClassLoader =
Thread.currentThread().getContextClassLoader(); break;
case 3: sysClassLoader = ClassLoader.getSystemClassLoader();
break;
default: return "NULL";
}
//sysClassLoader.g
//Get the URLs
URL[] urls = ((URLClassLoader)sysClassLoader).getURLs();
String cp = "";
for(int i=0; i< urls.length; i++)
{
cp += urls[i].getFile();
cp += ";";
}
return cp;
}
}
and select test.getCP(1); I get a casting exception
FEHLER: java.lang.ClassCastException: org.postgresql.pljava.sqlj.Loader
cannot be cast to java.net.URLClassLoader
********** Error **********
or select test.getCP(2); something completly different ..
"/C:/Program%20Files/PostgreSQL/9.0/data/Program%20FilesPostgreSQL9.0pljavapljava.jar;/C:/Program%20Files/PostgreSQL/9.0/data/;/C:/Program%20Files%20(x86)/Java/jre6/lib/ext/QTJava.zip;/C:/Program%20Files/PostgreSQL/9.0/pljava/pljava.jar;/C:/Program%20Files/PostgreSQL/9.0/pljava/deploy.jar;/C:/Program%20Files%20(x86)/PostgreSQL/pgJDBC/postgresql-8.4-702.jdbc4.jar;"
Any Ideas how to solve this?
Thx and cheers
Chris
PS As a dirty workaround I could add every jar into my environment classpath
... I think ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20110706/25f056da/attachment.html;
^ permalink raw reply [nested|flat] 2+ messages in thread
* [Pljava-dev] Classloader/Classpath problem with Ressource Files
2011-07-06 18:15 [Pljava-dev] Classloader/Classpath problem with Ressource Files
@ 2011-07-28 12:39 `
0 siblings, 0 replies; 2+ messages in thread
From: @ 2011-07-28 12:39 UTC (permalink / raw)
Christian Kindler <vorarlberger at gmail.com> writes:
> Hi
>
> I want to use html-unit from pg using pljava. But the problem is,
> that pljava reports a file not found error when somebody try to
> access classpath trough classloader.
PL/Java uses its own classloader to load them from the database. Can
you give a very simple example that demonstrates what you are trying
to accomplish without involving your actual code? Something simpler?
Do you *need* a classloader for what you are doing?
--
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] 2+ messages in thread
end of thread, other threads:[~2011-07-28 12:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-07-06 18:15 [Pljava-dev] Classloader/Classpath problem with Ressource Files
2011-07-28 12:39 `
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox