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):
- Make sure you have sun-java6-bin and sun-java6-jre installed (using Synaptics Package Manager perhaps)
- In Eclipse, RClick JRE System Library > Build Path > Configure Build Path
- Add Library > Alternate JRE > Installed JREs…
- Add > Standard VM > Next > Directory > /usr/lib/jvm/java-6-sun-1.6.x.xx
- Remove Openjdk JRE System Library
Ian Ma
Advertisement
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.
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’.