Sathish Kumar
Sathish Kumar

Reputation: 2536

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

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

POM.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.htc.myapp.main</groupId>
  <artifactId>SpringProject</artifactId>
  <version>0.0.1-SNAPSHOT</version> 
  <properties>
    <java.version>1.8</java.version>
  </properties>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
  </parent>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>


<dependency>
<groupId>com.bmc.remedy</groupId>
<artifactId>remedyapi</artifactId>
<version>8.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/remedyapi-8.1.jar</systemPath>
</dependency>

    <!-- JSTL tag lib -->
    <dependency>
      <groupId>javax.servlet.jsp.jstl</groupId>
      <artifactId>javax.servlet.jsp.jstl-api</artifactId>
      <version>1.2.1</version>
    </dependency>

    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<!-- <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
</dependency> -->   

    <!-- Tomcat for JSP rendering -->
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <scope>provided</scope>
    </dependency>

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>


             <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>4.3.8.RELEASE</version>
</dependency>

 <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>
        </dependency>


    <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.8.5</version>
        </dependency>



            <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.3.1</version>
        </dependency>

    <dependency> 
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>

    <!-- <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.3.1</version>
        </dependency> -->
    <!--    
    <dependency> 
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency> -->



    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.3</version>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> 


<!-- <dependency> 
        <groupId>com.fasterxml.jackson.core</groupId> 
        <artifactId>jackson-databind</artifactId> 
        <version>2.5.3</version>  
</dependency>  -->



<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-client</artifactId>
    <version>1.19</version>
</dependency>

  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>



  </dependencies>

  <build>
  <finalName>MyApp</finalName>
    <plugins> 
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>


    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>

            </plugin>

     </plugins>

  </build>
  <procedure><packaging>war</packaging></properties>
</project>

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

2019-06-19 12:42:55.943 ERROR 20177 --- [bio-8080-exec-3] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.
java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433/MyDatabase;user=username;password=pwd

I copied jtds-1.3.1.jar to $TOMCAT_instance/lib directory and also tried used the following DB settings but NOTHING worked

db_LMS.url=jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433;databaseName=MyDatabase;integratedSecurity=true;user=username;password=pwd
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

        db_LMS.url=jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433/MyDatabase;user=username;password=pwd
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

Any help on this issue is highly appreciated

Upvotes: 1

Views: 27473

Answers (2)

Sathish Kumar
Sathish Kumar

Reputation: 2536

Added the following in $TOMCAT_HOME/conf/server.xml resolved the Issue

By default Tomcat disable loading Java driver file to prevent memory leak issue

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false" />

Upvotes: 1

Mark Bramnik
Mark Bramnik

Reputation: 42461

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).

Upvotes: 0

Related Questions