Cannot resolve method close() on javax.servlet.ServletOutputStream

Hello IntelliJ Community.

I'm using the latest build of IntelliJ IDEA: 11.1.2 #IU-117.418
I have a maven based Java project which contains the following code snippet in a JAX-RS resource class: javax.servlet.http.HttpServletResponse response;
javax.servlet.ServletOutputStream stream = response.getOutputStream();

The close method is highlighted red in my editor, with the error message stating: "cannot resolve method close()"; however building the project using Maven 2 (both from within IDEA and standalone from the command line) does not produce any errors / warnings about the close method. (in fact the application runs just fine, as expected)

Using ctrl+click and the "scroll to source button" I've discovered that IDEA believes the classes listed in the code snippet above resolve to the following jars: [Maven: com.sun.jersey:jersey-core:1.6]
javax.servlet.http.HttpServletResponse [Maven:]
javax.servlet.ServletOutputStream [Maven:]

But there may be some confusion between what IntelliJ believes the resolution is and what the resolution actually is when Maven builds the my pom since ctrl+N ServletOutputStream produces the following list:

ServletOutputStream (javax.servlet) Maven:
ServletOutputStream (javax.servlet) Maven: org.glassfish:javax.servlet:3.0
ServletOutputStream (javax.servlet) Maven: javax.servlet:servlet-api:2.5

<dependency>      <groupId>com.sun.jersey</groupId>      <artifactId>jersey-server</artifactId>      <version>1.6</version> </dependency>
<dependency>      <groupId></groupId>      <artifactId>gwt-user</artifactId>      <version>2.4.0</version>      <scope>provided</scope> </dependency>
<dependency>      <groupId>javax.servlet</groupId>      <artifactId>servlet-api</artifactId>      <version>2.5</version>      <scope>provided</scope> </dependency>
<dependency>      <groupId>com.sun.jersey</groupId>       <artifactId>jersey-grizzly2</artifactId>       <version>1.6</version>       <scope>test</scope> </dependency>

Can you see what I'm missing? Is this an IntelliJ Maven bug or have I configured something incorrectly? Any help is greatly appreciated!

P.S. I've attempted to invalidate the caches and reimport maven projects, neither action had any affect on the unresolved method.

Comment actions Permalink


could you please create a minimal Maven project which reproduces the problem, and then create an issue in a tracker?

Comment actions Permalink

Hi Roman:

I'd like to, but I'm having trouble reproducing it in a sample project, are there any diagnostics I can generate from the offending project that would help you debug; short of including the project's source?


Comment actions Permalink

The method close() is inherited from - so does your IDEA project have a JDK configured? (you can check this in File | Project Structure | Project)

Comment actions Permalink

I believe I have my JDK configured correctly:


Comment actions Permalink

At a project level - yes, absolutely. Please check also that modules have correct SDK too.

Comment actions Permalink

I am experiencing the exast same problem except with the method write().  It seams to me that after upgrading from 10, IntelliJ does not recognize the methods found in the extended  I have followed the suggested resolution steps and have not had any sucess.

Comment actions Permalink

It appears I found the solution to my problem.

If I go into `Project Structure` --> `Module` --> `Dependencies` and move 'Maven:' below 'Maven:' then finds the close() method just fine.  If I move the gwt-user jar above the gwt-dev jar, then it give me the error.

Hope it helps.

Comment actions Permalink

Thanks Ben, your solution worked for me as well. Seems like this is a bug with the Intellij Maven integration, but without reproduceable steps; I'm not sure what to file. At least we have a hackey workaround for now.


Please sign in to leave a comment.