2
votes

I'm trying to create a simple test restful web service using intellij idea. I'm following this tutorial: https://medium.com/@jamsesso/starting-out-with-jersey-apache-tomcat-using-intellij-6338d93ffd40

But, i got some problems running it. Every time i go to localhost:8080/ after running it, it shows me error 404 and the message

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

. And, in intellij, there is a extense list of errors. I'll put the first one here:

13-Jan-2019 15:34:28.861 GRAVE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

At the beggining, it shows this:

F:\Java\apache-tomcat-9.0.13\bin\catalina.bat run
[2019-01-13 03:34:27,290] Artifact RestTeste:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\vitor\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_13_RestTeste"
Using CATALINA_HOME:   "F:\Java\apache-tomcat-9.0.13"
Using CATALINA_TMPDIR: "F:\Java\apache-tomcat-9.0.13\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_111"
Using CLASSPATH:       "F:\Java\apache-tomcat-9.0.13\bin\bootstrap.jar;F:\Java\apache-tomcat-9.0.13\bin\tomcat-juli.jar"

I think tomcat is maybe not with the right configs, but i couldn't find the ones that are wrong. I looked for environment variables and java version between intellij and tomcat, but i could say precisely if one of this was the problem. Java_home and catalina_home was set up to jdk folder and tomcat folder, respectively, and from what i saw, the versions were correct. I'm completely lost regarding this problem, and couldn't find any solution in more than 4 hours.

What could be the problem?

Am i missing some configuration step in tomcat or in intellij? I was reading the running.txt file inside of tomcat folder and followed the steps to configure it but no success.

Thanks a lot!

UPDATE: I tried to do other stuff so it's worth pointing out here. I tried the install through the .exe downloaded in apache tomcat website. It worked fine, i started it and at localhost:8080 it shows me the default tomcat page. I then went to intellij and added this new version of tomcat to my application servers, located in C:\Program Files\Apache Software Foundation\Tomcat 9.0. When i tried to run it, at first, it gave me the error that localhost was already in use, but i closed tomcat and tried again and it worked. At least, partially. It gives me the same errors than before and running only localhost:8080 gives me the message "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." again. I tried changing my jre_home variable to C:\Program Files\Java\jre1.8.0_191, as the answer from yan suggested, but it continued to show Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_111". If i echo %JRE_HOME% in cmd it will print the jre path, not the jdk one. Can you guys help me? To add the application server, i simply selected tomcat and the path to it. The initial text, again:

Using CATALINA_BASE:   "C:\Users\vitor\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_8_RestTest"
Using CATALINA_HOME:   "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_111"
Using CLASSPATH:       "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\tomcat-juli.jar"

An image of my envinroment variables:enter image description here

Update 2: here's a print of my running configurations, as requested:

enter image description here

2

2 Answers

2
votes

Make sure that you added your artifact(s) in the Deployment tab (see screenshot below)!

Run/Debug Configurations

After do this, you run your project and it should be ok.

0
votes
  • First some background on how Tomee works: Getting started with tomee.
  • Make sure tomcat is running in port 8080 and not somthing else, look at the tomcat cofig file(s) to find out where it should be running.
  • Make sure your firewall is not blocking it although if its port 8080 it shouldn't .
  • I've noticed that in the output: Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_111 - its the jdk not jre.
  • Another thing worth mentioning is that your app could deploy to something like: "localhost:8080/app_name" so try changing your running configurations in Intellij. The root URL of your app is determined in following tags in web/WEB-INF/web.xml:

    "servlet-name" and "url-pattern"

  • Make sure your Intellij build produces a .war exploded artifact - check your project setting under "artifacts".