jump to navigation

Access restriction: Java OpenJdk Rt.jar May 3, 2010

Posted by vyolian in java.
trackback

Environment: Ubuntu Jaunty 9.10, Eclipse
Error: “Access restriction: The type HttpServer is not accessible due to restriction on required library /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar”
Solution (quick): You need to configure your project from Java OpenJdk to Sun’s Java

Solution (detailed):

  1. Make sure you have sun-java6-bin and sun-java6-jre installed (using Synaptics Package Manager perhaps)
  2. In Eclipse, RClick JRE System Library > Build Path > Configure Build Path
  3. Add Library > Alternate JRE > Installed JREs…
  4. Add > Standard VM > Next > Directory > /usr/lib/jvm/java-6-sun-1.6.x.xx
  5. Remove Openjdk JRE System Library

Ian Ma

Advertisement

Comments»

1. Bilbo - May 18, 2010

Landed into this page googling for a similar problem in Ubuntu 10.04:

Cannot instantiate class: com.sun.jndi.rmi.registry.RegistryContextFactory; [Root exception is java.lang.ClassNotFoundException: com/sun/jndi/rmi/registry/RegistryContextFactory;]

I removed OpenJdk and left just Sun JDK. Now at least the java editor in Eclipse lets me write:
import com.sun.jndi.rmi.registry.RegistryContextFactory;

(previously the IDE warned about ClassNotFound in that line).

Still while trying to run either from the eclipse IDE or with a shell script the problem persists. I recompiled all the classes but with no success. Looks OpenJDK has left some traces behind.

I even checked with the help of:
lsof -p “javaPID”
that java/eclipse were using the proper Sun jdk rt.jar library.

It doesn’t make any sense to me.

2. Bilbo - May 20, 2010

Answering myself for anyone else landing here. The first problem was caused by OpenJDK since it doesn’t implement com.sun.jndi.rmi.registry.RegistryContextFactory. (I’m using OpenJDK as installed by Ubuntu 10.4 with ‘apt-get install openjdk-6-jdk’ @ 2010-05-20).

The second one was an stupid and not related one. I just added an extra ‘;” to the jndi.properties config file so the class loader was trying to find ‘RegistryContextFactory;’ instead of ‘RegistryContextFactory’.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.