• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot find javax/crypto/spec/SecretKeySpec class inTomcat 6

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a simple module to log into MS SQL. It works when I run it as a standalone program. When I add it to Tomcat 6 as servlet code I get:

java.lang.NoClassDefFoundError: javax/crypto/spec/SecretKeySpec

This class is in the jce.jar. I'm not sure what I'm doing wrong. The code is included.

Thanks,

Chuck

package com.example.web;


import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
import java.*;
import java.sql.*;
import javax.crypto.spec.SecretKeySpec;

public class SoitLogon extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{

response.setContentType("text/html");
PrintWriter out = response.getWriter();




DB db = new DB();
String ret = db.dbConnect(
"jdbc:sqlserver://localhost:1433","sa","931900");

out.println("return value = " + ret);

}

class DB
{
public DB() {}

public String dbConnect(String db_connect_string,
String db_userid, String db_password)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);
return "connected";

}
catch (Exception e)
{
e.printStackTrace();
return e.getMessage();

}
}
}
}



 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you put jce,jar?
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is under Tomcat6.0/lib.

I also extracted the jce.jar file. It is under Tomcat6.0/lib/javax/crypto/spec/SecretKeySpec.class.

I also put the class under the classes directory of the servlet where my code class resides.

I thought putting it under the Tomcat6.0/lib directory would have worked.

Chuck
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chuck Dial wrote:It is under Tomcat6.0/lib


That will do it.

All the other stuff you did will not work. Undo it.

Are you sure that the class file is in the jar file?
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear,

I didn't say thanks before, so thanks for helping. I did a jar -tf jce.jar and the class showed up in the list as javax/crypto/spec/SecretKeySpec.class.

I also did the extraction earlier to verify the class was there.

I'm at a loss on what to do next. I've been spinning my wheels for 2 days.

Thanks,

Chuck
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never heard of Tomcat not finding a class in a properly deployed jar.

Move the jar to your app's WEB-INF/lib, just as a test.

Also, post the entire stack trace. Use code tags to preserve formatting.
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With code tag. Never used them before.

New, shorter, code. Still get same SecretKeySpec error. Not sure why I get this error. I included the code and the trace that appeared on the IE screen.



Trace:

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoClassDefFoundError: javax/crypto/spec/SecretKeySpec
com.sun.net.ssl.internal.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:384)
com.sun.net.ssl.internal.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:367)
com.sun.net.ssl.internal.ssl.CipherSuite.isAvailable(CipherSuite.java:143)
com.sun.net.ssl.internal.ssl.CipherSuiteList.buildAvailableCache(CipherSuiteList.java:210)
com.sun.net.ssl.internal.ssl.CipherSuiteList.getDefault(CipherSuiteList.java:233)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.init(SSLSocketImpl.java:508)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:479)
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:92)
com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1368)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:207)
com.example.web.SoitLogon.doPost(SoitLogon.java:21)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Chuck
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear,

I added code tags to my prior post.

Chuck
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try moving it to WEB-INF/lib to see what happens?
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,

C:Apache Software Foundation/Tomcat6.0/webapps/SoitProcess/WEB-INF/lib/jce.jar

I had to create the lib directory. I didn't mention it but I'm running under Vista if that makes a difference.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It shouldn't make a difference. And at this point, I've got nothing. I've never heard of Tomcat not finding a valid class in a jar placed in one of the proper locations.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try removing the file jce.jar from Tomcat altogether. Starting with Java 5, JCE is part of the core JRE, and does not need to be added separately.
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I removed Tomcat 6 and loaded Tomcat 5.5.28. I can now access the database with the same code. I think there is either an issue with the way I loaded Tomcat 6 or there may be a bug in Tomcat 6. Either way, I can move forward. Thanks for your help.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
It will give me the powers of the gods. Not bad for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic