Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 719

Maven build successful but compiled class files contain unresolved type errors

$
0
0

I have a project that compiles to WAR file, when I am using 'clean install' to build my project it is giving "Build Success", but when I decompile some files it is giving following lines in the decompiled file :

package service.auth;import FilterChain;import FilterConfig;import ServletException;import ServletRequest;import ServletResponse;import java.io.IOException;public class XSSFilter { public void init(FilterConfig paramFilterConfig) throws ServletException {    throw new Error("Unresolved compilation problems: \n\tFilterConfig cannot be resolved to a type\n\tServletException cannot be resolved to a type\n");  }  public void destroy() {    throw new Error("Unresolved compilation problem: \n\tThe method destroy() of type XSSFilter must override or implement a supertype method\n");  }  public void doFilter(ServletRequest paramServletRequest, ServletResponse paramServletResponse, FilterChain paramFilterChain) throws IOException, ServletException {    throw new Error("Unresolved compilation problems: \n\tServletRequest cannot be resolved to a type\n\tServletResponse cannot be resolved to a type\n\tFilterChain cannot be resolved to a type\n\tServletException cannot be resolved to a type\n\tThe constructor XSSRequestWrapper(HttpServletRequest) refers to the missing type HttpServletRequest\n\tHttpServletRequest cannot be resolved to a type\n");  }}

Although the source Java file contains proper imports, somehow the imports are not reflected correctly in decompiled file. Below are the imports of source Java :

import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;

The jar file needed "javax.servlet-api" is included correctly in the pom.xml and there is no compilation error also, somehow, after maven build the target folder that contains the war folder has these few issues, mainly related to servlet-api classes references only. I know it must be some silly mistake from my side but I am not able to find what.

PS : I also had to include "jakarta.servlet-api" jar in my pom.xml for some reason, also when I directly deploy the war to my jboss server via cleaning and restating the server it is working perfectly, and the application is also working.

Any one had this kind of error before? I just want a direction to think towards in order to resolve this. Thank you!!


Viewing all articles
Browse latest Browse all 719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>