简体   繁体   中英

Teamcity - package javax.servlet does not exist

How do I import javax.servlet in Teamcity? I have the below error message when I try to build the java project through teamcity IntelliJ IDEA runner.

Should I copy servlet-api.jar to the teamcity server and specify the path to the servlet-api.jar under Teamcity -> Build Configuration -> General Settings -> Artifact paths OR Teamcity -> Build Configuration -> Build Step: testStep -> Artifacts to Build?

This is my first time with teamcity and I'm using this https://github.com/marekbruchaty/SimpleJavaWebApp project. I have a CentOS server which has teamcity and gitlab.

From my desktop, using IntelliJ IDEA I can import servlet.api to do a successful build. But the teamcity is in another location and managed remotely and I wonder how to import the servlet-api into teamcity?

Here is the build error:

/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:1: package javax.servlet does not exist
import javax.servlet.ServletException;
                    ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:4: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:5: package javax.servlet.annotation does not exist
import javax.servlet.annotation.WebServlet;
                               ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:13: cannot find symbol
  symbol: class HttpServlet
public class FormServlet extends HttpServlet {
                                 ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:12: cannot find symbol
  symbol: class WebServlet
@WebServlet(name = "FormServlet")
 ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:14: cannot find symbol
  symbol:   class HttpServletRequest
  location: class FormServlet
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                          ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:14: cannot find symbol
  symbol:   class HttpServletResponse
  location: class FormServlet

Figured it out.

I had to paste the path to servlet-api.jar into Build Step -> Project SDKs -> JDK Jar files patters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM