ClassCastException using HttpsURLConnection with Tomcat 4.1.27

Hi,
I try to open an SSL connection using HttpsURLConnection that works fine with a standalone application (see code fragment):
import javax.net.ssl.HttpsURLConnection;
import java.net.*;
import java.io.*;
URL website = new URL( "https://aSampleSSLSite" );
HttpsURLConnection connection = ( HttpsURLConnection ) website.openConnection();
Using the same code in Tomcat 4.1.27 and Struts 1.1 throws a java.lang.ClassCastException while trying to use website.openConnection().
What is the difference?

Hi,
I'm using JDK 1.4.2 and haven't installed JSSE separately at all. Actually I really use javax.net.ssl.HttpsURLConnection. However, I tried com.sun.net.ssl.HttpsURLConnection as well and got a 'java.net.SocketException: Default SSL context init failed' instead of.
Oddly enough the code works fine in a standalone application.

Similar Messages

  • Adv. of using apache with tomcat??

    can anyone pl tell me the advantages of using Apache with Tomcat in comarison to other web servers?
    Thanks

    The biggest advantages are that they are open source, so you don't have to pay a huge licence fee, and they are very stable. I don't know how they compare for speed - I know Apache is lightning when it comes to serving flat pages, there are no benchmarks yet for the new Tomcat because it was only released last monday. You can run them on linux or another unix variant, so they are more likely to be secure (windows servers are horrendously open to attack) and stable.

  • How to use JMS with tomcat and Axis

    Hello
    I'm new in ii, so i'm still a little bit lost. I have been implementing web services with tomcat and Axis. However, these services are synchronous and I would like that some services were asynchronous.
    I've been reading about the topic and I've found that JMS is a good solution for it. I have already downloaded JMS in my computer but now I don't know what else to do. I've been trying to run the SimpleQueueSender.java example but I get the error:
    JNDI API lookup failed: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    But I have attached all .jar from F:\Sun\MessageQueue\lib
    In addition to this, for my first webservices I used the Java2WSDL, WSDL2Java and AdminClient (axis tool) to create my web services bindings, stubs and skeletons and to deploy the web service on the server. Do I have to use them now with JMS? or now the deployment must be performed in a different way?
    Thank you in advanced,

    The error means that you have to specify the type and location of your jndi store. You could create a jndi.properties file and put two properties in it:
    java.naming.provider.url=file\\\:////var/jndi
    java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
    for a file based jndi store. Then you have to make sure your jndi.properties file is in your CLASSPATH. Then you have to use something like imqadmin to create your jndi store and store in it your administrative objects like Queues and QueueConnectionFactories.

  • Using Eclipse with Tomcat

    I'm trying to get eclipse to work correctly with tomcat server. but when i create a project it creates it in my workspace folder and i can't run it on the server.
    I assume it has to create the project in the tomcat root directory in order for it to run properly but i don't know how to get eclipse to do this.
    Any help would be appreciated.

    What I use to do is
    File -> Export -> War File and it generates a war file. You set that war file in the webapps directory of tomcat and it self extracts the files in order to be used from the navigator

  • Use JSTL with Tomcat 4.1.x

    Hi,
    I've had a look at various tutorials and documentation and must be missing something obvious.
    I haven't been using them before so what do I need to add to Tomcat to make it work.
    So far I've put a JSP file in with this:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <c:redirect url="welcome.html"/>
    When I run it I get this error:
    org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
    I expect I have to put a JAR or a TLD file somewhere. If so, could someone tell me what and where.
    Thanks

    Download the source from the link that you got the jar from. The tld's are in there. What I do is put the tld's in a tld folder in WEB-INF. Then I change the web.xml file to reflect this.
    <taglib>
        <taglib-uri>/tags/core</taglib-uri>
        <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>Then I change the uri to point to the tld's on my server instead of sun's server in my jsp, like this:
    <%@ taglib uri="/tags/core" prefix="c" %>it points to the uri in my web xml

  • Using ADF with Tomcat - A total beginner, lost

    Hi all,
    I am a complete beginner in Java using jDevaloper and java for web. I have being a desktop programmer. So I followed the jdeveloper tutorial Developing Rich Web Applications With Oracle ADF up to here . The small deference in my project is that it uses a mySQL database. When I tried to Run the project the Java SE crashed and the weblogic domain was not built. I tried many methods mentioned in the web but the Java keeps on crashing. I tried using both bundled JDK and JDK avilable in my machine but the crash continuous. So I decided to use tomcat.
    So I have came up to creating the .war file. But when I started the tomcat I got this error;
    SEVERE: Error configuring application listener of class oracle.adf.mbean.share.config.ADFConfigLifeCycleCallBack
    I have gone out of choices. How should I correct this.
    Thanks [Dana Singleterry|https://blogs.oracle.com/dana/entry/how_to_deploy_a_11g_adf_applic_1] , [Terry Cho|http://javamaster.wordpress.com/category/java-programming/] and many others for their knowledge sharing.

    hi manjulapra
    manjulapra wrote:
    ... So I decided to use tomcat. ...The "Application Servers " section of the "Certification and Support Matrix " for "Oracle JDeveloper and Application Development Framework 11g Release 2 "
    at http://www.oracle.com/technetwork/developer-tools/jdev/jdev11gr2-cert-405181.html#Application_Servers
    currently has for "Tomcat 6 " and "ADF " the value "Not Supported ".
    regards
    Jan Vervecken

  • Problem when using Logger with Tomcat and eclipse

    Hi, Iam using Tomcat 5.5.7 and my IDE is eclipse.Iam using java.util.logging.Logger class for logging.Iam putting the properties file in Appname/WEB-INF directory.The properties file is not identified.The error Iam getting is Error initialising log file java.lang.NullPointerException and java.io.FileNot FoundException
    The content of my logging.properties file is
    java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=SEVERE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    java.util.logging.FileHandler.level=ALL java.util.logging.FileHandler.pattern=%h/javalogs%u.log java.util.logging.FileHandler.append=true java.util.logging.FileHandler.count=1
    My servlet is
    import java.io.*;
    import java.util.logging.*;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldServlet extends HttpServlet
          public void init(ServletConfig config) throws ServletException
               try
                         String file=getServletConfig().getInitParameter("java.util.logging.config.file");
                        InputStream is = getServletContext().getResourceAsStream(file);
                        LogManager.getLogManager().reset();
                          LogManager.getLogManager().readConfiguration(is);
               catch(Exception e)
                    System.out.println("Error initialising log file"+e);
          public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
                   final Logger fLogger =
                 Logger.getLogger(HelloWorldServlet.class.getName());
                 PrintWriter  out; 
                 String title = "Simple Servlet Output";
                // set content type and other response header fields first                                   
                // then write the data of the response
                 response.setContentType("text/html");
                 fLogger.finest("this is finest");
                 fLogger.finer("this is finer");
                 fLogger.fine("this is fine");
                 fLogger.config("this is config");
                 fLogger.info("this is info");
                 fLogger.warning("this is a warning");
                 fLogger.severe("this is severe");
                 out = response.getWriter();
                out.println("<P>This is output from SimpleServlet!!!!!!!!.");  
    }My web.xml file is
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <init-param>
         <param-name>java.util.logging.config.file</param-name>
         <param-value>/WEB-INF/classes/logging1.properties</param-value>
        </init-param>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>HelloWorldServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
      </servlet-mapping>
    </web-app>Can anybody help me out.

    Hi, Iam using Tomcat 5.5.7 and my IDE is eclipse.Iam using java.util.logging.Logger class for logging.Iam putting the properties file in Appname/WEB-INF directory.The properties file is not identified.The error Iam getting is Error initialising log file java.lang.NullPointerException and java.io.FileNot FoundException
    The content of my logging.properties file is
    java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=SEVERE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    java.util.logging.FileHandler.level=ALL java.util.logging.FileHandler.pattern=%h/javalogs%u.log java.util.logging.FileHandler.append=true java.util.logging.FileHandler.count=1
    My servlet is
    import java.io.*;
    import java.util.logging.*;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldServlet extends HttpServlet
          public void init(ServletConfig config) throws ServletException
               try
                         String file=getServletConfig().getInitParameter("java.util.logging.config.file");
                        InputStream is = getServletContext().getResourceAsStream(file);
                        LogManager.getLogManager().reset();
                          LogManager.getLogManager().readConfiguration(is);
               catch(Exception e)
                    System.out.println("Error initialising log file"+e);
          public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
                   final Logger fLogger =
                 Logger.getLogger(HelloWorldServlet.class.getName());
                 PrintWriter  out; 
                 String title = "Simple Servlet Output";
                // set content type and other response header fields first                                   
                // then write the data of the response
                 response.setContentType("text/html");
                 fLogger.finest("this is finest");
                 fLogger.finer("this is finer");
                 fLogger.fine("this is fine");
                 fLogger.config("this is config");
                 fLogger.info("this is info");
                 fLogger.warning("this is a warning");
                 fLogger.severe("this is severe");
                 out = response.getWriter();
                out.println("<P>This is output from SimpleServlet!!!!!!!!.");  
    }My web.xml file is
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <init-param>
         <param-name>java.util.logging.config.file</param-name>
         <param-value>/WEB-INF/classes/logging1.properties</param-value>
        </init-param>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>HelloWorldServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
      </servlet-mapping>
    </web-app>Can anybody help me out.

  • Using JavaMail with Tomcat and JNDI

    I have a web application and I want to make use of JNDI Mail Sessions for sending email in my Web Appln.
    I am using Tomcat4.0.1
    In my server.xml file I declared a resource as follows:
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
    <ResourceParams name="mail/Session">
         <parameter>
         <name>mail.smtp.host</name>
         <value>mail.abc.com</value>
         </parameter>
    </ResourceParams>
    Now Inside my jsp/servlet code i can use something like this:=
    // Acquire our JavaMail session object
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    Session session = (Session) envCtx.lookup("mail/Session");
    // Prepare our mail message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    InternetAddress dests[] = new InternetAddress[]
    { new InternetAddress(to) };
    message.setRecipients(Message.RecipientType.TO, dests);
    message.setSubject(subject);
    message.setContent(content, "text/plain");
    // Send our mail message
    Transport.send(message);
    But my smtp mail provider uses Authentication.
    So I am looking of some way wherein I can provide the user and password information in the server.xml file itself along with smtp provider.
    My Query is How to do this as i dont see any references for using JavaMail sessions using Authentication
    Any Help highly appreciated
    Thanks
    Raj

    Isnt there anyone who can answer this question or its not a question worthwile
    Awaiting reply
    ...

  • Using mod_rewrite with mod_jk2

    Hi, recently i posted a query about how to manipulate url in tomcat. I'd found out that Apache server do have this mod_rewrite that allow URL to be manipulated before the server starts to look for the destination pages. But since my apps are running in Tomcat (it's servlets), is it possible that i use the mod_rewrite to change my URL that point to the web-apps in Tomcat? The scenario is:
    1) i have a servlet that sits inside Tomcat with /abc as the directory. Thus the URL that i can use to call it with Apache linked to Tomcat is:
    http://111.111.111.111/abc/myServlet
    2) Becoz of some external constraint i need to use a URL with the below format to call that servlet:
    http://111.111.111.111/234/aaa/bbb/ggg/hhh/abc/myServlet
    So is it possible for me perform this task???
    Thanks in advance.

    hi
    i am facing same kind of problem i using servlet with tomcat.using path
    http://192.168.0.112:8081/servlet/DispatcherServlet.can hide this path from address bar.

  • JNDI with tomcat (newbie)

    Hi,
    I'm fairly new to java and trying to setup apache jackrabbit using JNDI with tomcat. My problem is that my servlet receives a org.apache.jackrabbit.core.jndi.BindableRepository instead javax.jcr.Repository. It seems as if it doesn't matter what is written in my web.xml nor context.xml. Any tips is most appretiated (but I guess it s just my lack of knowledge that is causing the problem).
    Server.xml
    <GlobalNamingResources>
         <Resource name="jcr/globalRepository" auth="Container" type="javax.jcr.Repository" factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory" configFilePath="C:/Development/Eclipse/Workspace/iKvittoPlatform/iKvittoRepository/repository.xml" repHomeDir="C:/Development/Eclipse/Workspace/iKvittoPlatform/iKvittoRepository" />web.xml
        <resource-env-ref>
              <description>Content Repository</description>
              <resource-env-ref-name>jcr/repository</resource-env-ref-name>
              <resource-env-ref-type>javax.jcr.Repository</resource-env-ref-type>
        </resource-env-ref>context.xml (in WEB-INF)
         <ResourceLink name="jcr/repository" global="jcr/globalRepository" type="javax.jcr.Repository" />My servlet
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.jcr.Repository;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class for Servlet: JcrDemoServlet
    public class JcrDemoServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
        /* (non-Java-doc)
          * @see javax.servlet.http.HttpServlet#HttpServlet()
         private static final long serialVersionUID = (-1L);
         /* (non-Java-doc)
          * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              doPost(request, response);
              // TODO Auto-generated method stub
         /* (non-Java-doc)
          * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              PrintWriter writer = response.getWriter();
              writer.println("SERVLET JNDI");
              try
                   InitialContext ctx = new InitialContext();
                   Context localContext = (Context) ctx.lookup("java:comp/env");
                   //writer.println(localContext);
                   Object repository = localContext.lookup("jcr/repository");
                   if(repository instanceof Repository)
                        writer.println("SUCCESS");
                   else
                        writer.println("FAILURE");
                        writer.println(repository.getClass());
              catch(Exception e)
                   writer.println("EXCEPTION");
                   writer.println("<p><pre>");
                   e.printStackTrace(writer);
                   writer.println("</p></pre>");
              writer.close();
              // TODO Auto-generated method stub
    }

    exactly what are you trying to do with jndi & tomcat?

  • Using Java Logging with Tomcat

    Hi in a previous non Tomcat project I wrote some classes that used the java.util.logging library that comes with java 1.4 quite successfully. I am now trying to use the same classes with Tomcat 5.0 but it doesnt like it. With the logging classes you can provide a configuration class which you define with a property "java.util.logging.config.class", I put the class in my WEB_INF\classes with all the other classes.
    When I run with Tomcat i have a servlet that does the following to try and initilse the logging
    com.appserver.util.logging.LogProperties.setLevelFromParametersFromPrefs();
    System.getProperties().setProperty("java.util.logging.config.class", "com.appserver.util.logging.LogProperties");
    LogManager.getLogManager().readConfiguration();
    it complains it cant find the class, when running readConfiguration(), (The 1st two lines run ok). I think the problem is to do with Tomcat classloader, with a simple Java application the classes would be expected to be on the system classpath, but on Tomcat the system classpath only contains bootstrap.jar.
    I realise I could probably get things working using Apaches log4j instead but it seems a bit silly to use that when there is a perfectly adequate logger built into the language now.
    Anyone done this ?

    OK
    Ive changed my code from
    com.appserver.util.logging.LogProperties.setLevelFromParametersFromPrefs();
    System.getProperties().setProperty("java.util.logging.config.class", "com.appserver.util.logging.LogProperties");
    LogManager.getLogManager().readConfiguration();to
    com.appserver.util.logging.LogProperties.setLevelFromParametersFromPrefs();
    LogManager.getLogManager().readConfiguration(com.appserver.util.logging.LogProperties.getPropertiesAsStream());Now I dont get any errors and only messages for the LEVEL is set to the value I specify in my LogProperties class are displayed. However I also specify a Formatter to use for console output but Tomcat just seems to ignore it and uses its own default formatter. Any ideas...please !

  • Tutorial on using client cert with Tomcat 5

    Hello,
    I'm looking for a tutorial on using client-cert method with tomcat 5.0.28 with jsp pages.
    I want to generate my own certs and keys.
    Is there anything like this on the web ?
    Thanks

    Maybe you could try searching the Tomcat mail archives or post your question to one of their mailing lists.
    http://jakarta.apache.org/site/mail.html

  • I want to use hibernate with the tomcat

    I want to use hibernate with the tomcat server can it be possible and if yes then what is the stepwise way.
    Infact I know the java JSF but want to command on Hibernate plz help me.
    I'll be thankful to you.

    To be honest, I wouldn't even know where to start. Do you know what Hibernate does and how it works? Do you know how Tomcat works? All you'd need to do to combine those two would be to let Tomcat provide the DB connections for Hibernate, I suppose. Neither of those products are a topic of this board though.

  • ClassCastException in HttpsURLConnection

    I try to connect to https://verisign.com using HttpsURLConnection..and i get :
    Exception in thread "main" java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl
         at URLReader.main(URLReader.java:22)
    code:
         java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
         System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
         System.setProperty("javax.net.ssl.trustStore","/home/httpd/servlets/cacerts");
    URL verisign = new URL("https://www.verisign.com/");
    HttpsURLConnection cx =(HttpsURLConnection)verisign.openConnection();
         BufferedReader in = new BufferedReader(
         new InputStreamReader(verisign.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    Is this problem connected with wrong certificate?
    But why is it a CastException?
    Please help thanks.

    Had this one.
    You probably use the new class:
    javax.net.ssl.HttpsURLConnection and verisign uses
    older com.sun.net.ssl.HttpsURLConnection.

  • How can I use LDAP for Tomcat authentication ?

    Hi
    I have an implementation of apache 1.3.20 with tomcat 3.2.3. I an doing
    auth. with a ldap server wihich works prefectly with apache
    mod_auth_ldap (module). When i am trying to read the environment
    variables with a cgi , REMOTE_USER returns me the authentificated user
    but when i am doing a getremoteuser() in my servlet with tomcat , it
    returns NULL Why ?
    I came accross this page when looking for material and
    http://www.peacetech.com/java/files/apache/tomcat/
    did the following
    1) Downloaded - jndi_auth_beta1.jar, Extracted jndi_auth.jar file which contained
    class files and plcaed them inside my tomcat/lib directory
    2) Then i have updated the server.xml file of my Tomcat, that i wanted to use LDAPRealm
    <RequestInterceptor className="com.peacetech.webtools.tomcat.LdapRealm"
    debug="1"
    directoryUrl = "ldap://csee.usf.edu:389"
    searchBaseContext = "o=usf.edu"
    searchFilter = "uid={0}"
    searchScopeAsString = "sub"
    securityAttributes = "securityEquals"
    attributesReadByOwner = "true"
    connectionMaxPoolSize = "10"
    ldapVersion = "3" />
    Then i had shutdown and restarted the server after some initial hickups, then i have tried to open some sample JSP and sevlets in the examples directory of my server. But i was not asked for any UserId/Password. Was wondering if i have done anything wrong ??
    Thanks
    Arun

    Maybe you should look at JAAS for that. I think it could help you.
    http://java.sun.com/products/jaas/
    C

Maybe you are looking for

  • Can we create a view involving a standard table and a ZTable ?

    Hi, I created a view based on 2 tables : EKKO and a Ztable having EBELN field in common. Now, when i try to create a PO in ME21N , this view should get updated.But,It doesn't happen so. So i want to confirm that is it not possible to create a view on

  • RMAN for active passive 10g R2 RAC

    Hi, I am having 10g R2 Active-Passive RAC setup. in this environment,If I am taking the backup using RMAN, how can I handle the failover? In active-active instance, if channel allocated to one node is failed, backup will be completed from channel all

  • Toshiba USB VoIP Phone PX1214E-1UPH

    I bought a toshiba voip phone PX1214E-1UPH that was supplied with an application cd. The matter is that the cleanning laday sent the box with this cd inside it, to the garbage. As you understant, i've lost it. I've also turned the internet upside dow

  • Reg:where will the comments in tcode pa30 maintained

    Hi All, I have a requirement where I need to get the comments maintained for the info type 0019 in the tcode pa30. I have placed the cursor on the field and pressed F1 help to see the table in which these comments are stored.But these comments are ma

  • How to make a shadow

    how can i make a shadow in a panel when the mouse is over? the panel has an image an this has to appear with the shadow thanks