sakir syed

Greenhorn
+ Follow
since Sep 02, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sakir syed

Hi Tim,

Thanks for your help. I deployed to the webapps folder for Tomcat having changed the webxml to correct the url, and it worked I got my first resource message. I will continue with the example.

thanks to Dave as well.


Kind Regards

Sakir

1 year ago
Hi Tim/Dave,

I tried copying the war file into the webapps directory and it still did not work. I do not know how to progress from this. Can you suggest any thing else?

Kind Regards

Sakir
1 year ago
Hi Dave,

Thank for replying to my post...

I followed the tutorial which specifies that the service can be run by 'Run on server' in Eclipse. I did not deply anything to the tomcat webapps directory. Attached you will find the tomcat directory structure image. Let me know how to proceed.

Kind regards

Sakir
1 year ago
Hi,

This is my first REST Api in java for which I followed the tutorial on youtube: (https://www.youtube.com/watch?v=5jQSat1cKMo) exactly. However I cannot get the url to work in eclipse and get the following error message: (see attached image also)

HTTP Status 404 – Not Found
Type Status Report
Message Not Found
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.13

I have uploaded my src and web xml files.

Can you help me discover what I am doing incorrectly.

Things I have tried already using google blogs:
- checked tomcat server is running independently - yes this is ok as it displays the tomcat home page when I enter the url: http://localhost:8080
- changed the url to many variations i.e.
http://localhost:8080/JavaAPI/rest/hello
http://localhost:8080/rest/hello
http://localhost:8080/JavaAPI/test/rest/hello
...etc none have worked.

Any help in this matter is appreciated.

Kind Regards

Sakir


"
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
 <display-name>JavaAPI</display-name>
 <servlet>
   <servlet-name>JavaAPI</servlet-name>
   <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
   <init-param>
     <param-name>jersey.config.server.provider.packages</param-name>
     <param-value>test</param-value>
   </init-param>
   <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>JavaAPI</servlet-name>
   <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
</web-app>

"

"
package test;

//import java.awt.PageAttributes.MediaType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;



@Path("/hello")
//@ApplicationPath("hello")
public class Hello extends Application {
@GET
@Produces(MediaType.TEXT_XML)
public String sayHello(){
String resource = "<? xml version='1.0' ?>" +
   "<hello> Hi Shakir, This is is Hello from XML</hello>";
return resource;
}

@GET
@Produces(MediaType.APPLICATION_JSON)
public String sayHelloJason(){
String resource = null;
return resource;
}

@GET
@Produces(MediaType.TEXT_HTML)
public String sayHelloHTML(){
String resource = "<h1> Hi Shakir, This is is Hello from HTML</h>";;
return resource;
}


}

"
1 year ago
Hi Tim,

I Created the War file and copied it to the Tomcat_Home/webapp/PlantPlaces directory as you suggested. Then used the url - http://localhost:8080/PlantPlaces/ to access it (even tried - http://localhost:8080/PlantPlaces) but both urls gave the same error as before.

Any further suggestions are really appreciated.

Kind Regards

Sakir
1 year ago
HI Tim,

I have uploaded a pic of the error message to this post. I hope you can see it. Below is the "Message" part of the Http 404 error:

Message : /PlantPlaces/

Thanks

Sakir
1 year ago
Hi Tim

Thankyou for getting back to me. I am using tomcat 9.0 and yes i get a 404 message with the description "The origin server did not find a current representation for the target resource or is not willing to..."

Let me know if you need any further information.

Kind regards

Sakir
1 year ago
hi Can you help me out. I am following a tutorial - https://www.youtube.com/watch?v=n6L7uX-o930&list=PL73qvSDlAVVhIVQX7d36glpQllxCIxEyR&index=7, which asks to create an index.xhtml page. I have followed all the instructions but I keep getting the following error - "the origin server did not find a current representation for the target resource or is not willing to disclose that one exists." Below you will find the web.xml I am using. I make the call to the webpage using : http://localhost:8080/PlantPlaces and then get the error

J2EE
Java 1.8
JRE 1.8
web.xml - see below
index.xhtml - see below

Web.xml


index.xhtml:


Any help is appreciated.

Thanks


Sakir
1 year ago
hi Can you help me out. I am following a tutorial - https://www.youtube.com/watch?v=n6L7uX-o930&list=PL73qvSDlAVVhIVQX7d36glpQllxCIxEyR&index=7, which asks to create an index.xhtml page. I have followed all the instructions but I keep getting the following error - "the origin server did not find a current representation for the target resource or is not willing to disclose that one exists." Below you will find the web.xml I am using. I make the call to the webpage using : http://localhost:8080/PlantPlaces and then get the error

J2EE
Java 1.8
JRE 1.8
web.xml - see below
index.xhtml - see below

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
 <display-name>PlantPlaces</display-name>
 <welcome-file-list>
   <welcome-file>index.xhtml</welcome-file>
   <welcome-file>index.html</welcome-file>
   <welcome-file>index.htm</welcome-file>
   <welcome-file>index.jsp</welcome-file>
   <welcome-file>default.html</welcome-file>
   <welcome-file>default.htm</welcome-file>
   <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>
 <servlet>
   <servlet-name>Faces Servlet</servlet-name>
   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>Faces Servlet</servlet-name>
   <url-pattern>/faces/*</url-pattern>
   <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
 <context-param>
   <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
   <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
   <param-value>client</param-value>
 </context-param>
 <context-param>
   <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
   <param-value>resources.application</param-value>
 </context-param>
 <listener>
   <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>
</web-app>


index.xhtml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Plant Places.com</title>
</head>
<body>
<h1>Welcome to PlantPlaces.com</h1>
Promoting plant diversity through education

</body>
</html>

Any help is appreciated.

Thanks


Sakir
1 year ago