[Solved-5 Solutions] Access restriction: The type QName is not accessible due to restriction on required library



Error Description:

    • When we attempt to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs we get this error in Eclipse.

    Access restriction: The type QName is not accessible due to restriction on required library C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar

    • The full classname is javax.xml.namespace.QName

    Solution 1:

      • Go to the Build Path settings in the project properties. Remove the JRE System Library Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
        • This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first.
        • If you want a fundamental solution make sure you exclude the jar files with the same classes.

      Solution 2:

        • On Windows : Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
        • On Mac OS X/Linux: Eclipse -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning

        Solution 3:

          • First, delete the JRE System Libraries. Then, import JRE System Libraries again.

          Solution 4:

            • Go to the Build Path settings in the project properties. Windows -> Preferences -> Java Compiler
            • Remove the JRE System Library
            • Add another JRE with a "perfect match"
            • clean and build your project again. It worked for me.

            Solution 5:

              • Go to the Java Build Path in the project properties. Remove the existing JRE System Library Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish.
              • Lastly select order and export tab select JRE Lib and move on top. That's it.

              Related Searches to Access restriction: The type QName is not accessible due to restriction on required library