aspose file tools*
The moose likes Java in General and the fly likes SecurityException: Prohibited package name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "SecurityException: Prohibited package name" Watch "SecurityException: Prohibited package name" New topic
Author

SecurityException: Prohibited package name

Prasma Kankut
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Is there anything wrong with the following method? It is throwing java.lang.SecurityException: Prohibited package name: java.lang.

Here is the full stack trace.

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Thanks.


<i>The fact that today we know more than yesterday is good news about today, not bad news about yesterday - Ilja Preuss</i>
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

I don't suppose you have a package statement at the beginning of your java file?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Prasma Kankut
Greenhorn

Joined: Oct 15, 2003
Posts: 21
No. There is no package statement.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

It's possible to get this kind of error if you're using an old JDK that doesn't include some newer API class, but then you put a newer JDK's rt.jar (which does include that class) on the CLASSPATH. The old JDK will become very unhappy upon loading a java.lang.Something class from the CLASSPATH instead of from the boot class loader. Check to see if your CLASSPATH includes any rt.jar's -- it's never appropriate to include them.
Although I think this can only happen when there's a SecurityManager present: JaveWebStart, Applets, RMI, etc.


[Jess in Action][AskingGoodQuestions]
Prasma Kankut
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Thanks Ernest, you got it right! Looks like it was the Oracle client which did the mischief.
But I can't get your point about the SecurityManager. Do you say this error will occur only when using Applets, RMI etc? But mine is a simple Java application.
Also, I noted another thing - this error occurs only when I use the java.util.regex package. Else everything is fine.
Does it mean that, the old JDK don't have this package and hence the error?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SecurityException: Prohibited package name