0

I'm currently trying to run a REST service for which I did the code of the services in java, and originally I was trying to get some client to test it. My problem right now is that the tomcat does not work with any path other than home (I do see the main page of tomcat, but whenever I try to access to any defined path I get a 404).

I've been trying this for several days, and I know there are a lot of posts about this because I've read a good amount of them, nevertheless, I don't know what I might be doing wrong, and at this point I would rather understand what is going on that simply fix it (not that I can right now anyway).

My configuration right now is: eclipse mars with tomcat 6, 7 and 8 currently installed (first I only had 6, but it didn't work so as I tried more options I installed more versions). I have maven 3.3.1 plugin, and what I currently do is: create a maven project, add whatever facets I need (I have some code servlets I did I'd like to test, but even a path to a helloworld is giving me a 404).

Then I right click maven install, then I try several things, all fail, main one that I think I should be doing is maven build with options deploy, so that the tomcat gets the war, and I can test the code. The problem is that when I manage to get a build success, I also get this message: 403

I don't really mind what option I use as long as I use it in some tomcat, locally, and I can test the rest service I'm trying to build

My current configuration (I've tried several, same result):

maven setting.xml

<server>
     <id>myTomcat</id>
     <username>admin</username>
     <password>admin</password>
 </server>
  </servers>

tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>

<role rolename="manager-script"/>
<user username="admin1" password="admin" roles="manager-script"/>
</tomcat-users>

Pom:

<plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <server>myTomcat</server>
        <url>http://localhost:8080/manager/html</url>
                    <path>/${project.build.finalName}</path>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

        </plugins>
monkey intern
  • 705
  • 3
  • 14
  • 34
  • You have the tomcat plugin. You can just run `mvn tomcat7:run` – Paul Samsotha Jun 07 '16 at 07:32
  • Do you get any error messages when you launch Tomcat? – Pascal Jun 07 '16 at 07:33
  • Not when running it but when I do the build, whichever it is, even though with some combination of configurations says builds success, currently I get a 403 forbidden @Pascal . – monkey intern Jun 07 '16 at 07:35
  • If you are getting a 403 then app runs, so that is not your problem. Your problem seems to be related to security, and the security configuration or how you are making the request. If you remove all security constraints, does it work? – Paul Samsotha Jun 07 '16 at 07:36
  • When I do run configuration, build, tomcat7:run as options, I get this @peeskillet java.lang.IllegalArgumentException: Document base C:\Users\redacted\workspace\proyect\src\main\webapp does not exist or is not a readable directory – monkey intern Jun 07 '16 at 07:36
  • That is part of the issue, the more I read the more people was saying how you had to configure this security option to get it running on tomcat 7 and whatnot, I really do not know how to get this to work, I just read several times that it was needed to configure a manager and so I tried to emulate it. – monkey intern Jun 07 '16 at 07:37
  • 1
    (Aside: the tag in settings.xml is for defining where to deploy the project **for Maven**. It won't run anything, it's so you can tell Maven where to store the project if it's used as a dependency in another one.) – Pascal Jun 07 '16 at 07:40
  • Is your project even set up as maven project, with maven structure? You might want to check [this out](http://stackoverflow.com/a/30020830/2587435) – Paul Samsotha Jun 07 '16 at 07:46
  • I had seen that post @peeskillet , not saying it doesn't work but it does not make me advance further, unfortunatelly – monkey intern Jun 07 '16 at 07:54
  • The problem @peeskillet is that although I looked into jersey to see if it was necessary, I'm not using it at the moment. I would to get this done but what I gathered was that it's not a requisite. And sorry I didn't answer in the previous message, my project is indeed maven and has a maven structure. – monkey intern Jun 07 '16 at 09:44

0 Answers0