0 Replies Latest reply on Jul 18, 2003 9:25 AM by Jason Boorn

    IllegalAccessError error on startup

    Jason Boorn Newbie


      I have an Mbean which starts up a simple socket listener. The listener uses SSL, and every so often it doesnt start up right. The error I get is the following:

      2003-07-18 11:19:28,069 ERROR [STDERR] java.lang.IllegalAccessError: try to access method com.sun.net.ssl.TrustManagerFactorySpi.engineInit(Ljava/security/KeyStore;)V from class com.sun.net.ssl.TrustManagerFactory
      2003-07-18 11:19:28,069 ERROR [STDERR] at com.sun.net.ssl.TrustManagerFactory.init([DashoPro-V1.2-120198])
      2003-07-18 11:19:28,069 ERROR [STDERR] at endogy.SocketListener.setSSL(SocketListener.java:62)
      2003-07-18 11:19:28,079 ERROR [STDERR] at endogy.SocketListener.run(SocketListener.java:287)
      2003-07-18 11:19:28,079 ERROR [STDERR] at java.lang.Thread.run(Thread.java:479)


      A sample of the code I'm using follows:

      public class SocketServer implements SocketServerMBean, Serializable {
      private static final Logger log = Logger.getLogger("SocketServer.class");

      static final int PORT=8686;
      private String JNDIName="";

      SocketListener currentListener;

      public void create() throws Exception {
      currentListener = new SocketListener(PORT);
      }

      public void start() throws Exception {
      currentListener.start();
      }

      public void stop() {
      currentListener.stop();
      }

      public void destroy(){
      currentListener = null;
      }

      }


      public class SocketListener implements Runnable, Serializable {

      ...

      public SocketListener(int port){
      //set up SSL
      java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
      ...
      }

      private void setSSL(){
      try {
      SecureRandom secureRandom = new SecureRandom();
      secureRandom.nextInt();

      KeyStore serverKeyStore = KeyStore.getInstance( "JKS" );
      serverKeyStore.load( new FileInputStream( "server.private" ), PASSWORD.toCharArray() );

      clientKeyStore = KeyStore.getInstance( "JKS" );
      clientKeyStore.load( new FileInputStream( "client.public" ), "public".toCharArray() );

      TrustManagerFactory tmf = TrustManagerFactory.getInstance( "SunX509" );
      tmf.init( clientKeyStore );

      KeyManagerFactory kmf = KeyManagerFactory.getInstance( "SunX509" );
      kmf.init( serverKeyStore, PASSWORD.toCharArray() );

      sslContext = SSLContext.getInstance( "TLS" );
      sslContext.init( kmf.getKeyManagers(), tmf.getTrustManagers(), secureRandom );

      SSLServerSocketFactory sf = sslContext.getServerSocketFactory();
      ss = (SSLServerSocket)sf.createServerSocket( port );
      }
      catch (Exception e){e.printStackTrace();}
      }



      }

      Any ideas?