views:

286

answers:

4

Hi,

Hopefully someone has come across this before. I'm running Spring STS 2.3.0 and when attempting to use the @Resource annotation from javax.annotations.Resource I get "Access restriction: The type Resource is not accessible due to restriction on required library". I'm using the JDK 6u18.

I've tried changing the JDK Compliance to 1.5 and 1.6 and both yield the same error.

Cheers, -Ed

A: 

You might be able to change that configured compiler error to a warning or ignored, in the deprecated and restricted API section: Forbidden reference (access rules).

Stephen Denne
A: 

Eclipse should tell you what library (say, X) it's having an issue with. Something like this is happening:

  • Spring STS has a dependency on version V1 of library X.
  • Something else also has a dependency on version V2 (where V1 != V2) of library X.

Now you have a transitive dependency on the same library, but two different versions are in your classpath. That's not allowed. The solution is to remove things from your classpath and instead add specific libraries to your Eclipse build path.

John Feminella
+2  A: 

If you are using a Plug-in Project instead of a regular Java project, try setting

Bundle-RequiredExecutionEnvironment: JavaSE-1.6

in your manifest.mf. (And after changing it, you may need to Right click on the project and do PDE Tools -> Update Classpath

Andrew Niefer
A: 

This worked for me: Change eclipse (STS) project build path | Libraries tab | select JRE System Library [J2SE-1.4] | Edit button | change from Execution Environment radio tab which says J2SE 1.4 (jdk1.6.0_21) to Workspace default JRE (jdk1.6.0_21).

Wolf