Ulf Dittmer wrote:
Ulf Dittmer wrote:OK, that looks like a pretty clean Tomcat, except for converter-gson-2.9.0.jar. That's part of your web app, and belongs into WEB-INF/lib, together with the other dependencies (like Retrofit).
Actually, jakarta.servlet.jsp-api-3.1.1.jar looks suspicious. Wasn't there a jsp-api.jar file initially? Mucking around with Tomcat's internal files is a recipe for desaster.
|java.lang.RuntimeException: Error scanning entry org/apache/taglibs/standard/tlv/JstlSqlTLV$Handler.class from jar file:///C:/Users/abc/xxx/abc-workSpace/restPostMan/src/main/webapp/WEB-INF/lib/jakarta.servlet.jsp.jstl-3.0.1.jar
Ulf Dittmer wrote:
tangara goh wrote:The content of Tomcat Lib is quite huge. Is it possible to attached a compressed file here?
What we would need to see is not the files, but the list of files - in text, NOT as a screenshot.
I tried to attempt the stand alone Tomcat and I can't find any tutorial that can guide me how to operate a Tomcat server without IDE.
Start here: https://tomcat.apache.org/tomcat-10.1-doc/setup.html
I got a reply from SO
Oh, you are also asking this elsewhere, without mentioning this here? And probably without mentioning it there? Thus duplicating effort and wasting people's time? You've been here long enough to know that that's unfriendly behaviour. I just lost interest in helping you. Good bye.
Tim Holloway wrote:
Ulf Dittmer wrote:The error message does indicate that not all jar files are where they should be, or that some jar files are the wrong versions. If you post the contents of TOMCAT_HOME/lib and WEB-INF/lib, maybe we can help you.
And, again, DO NOT put application JAR files into TOMCAT_HOME/lib. That includes application library JARs!!!
Ulf Dittmer wrote:
and it is quite strange that i already have jakarta.servlet.jsp.jstl it is still complaing i need jakarta/servlet/jsp/JspFactory
That sentence does not make sense. JSP and JSTL are different things. JSP is built into a servlet container, whereas JSTL needs to be added.
There seems to be a disconnect between the libraries you compile against, and the libraries (meaning, the Tomcat version) that you run the code on. I advise not to use the IDE for this, but to use a standalone Tomcat for running your code. That way you will know exactly what version of the libraries is used.
why would i still need to install the jars manually ?
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:878)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
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:871)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:912)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
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:347)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
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:871)
... 21 more
Caused by: java.lang.NoClassDefFoundError: jakarta/servlet/jsp/JspFactory
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:235)
at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:206)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1834)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1299)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:987)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:304)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4797)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more
Ulf Dittmer wrote:You shouldn't download anything from the Maven site, you should let Maven do this. That is what dependency management systems are for.
I have no way of knowing whether some file on your disk is broken or incomplete. What I do know is that the "converter-gson" dependency simply does not contain the class retrofit2.Converter. That is why I keep asking how you have made sure that it does. Because it doesn't, and it baffles me how you might have gotten that idea.
Ulf Dittmer wrote:I'll ask yet again, hoping that you will actually do it this time:
Tell us how you checked which jar file that class is in
Because the converter-gson jar file does NOT contain the missing class.
If you want help you need to pay attention to what people are telling you.
Ulf Dittmer wrote:That screenshot, rather pointedly, does NOT contain the jar file in which the class retrofit2.Converter lives. I'll ask again:
Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.
Ulf Dittmer wrote:
tangara goh wrote:I already have it in my pom. Now I added into TOMCAT_HOME/lib again as well as the WEB-
Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.
Seeing that you seem to run Tomcat inside of an IDE, I can easily picture the jar file not ending up in the correct runtime directory.
Please see attached.
And snippet of my pom
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
Ulf Dittmer wrote:"<servlet-class>package controller.restController</servlet-class>" is wrong; remove the "package" part. Also note that class names should start with an uppercase letter.
Mappings never contain the context name.
Also note that "restPostMan" is the name of the servlet, not "restController" (which the form action uses).
We don't know what you have in WEB-INF/lib and TOMCAT_HOME/lib, but apparently not the class retrofit2.Converter. So you need to add whatever jar file contains that. Build tools like Maven and Gradle can handle dependency management for you.
Ulf Dittmer wrote:Were you hoping that "{exlir." would print the attribute? That's wrong in several ways; try "${exlir}" instead.
I'll refrain from commenting on the JSP XML syntax, which has been out of fashion for many years.
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:878)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
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:871)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:912)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
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:347)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
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:871)
... 21 more
Caused by: java.lang.NoClassDefFoundError: retrofit2/Converter$Factory
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
Tim Holloway wrote:Spring works just fine with Jakarta EE, although if you want to use CDI, it's a little touchy yet.
I'm a big fan of JavaServer Faces, which is also part of the Jakarta EE standard for an MVC GUI. In large part because it simplifies the task of displaying and processing GUI forms with automated validation and error reporting. I use Spring Data as the backend.
I've done JSF webapps that provide web services via ReST. JSF is, as I said, form oriented. But it's not greedy so the ReST stuff just routes to a ReST dispatched servlet, The JSF stuff routes to the FacesServlet, both use and share stock JEE object scopes (request, session, application), and all can share with Spring Data so it's just one big happy place.
Stephan van Hulst wrote:@WebServlet
It's not quite clear to me what it is you want to do. Do you just want to use a JSP to display some data that was generated in a controller or servlet?
Personally I'm a big fan of Jakarta MVC. It's similar to Spring MVC, but it only depends on Jakarta EE APIs such as JSP and JAX-RS. If your goal is to just write some web controllers with JSP views, it's great.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>restClientWithUI</groupId>
<artifactId>restClientWithUI</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven-compiler.source>17</maven-compiler.source>
<maven-compiler.target>17</maven-compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/jakarta.platform/jakarta.jakartaee-web-api -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>
C:\Program Files\Java\apache-tomcat-10.1.6\webapps
</directory>
<includes>
<include>**/*.war </include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>webclientv1</warName>
<outputDirectory> C:\Program Files\Java\apache-tomcat-10.1.6\webapps</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>