0

When invoking a webservice deployed in a weblogic server I get a 404 - Not found error. Even after searching for similar questions in SO i wasn´t able to find a solution:

Rest Web services returning a 404

Java Restful Service eclipse tomcat HTTP Error 404

Restful Web Service returning 404, bad web.xml?

The resources are correctly deployed in the weblogic server as you can see from the following image:

enter image description here

I have the following code:

ServicesREST.java

package pt.vdf.nc.webproxy;

@Path("/NCProxyServices")
public class ServicesREST {

    public ServicesREST(){
        WebProxy.getAllInstances();
    }

    @Path("ManageShortNumber/{MSISDN}/{DestinationNumber}")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public Response manageShortNumberSMSIntegration(@PathParam("MSISDN") String terminal, @PathParam("DestinationNumber") Integer shortNumber) {
    (...)
   }

application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
    version="5">
    <description>WebApp builder and deployer</description>
    <display-name>ncwebproxy</display-name>
    <module>
        <web>
            <web-uri>ncwebproxy.war</web-uri>
            <context-root>/webproxy/</context-root>
        </web>
    </module>
    <library-directory>lib</library-directory>
</application>

web.xml

(...)

<security-constraint>
    <display-name>Administrators</display-name>
    <web-resource-collection>
        <web-resource-name>webproxy</web-resource-name>
        <url-pattern>/webproxy/*</url-pattern>
        <http-method>GET</http-method>
    </web-resource-collection>
 </security-constraint>

(...)

[EDIT] -> Added pom.xml below:

   <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>
    <artifactId>services-web</artifactId>
    <packaging>war</packaging>
    <name>services-web</name>
    <description>Services Web - WAR</description>

    <parent>
        <groupId>pt.vdf.nc.services</groupId>
        <artifactId>services</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../services</relativePath>
    </parent>

    <properties>
        <war.phase>package</war.phase>
        <install.phase>install</install.phase>
        <weblogic.version>10.3.6</weblogic.version>
    </properties>

    <profiles>

        <profile>
            <id>env-loc-wl</id>

            <properties>
                <war.phase>package</war.phase>
                <install.phase>install</install.phase>
            </properties>
        </profile>

        <profile>
            <id>env-loc-tc</id>

            <properties>
                <war.phase>none</war.phase>
                <install.phase>none</install.phase>
            </properties>
        </profile>

        <profile>
            <id>env-dev-wl</id>

            <properties>
                <war.phase>package</war.phase>
                <install.phase>install</install.phase>
            </properties>
        </profile>

        <profile>
            <id>env-tst-wl</id>

            <properties>
                <war.phase>package</war.phase>
                <install.phase>install</install.phase>
            </properties>
        </profile>

        <profile>
            <id>env-ath-wl</id>

            <properties>
                <war.phase>none</war.phase>
                <install.phase>none</install.phase>
            </properties>
        </profile>

        <profile>
            <id>env-prd-wl</id>

            <properties>
                <war.phase>package</war.phase>
                <install.phase>install</install.phase>
            </properties>
        </profile>
    </profiles>

    <build>
        <finalName>ncservices</finalName>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>cfg/services-cfg.properties</include>
                    <include>ctx/*</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-war</id>
                        <phase>${war.phase}</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-install</id>
                        <phase>${install.phase}</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <artifactId>services-common</artifactId>
            <groupId>${project.groupId}</groupId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.22.1</version>
</dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <version>2.22.1</version>
    </dependency>

        <dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.22.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.22.1</version>
</dependency>
        <dependency>
            <groupId>com.oracle.weblogic</groupId>
            <artifactId>weblogic</artifactId>
            <version>${weblogic.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.timesten</groupId>
            <artifactId>ttjdbc6</artifactId>
            <version>11.2.1.6.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle.weblogic</groupId>
            <artifactId>wlclient</artifactId>
            <version>${weblogic.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>
        <dependency>
            <groupId>com.wordnik</groupId>
            <artifactId>swagger-core_2.10</artifactId>
            <version>1.3.11</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>2.9.0</version>
        </dependency>
    </dependencies>
</project>

I tried a variety of different url patterns to try and invoke the service successfully but i keep getting the error 404.

http://localhost:7001/webproxy/NCProxyServices/ManageShortNumber/9842987982/97668/
http://localhost:7001/pt.vdf.nc.webproxy/webproxy/NCProxyServices/ManageShortNumber/9842987982/97668/
http://localhost:7001/NCProxyServices/ManageShortNumber/9842987982/97668/

Would you kindly point me in the right direction to successfully invoke this service.

Thank you for your time

Daniel André
  • 1,158
  • 1
  • 12
  • 28
  • I see no class that extends `javax.ws.rs.core.Application`, no Jersey configuration in your web.xml at all? (edit: removed the reference to a `beans.xml`, I see Spring is used) – Gimby Dec 11 '15 at 12:28
  • See in your logfiles if you have deployment problems – Jens Dec 11 '15 at 12:28
  • @Gimby Jersey configurations exist on the pom.xml which I added to my question. Not sure what you mean by "I see no class that extends javax.ws.rs.core.Application" – Daniel André Dec 11 '15 at 12:57
  • @Jens The deployment was completed successfully with no errors or problems. – Daniel André Dec 11 '15 at 12:58
  • 1
    @DanielAndré the jersey user guide is rather specific. https://jersey.java.net/documentation/1.19/jax-rs.html#d4e186 – Gimby Dec 11 '15 at 13:01
  • Might remove the * from your url-mapping in web.xml; this thread may shed more light: https://stackoverflow.com/questions/26732/invalid-url-pattern-servlet-mapping-in-tomcat-6-0/26744#26744 – Boris Dec 22 '15 at 19:58

1 Answers1

0

I see you are using @Consumes(MediaType.APPLICATION_JSON) but reading the parameter using @PathParam and not from JSON format. Also I see @Produces(MediaType.APPLICATION_JSON) but the method return type is Response. Can you try removing these two annotations. And in case you need to handle JSON requests/responses you need to specify JSON library for encoding & decoding. Not sure if you have taken care of that already.

  • Thank you for your answer. Unfortunately removing the two notations made no difference. As for handling JSON requests/responses, it's not an issue. – Daniel André Dec 11 '15 at 14:49
  • Could you please post the complete web.xml file. – Madhusudana Reddy Sunnapu Dec 11 '15 at 16:19
  • By the way, normally 7001 is the admin port of weblogic and managed server port is 8001, although you could configure these port numbers. Just thinking should we try with 8001 - http://localhost:8001/webproxy/NCProxyServices/ManageShortNumber/9842987982/97668/ – Madhusudana Reddy Sunnapu Dec 11 '15 at 16:57