the origin server did not find a current representation for the target resource что делать
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat
I have built an application using Spring with Eclipse IDE. When I launch the project from Eclipse IDE everything is fine but when I package the maven project as a war file and deployed to separate tomcat I have this issue
This is a configuration snippet from my xml file
I am trying to access this controller
anyone with an idea why this is failing on deployed to tomcat?
15 Answers 15
I struggled with this problem many times.
The solution I am currently using is weather the webapp(or the folder where you kept the views like jsp) is under deployment assembly.
To do so Right click on the project > Build Path > Configure Build path > Deployment Assembly > Add(right hand side) > Folder > (add your jsp folder. In default case it is src/main/webapp )
You could also get this error after you did everything correct but on the JSP you put the anchor tag the old fashion(I am adding this incase if it help anybody else with the same issue).
I had the following syntax on the jsp. TakeMeToTheController and I kept seeing the error mentioned in the question. However changing the tag into the one shown below solved the issue.
If you are developing spring boot application add «SpringBootServletInitializer» as shown in following code to your main file. Because without SpringBootServletInitializer Tomcat will consider it as normal application it will not consider as Spring boot application
I’ve received the same error when working in a Spring Boot Application because when running as Spring Boot, it’s easy to do localhost:8080/hello/World but when you’ve built the artifact and deployed to Tomcat, then you need to switch to using localhost:8080//hello/World
Trying to run a servlet in Eclipse (right-click + «Run on Server») I encountered the very same problem: «HTTP Status: 404 / Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.» Adding an index.html did not help, neither changing various settings of the tomcat.
My environment: Eclipse Neon.3 Release 4.6.3, Tomcat-Version 8.5.14., OS Linux Mint 18.1.
I was facing the same issue and with some hint from @tadtab ‘s answer, I was able to figure out a solution for the same problem in my project.
1->Follow the steps mentioned in @tadtab’s answers.
2->Right Click on the project->Click on Properties->Search for Deployment Assembly.
3->Search whether your folder exists on the screen. (If not, add it).
4->On the screen you will find a ‘Deploy Path’ column corresponding to your source folder. Copy that path. In my case, it was /views.
5->So basically, in the setPrefix() method, we should have the path at the time of deployment. Earlier I was just using /views in the setPrefix() method, so I was getting the same error. But after, it worked well.
The same should be applicable to XML configuration also.
Ошибка Tomcat 404: исходный сервер не нашел текущее представление целевого ресурса или не желает раскрывать, что он существует
Я следил за учебником по o7planning и застрял на шаге 6:
Однако страница приветствия Tomcat отображается правильно.
Здесь решения, которые я пробовал до сих пор (и они НЕ работают):
Щелкните правой кнопкой мыши проект → Свойства → Границы проекта → Runtimes → отметьте «Apache Tomcat v9.0» → Применить → завершить.
Вкладка «Сервер» → Щелкните правой кнопкой мыши «Tomcat v9.0. » → properties → location location → Выберите «Использовать установку tomcat» на панели «Расположение серверов».
ОТВЕТЫ
Ответ 1
Проблема решена, я не добавил index.html. Что указывает на web.xml
Update:
Больше обновлений: у проекта может быть более одного файла «web.xml».
есть еще один «web.xml»,
Затем вам может потребоваться добавить еще один индекс (на этот раз index.jsp) в
Ответ 2
Надеюсь, это поможет. Из затмения вы щелкните правой кнопкой мыши проект → Run As → Run on Server, а затем он сработает для меня. Я использовал Eclipse Jee Neon и Apache Tomcat 9.0.:)
Исходный сервер не нашел текущего представления для целевого ресурса или не хочет раскрыть, что он существует при развертывании на кот
Я создал приложение, используя Spring с Eclipse IDE. Когда я запускаю проект из Eclipse IDE, все в порядке, но когда я упаковываю проект maven в файл war и развертываю его в отдельный tomcat, у меня возникает эта проблема
Это фрагмент конфигурации из моего файла XML
Я пытаюсь получить доступ к этому контроллеру
Кто-нибудь с идеей, почему это не удается развернуть на Tomcat?
8 ответов
Я получил ту же ошибку при работе в Spring Boot Application, потому что при запуске Spring Boot это легко сделать localhost:8080/hello/World но когда вы создали артефакт и развернули его в Tomcat, вам нужно переключиться на использование localhost:8080//hello/World
Если вы разрабатываете приложение для начальной загрузки, добавьте SpringBootServletInitializer, как показано в следующем коде, в ваш основной файл. Потому что без SpringBootServletInitializer Tomcat будет рассматривать его как обычное приложение, которое не будет считаться загрузочным приложением Spring
При попытке запустить сервлет в Eclipse (щелчок правой кнопкой мыши + «Запуск на сервере») я столкнулся с той же проблемой: «HTTP-статус: 404 /Описание: исходный сервер не нашел текущее представление для целевого ресурса или не хочет раскрыть, что он существует». Добавление index.html не помогло и не изменило различные настройки кота.
Моя среда: Eclipse Neon.3, выпуск 4.6.3, Tomcat-версия 8.5.14., ОС Linux Mint 18.1.
Решение одно: Измените версию Apache Tomcat (последняя версия предпочтительнее) (ручной процесс).
Решение второе: Установите последнюю IDE Eclipse и настройте сервер Apache Tomcat (внутренне автоматический процесс i, e eclipse обрабатывает часть конфигурации).
После успешной процедуры автоматического процесса, ручной процесс должен работать хорошо.
Я столкнулся с той же проблемой.
затем вручную выберите свой сервер. Это может помочь.
Почти ту же проблему можно решить, создав файл geoexplorer.xml в /opt/apache-tomcat-8.5.37/conf/Catalina/localhost содержимое файла geoexplorer.xml:
Tomcat error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
I have NOT worked on Java, SpringBoot and Maven a lot. I had gone through several posts for the issue mentioned above, but nothing was close to my scenario
I compile and package SpringBoot project using Maven with JDK1.8.0_172 on Windows 10
I then deploy this packaged war to Linux server ( RHEL with JDK1.8.0_201 and Tomcat 8 )
When I hit the URL http://localhost:8080/MyApp, tomcat errors and I don’t see anything wrong in Tomcat logs
I am not sure what I am doing wrong. Any help is highly appreciated
Error from Tomcat Server
POM.xml file
EDIT
I installed Tomcat 7 and was able to open the application. However, invoking some action on application throws ‘Something went wrong’
Looking into Tomcat logs it appears there’s some issue with DB connectivity
Error on Logs
Any help on this issue is highly appreciated
2 Answers 2
By default Tomcat disable loading Java driver file to prevent memory leak issue
This error simply means that there is no «code that handles» the request associated with the URL you type. Usually, tomcat doesn’t log these attempts, because they won’t really add any helpful information someone tried to access the resource that doesn’t exist, so what?
Check the context path under which the application gets deployed, maybe it’s not MyApp but something else?
Also check that your request is really valid (You issue the right HTTP method, send correct headers and so forth).
Last but not least, make sure that your controllers are indeed recognized by spring during the startup (you should see something like url is mapped to some info about the controller ) in the startup log of spring application.
Another possible reason is that the resource is protected and cannot be accessed without some sort of identification, like credentials. In this case check the security configurations as well (since its a very broad topic by its own, I don’t think I can be more specific in the context of this question).
How to troubleshoot HTTP 404 The origin server did not find a current representation for the target resource
Following a software demo on Skillsoft, I built a simple Spring MVC Demo app in Eclipse. The app loads fine and I can hit the home page («Hello World»). But when I try to hit my controller, I get the following error message
Type Status Report
Message /springMVCDemo/WEB-INF/jsp/quote.jsp
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
I’ve studied the following links that describe the same error, but I could not make my code work:
web.xml
myDemoApp-servletConfig.xml
MyDemoController.java
Quote.jsp
index.jsp
Directory Structure
What I’ve tried and the results
Result: Browser displays «Hello World!» as expected
Expected behaviour: One of three quotes gets displayed
Actual result: HTTP 404 + Eclipse console messages:
Result: As expected here, I got HTTP 404 since no such mapping exists. Also the following Eclipse console message was displayed:
In summary, I believe my controller is getting mapped correctly, but for some reason the page won’t get displayed 🙁
Software versions I am using
Eclipse 2018-09 (4.9.0); Tomcat v9.0
If anyone can provide some troubleshooting advice, it would be greatly appreciated. I’ve spent nearly 8 hours trying to tailor my servlet config file, but so far no luck.