Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Property() and Class.forName() error in jdk1.1/1.3

 
mike zhang
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use java.util.Properties class to read property data including jdbc oracle driver, and then use Class.forName(driver) to connect to database. However, if I do this in jdk1.1 it works fine; when I use the same code in jdk1.3, I got error like:
****
...
..
java.net.URLClassLoader.
java.lang.ClassLoader.loadClass()
java.lang.Class.forName0(Native method)
java.lang.Class.forName()
*****
Does somebody know the reason and how to fix it ?
Thanks,
mike
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,
I'm not totally sure about this one, but it appears to be a security issue. It looks like you're trying to load a class over a network connection. You may try creating a policy file that grants universal permission just to test this.
Hope this helps
Michael Morris
SCJP2
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may be this is elementary. You have the driver in the classpath?
Yeah i understand that you would probably get no class def found error or some stuff like that if it's not so.
Anyway you w'd want to check if classes12.zip (or the ora driver you are using) in the classpath
 
mike zhang
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath does include the driver. The situation is: using the same code, same driver, it works in jdk1.1 but not in jdk1.3. If it is a security reason, why doesn't it happen in jdk1.1 ?
where should this security policy file be put ?
thanks,
mike
 
Matt Siegel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this --
Thread.getContextClassLoader().loadClass(driver);
Let me know if that works,
Matt
 
Mandan Happy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What difference would Thread.getContextClassLoader().loadClass() would make ? howz it different from Class.forName() ?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mike zhang:
****
...
..
java.net.URLClassLoader.
java.lang.ClassLoader.loadClass()
java.lang.Class.forName0(Native method)
java.lang.Class.forName()
*****
[/QB]

What are the dots standing for? What Error/Exception are you getting???
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the relevant code and complete error message/stack trace. If you are running an application, I don't think you will get any security exceptions. Also, I don't think that the presence of URLClassLoader in the stack trace necessarily indicates network class loading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic