I can't import Java EE annotations in eclipse,such as @EJB and @Stateless, instead eclipse recommends me to create them.
Asked
Active
Viewed 279 times
0
-
Do you have the libraries with those classes on the project's Java Build Path? Typically they'd come from your targeted Server. – nitind Dec 29 '19 at 22:46
-
can you please share your `pom.xml`. You might miss the EJB API dependency – rieckpil Dec 31 '19 at 09:41
-
@nitind Do you mean a jar that should be in Tomcat's libraries? – IvanKarl Jan 01 '20 at 09:00
-
@rieckpil There's not any pom.xml file as well – IvanKarl Jan 01 '20 at 09:00
-
@IvanKarl Yes, but you can not use Tomcat itself for this. To have EJB support you need TomEE: http://tomee.apache.org/comparison.html . – nitind Jan 01 '20 at 17:06
1 Answers
0
Per se, you can't use the EJB specification with a plain Tomcat server. Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket specification.
The EJB (Enterprise JavaBeans) specification is part of Java EE (now called Jakarta EE) and requires a Java EE application server: e.g. TomEE, Payara, Glassfish, Open Liberty, WildFly, etc. Tomcat is not a Java EE application server as it is just a servlet-container.
If you still want to run your application in a Tomcat-like environment, have a look at the TomEE application server: How to deploy EJB based application on Tomcat.

rieckpil
- 10,470
- 3
- 32
- 56