Home > Blockchain >  I am looking for a canocical list of maven dependensies needed to run Java EE Web Profile in Tomcat
I am looking for a canocical list of maven dependensies needed to run Java EE Web Profile in Tomcat

Time:11-18

I am trying to do something trivial. I want to run a Java EE Web Profile 8 application in Apache Tomcat 9. I have been searching the web for the last couple of days now trying to find a canonical list of Java EE dependencies needed for Tomcat. Can any one help me with such a list? I have read the following articles and they do not help:

How to properly install and configure JSF libraries via Maven?

Tomcat casting servlets to javax.servlet.Servlet instead of jakarta.servlet.http.HttpServlet

Seeing that Java EE is huge and this information is not just available on the web, the question is kind of important to answer. If official sources can be listed, this would help.

My POM file currently only contains

<dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-web-api</artifactId>
    <version>8.0.0</version>
</dependency>

and I get the following exception when running my webapp

java.util.MissingResourceException: Can't find javax.faces.LogStrings bundle from 
    at java.logging/java.util.logging.Logger.setupResourceInfo(Logger.java:2300)
    at java.logging/java.util.logging.Logger.<init>(Logger.java:565)
    at java.logging/java.util.logging.LogManager.demandLogger(LogManager.java:524)
    at java.logging/java.util.logging.LogManager.demandLogger(LogManager.java:517)
    at java.logging/java.util.logging.Logger.demandLogger(Logger.java:655)
    at java.logging/java.util.logging.Logger.getLogger(Logger.java:793)
    at java.logging/java.util.logging.Logger.getLogger(Logger.java:769)
    at javax.faces.webapp.FacesServlet.<clinit>(FacesServlet.java:258)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4902)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5206)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)

CodePudding user response:

The dependency you added is just the API. Java EE consist of a series of specfications (APIs), (the web profile being a subset of those). But they are only APIs, you need as well the implementations.

So, apart from the jakarta.jakartaee-web-api, which will bring all the apis you need, allowing any code you want to compile, you need all the implementations of all those APIs in order to make it work at runtime (That is why your code compiles but it doesn't run. It has the APIs in the classpath to compile, but not the implementations to run). This is a long list and something that you would need to add manually for each and every one of them. As ypu can imagine, this is not a good idea. Tjats why there are Application Servers (Wildfly, Payara, TomEE... but not Tomcat , which is just a Servlet Container, it implements the Servlet Specification, beside a buch of other things.).

Application Servers bundle the implementation for all Java EE Specifications, all together and properly integrated and tested. And they come in many flavors, being full profile (whole Java EE) or web profile (what you are looking for) the most common.

So, you should download an Application Server in its Web Profile versions. If you came from Tomcat, as PiotR commented, you should go with TomEE, which isna Tomcat with Java EE Specifications implementation bundled.

http://tomee.apache.org/download.html

You can find here all the flavors for TomEE, the one you are looking for is https://www.apache.org/dyn/closer.cgi/tomee/tomee-8.0.8/apache-tomee-8.0.8-webprofile.zip

  • Related