Link to home
Start Free TrialLog in
Avatar of kumvjuec
kumvjuec

asked on

Jars needed for HttpsURLConnection

hi,

Using HttpsURLConnection class gives me ClassDefNotFoundException. Can anybody tell which jars are needed here.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Why not just update your Java?
what is ur jdk version? can u do exception.printStaxktrace?
You probably have < 1.4 - upgrade!
Avatar of kumvjuec
kumvjuec

ASKER

It is 1.4.2
I found on net that it is inbuilt. But still I am getting
rootCause =
java.lang.NoClassDefFoundError: javax/net/ssl/HttpsURLConnection
HttpsURLConnection is being used inside an Action class and this webappl is running on Tomcat 5.0.25
If you're having runtime problems, then Tomcat is loading  < 1.4
I think it is runtime, because my files are compiling properly. Can you tell how can I solve this?
You need to ensure that Tomcat is started with >= 1.4 in its classpath
see CEHJ reply about the wrong jre beeing loaded.+#

see if in the tomcats config another java_home is specified
change your java_home environment variable and have it point to a jdk that's higher than 1.4 you most likely installed tomcat with an old jdk installed
;-)

is there an echo?
How do I find that which version the tomcat is using. afaik there has never been a version before 1.4 installed on my computer.

There is one other problem I have found - all https URLs are throwing MalFormedUrlException
But in Eclipse, when I am running the same code, the https URLs are also working.

Please help me how to configure Tomcat. My java_home is pointing towards c:\j2sdk1.4.2_04
I installed Tomcat again, and the same war file is working fine on the newly installed Tomcat. So this means that there must be some wrong configuration settings for Tomcat. Can you please help me what to change where in the older Tomcat so that it may work??
It's difficult to say without knowing your environment. JAVA_HOME you say is set to >= 1.4 but it doesn't seem to be behaving like that. You should be able to confirm the last point by printing the value of System property "java.vm.version" in a JSP/servlet
I don't know whether I have narrowed down the problem, but here is what I find.
When I start Tomcat from the taskbar's icon (Monitor Tomcat), then the https urls are working.
But when the same Tomcat is started from Eclipse (i am using tomcat plugin with default settings), then https urls throw malformedurlexception.
Please help me, there must be somthing different with the ways the two startups are taking place.
Doing System.getProperty gives me 1.4.2_04-b05
You'll have to trace the initialisation through in order:

>>When I start Tomcat from the taskbar's icon

see what the shortcut points to, then examine *it* and so  on ...
The code I am talking about is a single line

URL url = new URL("https://www.site.com");
OK - i've just done some investigation. IN my 1.4 installation, the HttpsUrlConnection classes are actually in jsse.jar. Are you perhaps missing that in your Tomcat classpath?
>>The code I am talking about is a single line

I'm talking about your environment, not your code. The code at this point is of no interest
>>IN my 1.4 installation, the HttpsUrlConnection classes are actually in jsse.jar.

That goes for 1.5 too, so i'd take a guess that all versions from 1.4 to 1.5 are the same. Look at the JRE jars
I found jsse.jar in the jre/lib directory

In case of "Monitor Tomcat"
JVM is C:\Program Files\Java\j2re1.4.2_04\bin\client\jvm.dll
Java Classpath is C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin\bootstrap.jar
Java Options are
-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.0
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 5.0

In Eclipse,
I have specified the same JVM
When I give bootstrap.jar in my classpath, Tomcat does not start.
I am just trying to give it the Java Options too
Try putting the full path to jsse.jar into the classpath. Quote it if it contains spaces
Thanks CEHJ, this has worked. :)
Last thing - can I just put this jar in some directory without specifying it in the classpath??

Thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks CEHJ, you have always solved my problem
8-)