1

The following is my web.xml

<web-app>
    <display-name>Kafka_APIs_LogManagement</display-name>
    <servlet>
        <servlet-name>myapplication</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.apis</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.scanning.recursive</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>myapplication</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <error-page>
        <error-code>404</error-code>
        <location>/Error_404.jsp</location>
    </error-page>

    <error-page>
        <error-code>500</error-code>
        <location>/Error_500.jsp</location>
    </error-page>

    <welcome-file-list>  
        <welcome-file>Error_404.jsp</welcome-file>  
        <welcome-file>Error_500.jsp</welcome-file>  
    </welcome-file-list>  

</web-app>

The following is my pom.xml

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.apis</groupId>
    <artifactId>my_APIs</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>my_APIs</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.10.68</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.2</version>
            <type>jar</type>
        </dependency> 


        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

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

<!--JERSEY DEPENDENCIES -- >

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.23.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.23.2</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-multipart</artifactId>
        <version>2.23.2</version>
    </dependency>

  <!--JERSEY DEPENDENCIES -- >  

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
            <type>jar</type>
        </dependency>




        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.4.2</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>myAPIS</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

The following is my method signature :

@POST
    @Path("/upload/{filename}/{type}")
    @Produces("application/json")
    @Consumes(MediaType.MULTIPART_FORM_DATA)

    public Response kafkaBulkProducer(InputStream a_fileInputStream,
                                      @PathParam("filename") String filename,
                                      @PathParam("type") String type,
                                      @Context ContainerRequestContext crc,
                                      @FormDataParam("file") InputStream fileInputStream,
                                      @FormDataParam("file") FormDataContentDisposition contentDispositionHeader)  {
}

and I am facing the following error :

[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response

If I remove both the @FormDataParam , it compiles perfectly and runs as expected, but If I introduce these two lines to my codes I get the error.

I have gone through the following links, but I did not able to solve my problem. Link

Thank you

Community
  • 1
  • 1
Salman Shaikh
  • 575
  • 1
  • 7
  • 24

0 Answers0