| Contact

[Eclipse] Access restriction: Class is not accessible due to restriction on required library

"Access restriction: Class is not accessible due to restriction on required library"; error message may be shown while developing Java projects in Eclipse IDE. Error message is self-explanatory, some classes can not be loaded into the project since restriction rules are being imposed on those classes.

How to solve

This error message can be removed by changing a setting inside Eclipse IDE. Open up the dialog box shown below, using any of the following paths.
  • Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
  • (Project) Properties -> Java Compiler -> Errors/Warnings
Locate the "Forbidden reference (access rules)" option under "Deprecated and restricted API" section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to "Error" which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.

"Warning" or "Ignore" options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or access rules).

Labels: , , , ,

Translate into your language
Reader Comments
Comments Count: 21
Write your own opinion
Share with others
E-mail
Search More Articles
  1. This is exactly what I searched for, thanks.
  2. thnaks for post
  3. Great!
  4. thanks for your post. Solved my problem!
  5. solved my problem. thanks!
  6. thank you so much
  7. thanks for the post....solved my problem!!
  8. Thanks for this, exactly what has been annoying me for for weeks.
  9. thanks, this saved my time.
  10. thanks dude!!
  11. I don't understand what these restrictions are, but thanks for the tip - made my day.
  12. Wow...I have been searching all over the place for this answer. Thanks for posting this.
  13. Anonymous Anonymous (March 09, 2009 8:17 PM)  
    Thanks a lot. It resolved my issue
  14. Anonymous Anonymous (March 23, 2009 1:33 PM)  
    Wonderful, this one was driving me crazy !
  15. Anonymous Anonymous (March 27, 2009 1:59 AM)  
    This post does not appear to provide a satisfactory solution to the problem, but merely explains how to make the warning go away. If you see the error "Access restriction: The method (name) from the type (class) is not accessible due to restriction on required project (project)" can be solved by 1) Right click on the project with the problem and select "properties"; 2) Select "Java Build Path"; 3) Expand "Plug-in Dependencies" and expand the project causing the problem; 4) Expand "Access rules" and modify them to ensure the referenced class is accessible.
  16. Anonymous Anonymous (May 07, 2009 12:02 AM)  
    Good.Quick and Neat help.........
    Thanks
  17. Anonymous Anonymous (May 29, 2009 10:25 AM)  
    The post by Anonymous on March 27, 2009 1:59AM does not solve the problem either. By modifying the Access Rules you are simply hiding the problem. The Access Rules are there for a reason and you need to fix the problem. If you don't, you are probably in violation of the Java license.
  18. Anonymous Anonymous (June 03, 2009 4:00 AM)  
    A BIG problem, with a SIMPLE solution.

    Thanks a lot.
  19. I encountered this when creating a maven apache cxf prototype. The problem was not fixable by changing access rules for the library because these were not modifiable. The solution for me was to use a newer JDK or change the Order/Export (I think this is class loader order) so the Maven-supplied jaxb-api2.1.jar was used. The workspace Java 1.5 system library was not correctly exporting the javax.jws.* package. My approach was just to change the system library to a 1.6 one.
  20. Anonymous Anonymous (June 19, 2009 12:51 PM)  
    Brilliant, mate! Helped me too. Thanks!
  21. Anonymous Anonymous (June 27, 2009 9:01 PM)  
    Thanks dude.

Post a Comment

We appreciate your opinions, suggestions and criticism.

ABOUT AUTHOR
Kamal Mettananada is a Software Architect, Java Explorer and Blogger. Digizol consists of computer related articles, tutorials, tips and other information.
ARCHIVES
Select Month:

Free counter and web stats

FEED SUBSCRIPTION
Subscribe to our feed using your online news reader, approximately 1-2 articles per week.
ABOUT US
^top^