Search
Calendar
May 2025
S M T W T F S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031
Archives

PostHeaderIcon (long tweet) java.lang.SecurityException: Prohibited package name

Case

Here is a case of stupid error. I started up a new project in IntelliJ IDEA, laying on a Maven archetype. On launching the first unit test, I got the following error:

Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java.lalou.jonathan.multiposts

Quick fix

As you may have noticed, the package name was prefixed with java.… which is prohibited by the JDK. An immediate fix is to restore a package name not starting with java..

The code in the JDK is explicit: the exception with such a message is raised in a unique occasion:

        if ((name != null) && name.startsWith("java.")) {
            throw new SecurityException
                ("Prohibited package name: " +
                 name.substring(0, name.lastIndexOf('.')));
        }

Leave a Reply