Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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

 
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
 
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
 
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
 
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
 
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() ?
 
author
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???
 
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.
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!