• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

REST - Hello World

 
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am learning REST and have written a simple hello world program.


My web.xml is




When I type
http://localhost:8080/ServletContainer1/test/hello

it says

type Status report

message /ServletContainer1/test/hello

description The requested resource is not available.


Can someone please help me to get this fixed?

 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some more details

I am using Tomcat 8.0 and Eclipse Version: Neon.1a Release (4.6.1)
 
Marshal
Posts: 5996
417
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your URL mapping defines "/rest/*" but you are attempting to access "/test/hello".
 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response.

Even
http://localhost:8080/ServletContainer1/rest/hello

gives the same error message
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the name of your web app really "ServletContainer1"? That doesn't sound like a name one would normally use.

If you renamed "com.vogella.jersey.first" to "test", then the URL would be http://localhost:8080/test/rest/hello
 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No luck , can you please guide me to some website that helps me with step by step instructions that get my first program working? I have gone thru a few websites (like vogella), but I am unable to find something that explains the link/connection between my servlet, XML file and the client/server (with tomcat/eclipse). Currently I am still reading "web services up and running" but wanted to make my hands dirty to understand the book better.
 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see you are using Jersey, you can explore the documentation on their website, there are many examples.
This page describes how to create a new REST API using a maven archetype, it should take no more than 5 minutes, you can then analyze the code while reading the docs: https://jersey.java.net/documentation/latest/getting-started.html

If later on you want to integrate Jersey with Spring and some data access, you can take a look at this boilerplate project https://github.com/gastongr/rest-boilerplate. You can get that running locally in 5 minutes too.

Also if you like video lessons, take a look at this great free course https://javabrains.io/courses/javaee_jaxrs
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic