title: java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl cannot be cast to javax.net.ssl.HttpsURLConnection
body: <p>I tried this code in my Netbeans 7.4 and it works without problem</p>
  
  <pre><code>import java.io.IOException;
  import java.net.URL;
  import javax.net.ssl.HttpsURLConnection;
  
  public class JavaApplication148 {
      public static void main(String[] args) throws IOException {
          URL url = new URL("https://redmine.ackee.cz/time_entries.xml");
          HttpsURLConnection httpCon = (HttpsURLConnection) url.openConnection();
      }
  }
  </code></pre>
  
  <p>However then I used it in eclipse in my maven-driven project and it throws following exception :</p>
  
  <pre><code>java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl 
  cannot be cast to javax.net.ssl.HttpsURLConnection
  </code></pre>
  
  <p>This is following class in my maven project that throws an error</p>
  
  <pre><code>package cz.ackee.redmine.commands;
  
  import java.io.IOException;
  import java.net.URL;
  import javax.net.ssl.HttpsURLConnection;
  
  public abstract class RedmineCommand {      
      public void write(String xmlAddress, String text, String requestMethod) throws IOException{         
           URL url = new URL("https://redmine.xxx.cz/time_entries.xml");
           HttpsURLConnection httpCon = (HttpsURLConnection) url.openConnection(); //this line throws exception
      }       
  }
  </code></pre>
  
  <p>This is my pom.xml</p>
  
  <pre><code>&lt;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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;cz.ackee&lt;/groupId&gt;
      &lt;artifactId&gt;pan-unicorn-bot&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;Pan Unicorn Bot&lt;/name&gt;
      &lt;description&gt;Pan unicorn IRC Bot&lt;/description&gt;
  
    &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;apache-snapshots&lt;/id&gt;
      &lt;url&gt;http://repository.apache.org/snapshots/&lt;/url&gt;
    &lt;/repository&gt;
    &lt;/repositories&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.30&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.5.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-cli&lt;/artifactId&gt;
              &lt;version&gt;1.3-SNAPSHOT&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.taskadapter&lt;/groupId&gt;
              &lt;artifactId&gt;redmine-java-api&lt;/artifactId&gt;
              &lt;version&gt;1.23&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
    &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;version&gt;2.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                      &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                      &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.2.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;descriptors&gt;
                          &lt;descriptor&gt;/src/main/assembly/binary.xml&lt;/descriptor&gt;
                      &lt;/descriptors&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;make-assembly&lt;/id&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;single&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;index&gt;true&lt;/index&gt;
                          &lt;manifest&gt;
                              &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                              &lt;mainClass&gt;cz.ackee.unicorn.PanUnicornMain&lt;/mainClass&gt;
                          &lt;/manifest&gt;
                          &lt;manifestEntries&gt;
                              &lt;mode&gt;development&lt;/mode&gt;
                              &lt;url&gt;${project.url}&lt;/url&gt;
                              &lt;key&gt;value&lt;/key&gt;
                          &lt;/manifestEntries&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
  
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Any idea, why it does compile and run without problem on netbeans and why it does not go well on maven-eclipse project?</p>
  
  <p>(I compile through command line using <code>mvn package</code>, I run it through eclipse)</p>