The import javax.annotation.Resource cannot be resolved
Asked Answered
M

4

12

I have tried to resolve by adding missing/unnecessary jar's but nothing works for me. if you know how to resolve this issue then kindly help... Thank you in advance.

Code IDE ERROR

I am using JDK 9.0.4 installed in this IDE Eclipse 4.7 Oxygen December 2017

Windows 10

Servlet 4.0

JSP 2.3

JSTL tags

Megaton answered 27/2, 2018 at 20:46 Comment(2)
Are you sure that the WebContent\WEB-INF\lib folder is included in the classpath by your Ide ?Collaboration
yes it is all working on other programs fine but when i am working with jdbc but having problem when i am coming to Context XML or creating a connection pool.Megaton
M
11

Eclipse is facing some bugs in IDE 4.7 it is not fully compitable with JDK 9 like in with JDK 9 IDE is not generating toString() function also...

so i change the JDK 9 to jdk 8.1 and it solves all the problem.

to change the JDK...

Window > Preferences > Installed JREs >>> Change the JDK 9 to JDK xx

AND/OR

Right Click Project > Properties > JRE > Edit >>> YOUR ALTERNATIVE JDK xx

This had solved my problem.

Megaton answered 28/2, 2018 at 6:33 Comment(2)
Just mention, in Eclipse Version: 2020-03 (4.15.0) " Installed JREs" is located under the "Java" menu point. So, the path to making the aforementioned changes is the following: Window > Preferences >Java >Installed JREs.Corey
@Corey Indeed thanks for update this comment really helps.Megaton
B
3

I have encountered the same problem with you.
Download javax.annotation.jar online and add to your library may help.

Bullhorn answered 11/7, 2018 at 14:0 Comment(1)
This fixed my problem.Probably
B
2

If you're using maven managing your dependencies, you can also add the below dependency in your pom.xml.

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

OR download the jar file from here https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api/1.3.2

Bischoff answered 1/1 at 23:29 Comment(0)
E
1

Or go to : right click your project->build path->configure build path->add external JARs->"C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib\annotations-api.jar" and all will be right.

Endres answered 5/11, 2021 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.