This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!

tangara goh

Ranch Foreman
+ Follow
since Dec 27, 2009
Merit badge: grant badges
Biography
I am a beginner in Java and hope to pick up the trade secrets so that I can move on to Android development
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
209
Given in last 30 days
5
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tangara goh

So, I was terribly confused about using Map.EntrySet then I chanced about this youtube video :

https://www.youtube.com/watch?v=28Esy94bXzk&list=PLMDZqACtfCkN0QFu10NFx3e3P-vKB-CQ2&index=13&t=624s

There is a part where you pasted the code onto the console before deciding what to do next.

I tried to copy the test arrays onto my console, it doesn't allow me at all.

How do I make that happened ?

Tks
P.S I will only ask here.
2 weeks ago

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.



Should I remove that jar ?

now, I tried out using jetty with eclipse and then it gives me error like this :


|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



the jar is also attached.

But, if i removed all the jars and the dependencies that Jetty is complaining, now it says it can't find my Controller.class.

I read that Eclipse inherited the Jakaratee EE, so it could be part of Eclipse, will the dependencies means redundant jars and so they are not supposed to be in ? What about Jetty since this is a Eclipse-jetty plug in I am using. ?
3 weeks ago
JSP

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.



Er I need an answer fast so I do hope you understand that I am running out of money i need to complete this assignment.

but, today i found out that solution doesn't work.  


Managed to copy it to txt :

01/03/2023  11:34 pm    <DIR>          .
01/03/2023  11:34 pm    <DIR>          ..
01/03/2023  12:06 am            14,122 annotations-api.jar
01/03/2023  12:06 am            55,980 catalina-ant.jar
01/03/2023  12:06 am           125,174 catalina-ha.jar
01/03/2023  12:06 am            63,435 catalina-ssi.jar
01/03/2023  12:06 am            78,936 catalina-storeconfig.jar
01/03/2023  12:06 am           324,727 catalina-tribes.jar
01/03/2023  12:06 am         1,702,785 catalina.jar
28/02/2023  09:21 pm             4,618 converter-gson-2.9.0.jar
01/03/2023  12:06 am         3,237,597 ecj-4.26.jar
01/03/2023  12:06 am            89,303 el-api.jar
01/03/2023  11:34 pm            71,370 jakarta.servlet.jsp-api-3.1.1.jar
01/03/2023  05:41 pm         3,711,043 jakarta.servlet.jsp.jstl-3.0.1.jar
01/03/2023  05:40 pm            46,041 jakarta.servlet.jsp.jstl-api-3.0.0.jar
01/03/2023  12:06 am           763,944 jakartaee-migration-1.0.6-shaded.jar
01/03/2023  12:06 am           172,849 jasper-el.jar
01/03/2023  12:06 am           569,478 jasper.jar
01/03/2023  12:06 am            28,466 jaspic-api.jar
01/03/2023  12:06 am           365,683 servlet-api.jar
01/03/2023  12:06 am            11,568 tomcat-api.jar
01/03/2023  12:06 am           870,285 tomcat-coyote.jar
01/03/2023  12:06 am           335,540 tomcat-dbcp.jar
01/03/2023  12:06 am            68,468 tomcat-i18n-cs.jar
01/03/2023  12:06 am            77,387 tomcat-i18n-de.jar
01/03/2023  12:06 am           104,046 tomcat-i18n-es.jar
01/03/2023  12:06 am           168,730 tomcat-i18n-fr.jar
01/03/2023  12:06 am           191,578 tomcat-i18n-ja.jar
01/03/2023  12:06 am           192,783 tomcat-i18n-ko.jar
01/03/2023  12:06 am            52,068 tomcat-i18n-pt-BR.jar
01/03/2023  12:06 am            49,200 tomcat-i18n-ru.jar
01/03/2023  12:06 am           175,966 tomcat-i18n-zh-CN.jar
01/03/2023  12:06 am           149,512 tomcat-jdbc.jar
01/03/2023  12:06 am            16,118 tomcat-jni.jar
01/03/2023  12:06 am           229,256 tomcat-util-scan.jar
01/03/2023  12:06 am           204,082 tomcat-util.jar
01/03/2023  12:06 am           240,150 tomcat-websocket.jar
01/03/2023  12:06 am            14,748 websocket-api.jar
01/03/2023  12:06 am            31,697 websocket-client-api.jar
             37 File(s)     14,608,733 bytes
              2 Dir(s)  15,923,810,304 bytes free

