Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open url. please check this url is correct

I'm developing a very simple Java web app with Tomcat (Maven Project) in Intellij (Version 14.0.3).

When I compile and deploy the package (command: "mvn clean package: using Intellij) and then run the program I get a popup saying :

Cannot open url. Please check this url is correct. 

The URL is "http://localhost:8080/TimeDisplay/ShowTime.html".

Needless to say, when I try accessing this URL directly through the browser I get to the page I created.

Here are the relevant fields of the project's Run Configuration:

  • Application Server: Tomcat 9.0.0.M3

  • Open browser: After launch checked with Firefox as the chosen browser. The link is the same as the one I get in the error.

  • On 'Update' action: Restart server

  • On frame deactivation: Do nothing

  • Tomcat Server Settings:

  • HTTP port: 8080
  • JMX port: 1099

Under the deployment tab I added "TimeDisplay:war exploded" (TimeDisplay is the name of my project).

My pom.xml is as follows:

<project xmlns="removed link due to low stackoverflow reputation" xmlns:xsi="removed link due to low stackoverflow reputation"
 xsi:schemaLocation="removed link due to low stackoverflow reputation">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.amin</groupId>
  <artifactId>TimeDisplay</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>TimeDisplay Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.24.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.24.1</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>TimeDisplay</finalName>
  </build>
</project>

I'm also attaching a screenshot of my project's structure.

Project Structure

It's worth noting that I was able to run the program through Intellij at first and this issue suddenly popped out without any changes done by me. Currently I'm packaging my code and manually deploying it in Tomcat, which is horrendous!

like image 556
Aminov Avatar asked Dec 09 '16 19:12

Aminov


2 Answers

There are probably more reasons for not displaying the web page in the external web browser. In my case the problem is the way Idea is trying to detect the application is deployed.

My web application uses single sign on and when the request is being made with no authentication, the application redirects the user to the external site to log in. However IntelliJ Idea is probably trying to wait for 200 response and spams my application with numerous requests. Correct response of the application is 302 for unauthenticated user though. And when it does not happen in some specific time frame, Idea complains about not being able to display the page and it will not even try to open the browser.

like image 166
David Hladky Avatar answered Nov 19 '22 05:11

David Hladky


Ok I solved the issue. It seems that there is a bug in IntelliJ 14.0.3. I removed my Run Configuration and created it again with the same parameters, and it started working immediately. So as a workaround, recreating the configuration solves the issue.

like image 44
Aminov Avatar answered Nov 19 '22 07:11

Aminov