2 Replies Latest reply on Nov 29, 2012 10:00 AM by Mike K

    Strange error in JBoss 7

    Mike K Newbie

      Hi All,

      I am having problem with running JBoss 7.1 and sunjce_provider.jar. When I invoke following code from spring service

      <code>

       

      private Key getKey() {

              if (key == null) {

                  Security.addProvider(provider);

                  File keyFile = null;

                  try {

                      keyFile = new File(keyPath);

                      ObjectInputStream in = new ObjectInputStream(new FileInputStream(keyFile));

                      key = (Key) in.readObject();

                      in.close();

                  } catch (Exception e) {

                      throw new EncryptionServiceException("getKey() : Failed to get cipher and key : " + e.getMessage(), e);

                  }

                  logger.debug("Key set from file at " + keyFile.getAbsolutePath());

              }

              return key;

          }

      </code>

       

      I get java.lang.ClassNotFoundException: com.sun.crypto.provider.DESKey on this line

      key = (Key) in.readObject();

       

      When I ran this code in Eclipse using JUnit - it was fine. I checked my jdk and sunjce_provider.jar is in <java_home>/jre/lib/ext. I really do not want to place sunjce_provider.jar into WEB-INF/lib. Any help will be greatly appreciated.