3 weeks ago
JSP

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!!!



The content of Tomcat Lib is quite huge.  Is it possible to attached a compressed file here?

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.

Can I have some guidance how I can test things out in Tomcat.

I got a reply from SO that I just dropped the entire Jakarata EE lib onto Tomcat and the error it will help.  It did work but still I got to iron out all the dependencies as I need it for CICD.
3 weeks ago
JSP

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.



Hi Ulf, I have put in all the lib that you mentioned.  Now, when I run the server on standalone, it gives me the same error, even though the index page could be displayed.

Please find attached.

3 weeks ago
JSP


why would i still need to install the jars manually ?


You don't, as I keep telling you. Of course, currently your Maven POM does nothing with those dependencies. You need to add something about Maven creating a war file. See https://www.baeldung.com/maven-generate-war-file for an introduction; section 3 contains the first step.

I have rewritten based on your hints. Tks.
Here's the new pom but I am stuck at the output it to Tomcat directory which is in that frustrating Windows 0S that gives me a access denial.  So, not to waste time, I chose to output it to a User directory and then added in a embedded tomcat.

But, when i run the server, this is the part that gets communicated, as it seem Eclipse will somehow call a Tomcat server which is not the embedded one.

How can I best navigate all these obstacles that is blocking my progress to the jsp which I have yet to figure out things?



so, basically, i got to learn the way from https://www.youtube.com/watch?v=xsfRSrDgBWI

and now the error is :


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



and it is quite strange that i already have jakarta.servlet.jsp.jstl it is still complaing i need   jakarta/servlet/jsp/JspFactory

3 weeks ago
JSP

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.



yes. so i am really puzzled why with maven - and i updated it, cleaned and installed it so many times, why would i still need to install the jars manually ?

here is the relevant dependencies

3 weeks ago
JSP

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.


ok. i think i know what you meant.

and i proceeded to add the respective files - retrofit files including okhttp3 etc

btw, it's never ending with the latest java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics but thank you so much and sorry I did not understand what you meant tks so much to make me wake up and read your message carefully.
3 weeks ago
JSP

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.



the name is converter-gson which is from retrofit2

<dependency>
 <groupId>com.squareup.retrofit2</groupId>
 <artifactId>converter-gson</artifactId>
 <version>2.9.0</version>
</dependency>
3 weeks ago
JSP

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>

3 weeks ago
JSP

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.



I already have it in my pom.  Now I added into TOMCAT_HOME/lib again as well as the WEB-INF/lib, it is still giving me the same error.

I am not sure what is wrong.  Attached i the tomcat configuration, do let me know if something is amissed. tks.
3 weeks ago
JSP

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.



I managed to get the template fixed after searching for many hours but it is the web.xml that I am not sure now.





so i am not sure if the servlet-name should e restPostMan which is the context name or do i put /demo ?

and the jsp is



and the error i am getting is


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)



i have included the retrofit2 in Tomcat lib just to see if that is the caused, as suggested by SO but it is not helpful.

Hope I can get some answers here. Tks.
3 weeks ago
JSP
Hello,

I am using Jakaratee with jstl but really i have forgotten how to do it.

Basically, I have use the HTTPServletRequest  in my Controller to set attributes in order to bring it in to the jsp layer but i tried the entire morning, I can't make the attributes in.

Here's is a the code snippet to give you a clearer idea :



but in my jstl page, I am not able to bring the setAttributes that i want to display. I have put the jstl.jar onto the lib folder in the WEB-INF lib folder.



Hope I can get some answers here. Tks again

3 weeks ago
JSP

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.



er, I am not doing a gui.  I just want to do a quick and dirty job using jsp but now really I am stuck how to extract the Map attributes and display it in the jsp.  It seems I have to re-write the rest client method to make it return as a Map ?
3 weeks ago

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.



Yes. I wanted to use a servlet instead of Spring as I thought it is easier but the amount of time spending on this is terrifying long.

This tomcat server is not allowing me to install the new tomcat 10.1.6 so I am using this way to let me install :


<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>



so, now I think i am going to delete the entire project it seems the tomcat 10.1.16 after i did the above.

so, will it affect things since I am not updating the ROOT.war as last time how I did it , and keep this pom ?

3 weeks ago