5 Replies Latest reply: Aug 30, 2011 7:19 PM by 881648 RSS

    Passing Virtual Machine Arguments while calling a .jar file.

    881648
      I am looking for a batch command that can execute execute a .jar file with Vitrual Machine Arguments.

      The following are the parameters that need to passed in.

      -Djavax.net.ssl.keyStore=NONE
      -Djavax.net.ssl.keyStoreType=PKCS11


      I have tried the following command. But it is not working

      java -Djavax.net.ssl.keyStore=NONE -Djavax.net.ssl.keyStoreType=PKCS11 -jar c:\temp\LoginTF.jar

      Any help is greatly appreciated,
      Soma Reddy
        • 1. Re: Passing Virtual Machine Arguments while calling a .jar file.
          Kayaman
          878645 wrote:
          java -Djavax.net.ssl.keyStore=NONE -Djavax.net.ssl.keyStoreType=PKCS11 -jar c:\temp\LoginTF.jar
          java -Djavax.net.ssl.keyStore=NONE -Djavax.net.ssl.keyStoreType=PKCS11 -cp c:\temp\LoginTF.jar com.foo.MainClass

          That'll work at least.
          • 2. Re: Passing Virtual Machine Arguments while calling a .jar file.
            881648
            Thanks for the quick response. Based on the exception, it seems to be problem is not in finding the MainClass. It was not able to look into the Keystore.
            If run through Eclipse IDE or use Ant script it runs fine and prompts me for CAC pin.

            This is how Ant build script looks for VM parameters

            ScriptBegin==================================

            <java classname="com.collab.examples.LoginTF" fork="true">

                 <jvmarg value="-Xdebug" />
                      <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5432" />
                 <jvmarg value="-Djavax.net.ssl.keyStore=NONE" />
                      <jvmarg value="-Djavax.net.ssl.keyStoreType=PKCS11" />
                      <jvmarg value="-Djavax.net.ssl.keyStorePassword=${keyStorePassword}" />
                      
                      <classpath refid="build.path" />
            </java>

            ScriptEnd=================================================================================


            Here are the exception details.

            ExceptionBegin=======================================================================================
            stack Trace isAxisFault
            faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
            faultSubcode:
            faultString: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
            faultActor:
            faultNode:
            faultDetail:
                 {http://xml.apache.org/axis/}stackTrace:java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
                 at javax.net.ssl.DefaultSSLSocketFactory.throwException(Unknown Source)
                 at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
                 at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
                 at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
                 at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
                 at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
                 at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
                 at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
                 at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
                 at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
                 at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
                 at org.apache.axis.client.Call.invoke(Call.java:2767)
                 at org.apache.axis.client.Call.invoke(Call.java:2443)
                 at org.apache.axis.client.Call.invoke(Call.java:2366)
                 at org.apache.axis.client.Call.invoke(Call.java:1812)
                 at com.collabnet.ce.soap50.webservices.cemain.CollabNetSoapStub.login(CollabNetSoapStub.java:115)
                 at com.collab.examples.LoginTF.main(LoginTF.java:37)
            Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
                 at java.security.Provider$Service.newInstance(Unknown Source)
                 at sun.security.jca.GetInstance.getInstance(Unknown Source)
                 at sun.security.jca.GetInstance.getInstance(Unknown Source)
                 at javax.net.ssl.SSLContext.getInstance(Unknown Source)
                 at javax.net.ssl.SSLContext.getDefault(Unknown Source)
                 at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
                 at org.apache.axis.components.net.JSSESocketFactory.initFactory(JSSESocketFactory.java:61)
                 at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:79)
                 ... 14 more
            Caused by: java.security.KeyStoreException: PKCS11 not found
                 at java.security.KeyStore.getInstance(Unknown Source)
                 at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.getDefaultKeyManager(Unknown Source)
                 at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.&lt;init&gt;(Unknown Source)
                 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
                 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
                 at java.lang.reflect.Constructor.newInstance(Unknown Source)
                 at java.lang.Class.newInstance0(Unknown Source)
                 at java.lang.Class.newInstance(Unknown Source)
                 ... 22 more
            Caused by: java.security.NoSuchAlgorithmException: PKCS11 KeyStore not available
                 at sun.security.jca.GetInstance.getInstance(Unknown Source)
                 at java.security.Security.getImpl(Unknown Source)
                 ... 31 more

                 {http://xml.apache.org/axis/}hostname:GDYL8420N5B

            java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
                 at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
                 at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
                 at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
                 at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
                 at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
                 at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
                 at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
                 at org.apache.axis.client.Call.invoke(Call.java:2767)
                 at org.apache.axis.client.Call.invoke(Call.java:2443)
                 at org.apache.axis.client.Call.invoke(Call.java:2366)
                 at org.apache.axis.client.Call.invoke(Call.java:1812)
                 at com.collabnet.ce.soap50.webservices.cemain.CollabNetSoapStub.login(CollabNetSoapStub.java:115)
                 at com.collab.examples.LoginTF.main(LoginTF.java:37)
            ExceptionEnd===========================================================================================
            • 3. Re: Passing Virtual Machine Arguments while calling a .jar file.
              jschellSomeoneStoleMyAlias
              878645 wrote:
              it seems to be problem is not in finding the MainClass.
              Nope. If that was the case it would tell you.
              If run through Eclipse IDE or use Ant script it runs fine and prompts me for CAC pin.
              So it runs it differently than the way you are doing it.

              I doubt that has anything to do with a jar file.
              This is how Ant build script looks for VM parameters
              Ant works. With three parameters.
              The command line doesn't. With two parameters.
              • 4. Re: Passing Virtual Machine Arguments while calling a .jar file.
                handat
                java -Djavax.net.ssl.keyStore=NONE -Djavax.net.ssl.keyStoreType=PKCS11 -cp c:\temp\LoginTF.jar com.collab.examples.LoginTF
                • 5. Re: Passing Virtual Machine Arguments while calling a .jar file.
                  881648
                  Thank you. That helped.

                  Soma