1 Reply Latest reply on Jan 17, 2006 8:34 AM by Kyle Duncan

    java.io.StreamCorruptedException in simple security example

    Kyle Duncan Newbie

      I am attempting to run the 'simple' xws-security example of JWSDP 1.6 using JBoss 4.0.2 and J2SDK 1.4.2. My JCE provider is de.cscc.crypto.provider from http://www.jhbci.de. (I tried several other JCE providers and got the same results).

      I have placed several of the JWSDP's endorsed jars in JBoss's lib/endorsed directory to avoid ClassDefNotFound errors.

      When deploying the securesimple.war, the following code triggers a StreamCorruptedException:

      symmKeyStore = KeyStore.getInstance(symmKeyStoreType);
      FileInputStream fis = new FileInputStream(symmKeyStoreURL);
      // the next line is where the exception occurs
      symmKeyStore.load(fis, symmKeyStorePassword.toCharArray());
      

      The stack trace is as follows, and occurs as the war is being deployed:

      08:25:11,556 INFO [TomcatDeployer] deploy, ctxPath=/securesimple, warUrl=file:/
      D:/jboss-wssecure/server/hspd12/tmp/deploy/tmp3384securesimple-exp.war/
      08:25:11,728 INFO [STDOUT] Jan 5, 2006 8:25:11 AM com.sun.xml.rpc.server.http.J
      AXRPCContextListener contextInitialized
      INFO: JAXRPCSERVLET12: JAX-RPC context listener initializing
      08:25:12,181 INFO [STDOUT] java.io.IOException: java.io.StreamCorruptedExceptio
      n invalid stream header
      08:25:12,181 INFO [STDOUT] at sample.SecurityEnvironmentHandler.initSymmKey
      Store(SecurityEnvironmentHandler.java:316)
      08:25:12,181 INFO [STDOUT] at sample.SecurityEnvironmentHandler.(Secu
      rityEnvironmentHandler.java:124)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.new
      Instance0(Native Method)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.new
      Instance(NativeConstructorAccessorImpl.java:39)
      08:25:12,181 INFO [STDOUT] at sun.reflect.DelegatingConstructorAccessorImpl
      .newInstance(DelegatingConstructorAccessorImpl.java:27)
      08:25:12,181 INFO [STDOUT] at java.lang.reflect.Constructor.newInstance(Con
      structor.java:274)
      08:25:12,181 INFO [STDOUT] at java.lang.Class.newInstance0(Class.java:308)
      08:25:12,181 INFO [STDOUT] at java.lang.Class.newInstance(Class.java:261)
      08:25:12,181 INFO [STDOUT] at com.sun.xml.rpc.security.SecurityPluginUtil.<
      init>(SecurityPluginUtil.java:92)
      08:25:12,181 INFO [STDOUT] at simple.PingPort_Ping_Tie.(PingPort_Pi
      ng_Tie.java:36)
      08:25:12,181 INFO [STDOUT] at java.lang.Class.forName0(Native Method)
      08:25:12,181 INFO [STDOUT] at java.lang.Class.forName(Class.java:219)
      08:25:12,181 INFO [STDOUT] at com.sun.xml.rpc.server.http.JAXRPCRuntimeInfo
      Parser.loadClass(JAXRPCRuntimeInfoParser.java:189)
      08:25:12,181 INFO [STDOUT] at com.sun.xml.rpc.server.http.JAXRPCRuntimeInfo
      Parser.parseEndpoints(JAXRPCRuntimeInfoParser.java:73)
      08:25:12,181 INFO [STDOUT] at com.sun.xml.rpc.server.http.JAXRPCRuntimeInfo
      Parser.parse(JAXRPCRuntimeInfoParser.java:39)
      08:25:12,181 INFO [STDOUT] at com.sun.xml.rpc.server.http.JAXRPCServlet.ini
      t(JAXRPCServlet.java:51)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.load
      Servlet(StandardWrapper.java:1091)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.load
      (StandardWrapper.java:925)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardContext.load
      OnStartup(StandardContext.java:3857)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardContext.star
      t(StandardContext.java:4118)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChi
      ldInternal(ContainerBase.java:759)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChi
      ld(ContainerBase.java:739)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardHost.addChil
      d(StandardHost.java:524)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      08:25:12,181 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,181 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,181 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.inv
      oke(BaseModelMBean.java:503)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(
      RawDynamicInvoker.java:150)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,181 INFO [STDOUT] at org.apache.catalina.core.StandardContext.init
      (StandardContext.java:5005)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      08:25:12,181 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      08:25:12,181 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,181 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,181 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.inv
      oke(BaseModelMBean.java:503)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(
      RawDynamicInvoker.java:150)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,181 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.perfo
      rmDeployInternal(TomcatDeployer.java:274)
      08:25:12,181 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.perfo
      rmDeploy(TomcatDeployer.java:91)
      08:25:12,181 INFO [STDOUT] at org.jboss.web.AbstractWebDeployer.start(Abstr
      actWebDeployer.java:357)
      08:25:12,181 INFO [STDOUT] at org.jboss.web.WebModule.startModule(WebModule
      .java:68)
      08:25:12,181 INFO [STDOUT] at org.jboss.web.WebModule.startService(WebModul
      e.java:46)
      08:25:12,181 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
      ernalStart(ServiceMBeanSupport.java:272)
      08:25:12,181 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
      ernalLifecycle(ServiceMBeanSupport.java:222)
      08:25:12,181 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor4.invoke(U
      nknown Source)
      08:25:12,181 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,181 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:72)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,181 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,181 INFO [STDOUT] at org.jboss.system.ServiceController$ServicePro
      xy.invoke(ServiceController.java:897)
      08:25:12,181 INFO [STDOUT] at $Proxy0.start(Unknown Source)
      08:25:12,181 INFO [STDOUT] at org.jboss.system.ServiceController.start(Serv
      iceController.java:418)
      08:25:12,181 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor11.invoke(
      Unknown Source)
      08:25:12,181 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,197 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:72)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
      roxyExt.java:177)
      08:25:12,197 INFO [STDOUT] at $Proxy27.start(Unknown Source)
      08:25:12,197 INFO [STDOUT] at org.jboss.web.AbstractWebContainer.start(Abst
      ractWebContainer.java:394)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainD
      eployer.java:964)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
      Deployer.java:775)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
      Deployer.java:738)
      08:25:12,197 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor40.invoke(
      Unknown Source)
      08:25:12,197 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,197 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.
      invoke(AbstractInterceptor.java:121)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:74)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationI
      nterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:74)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
      roxyExt.java:177)
      08:25:12,197 INFO [STDOUT] at $Proxy8.deploy(Unknown Source)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentSca
      nner.deploy(URLDeploymentScanner.java:325)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentSca
      nner.scan(URLDeploymentScanner.java:501)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeployme
      ntScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeployme
      ntScanner.startService(AbstractDeploymentScanner.java:277)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
      ernalStart(ServiceMBeanSupport.java:272)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
      ernalLifecycle(ServiceMBeanSupport.java:222)
      08:25:12,197 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor4.invoke(U
      nknown Source)
      08:25:12,197 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,197 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:72)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.ServiceController$ServicePro
      xy.invoke(ServiceController.java:897)
      08:25:12,197 INFO [STDOUT] at $Proxy0.start(Unknown Source)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.ServiceController.start(Serv
      iceController.java:418)
      08:25:12,197 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor11.invoke(
      Unknown Source)
      08:25:12,197 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,197 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:72)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
      roxyExt.java:177)
      08:25:12,197 INFO [STDOUT] at $Proxy4.start(Unknown Source)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.SARDeployer.start(SARDep
      loyer.java:273)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainD
      eployer.java:964)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
      Deployer.java:775)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
      Deployer.java:738)
      08:25:12,197 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
      Deployer.java:722)
      08:25:12,197 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      08:25:12,197 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      08:25:12,197 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      08:25:12,197 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
      invoke(ReflectedDispatcher.java:141)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
      ation.java:80)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.
      invoke(AbstractInterceptor.java:121)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:74)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationI
      nterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:74)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:249)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:644)
      08:25:12,197 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
      roxyExt.java:177)
      08:25:12,197 INFO [STDOUT] at $Proxy5.deploy(Unknown Source)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.server.ServerImpl.doStart(Se
      rverImpl.java:434)
      08:25:12,197 INFO [STDOUT] at org.jboss.system.server.ServerImpl.start(Serv
      erImpl.java:315)
      08:25:12,197 INFO [STDOUT] at org.jboss.Main.boot(Main.java:195)
      08:25:12,197 INFO [STDOUT] at org.jboss.Main$1.run(Main.java:463)
      08:25:12,197 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)

      // several other exceptions follow

      I can verify that the file being loaded, server-symmkeystore.jceks, is being found. I assume the cause of the exception is somewhere in my configuration and is not that there's anything wrong with server-symmkeystore.jceks. I've read elsewhere online that classloading issues can cause this type of exception, but I did not learn anything I could apply to my situation directly.

      I tried to simplify the situation by writing a small test program that executes only the few offending lines of code and that could be run standalone, and got the same exception. The program is as follows:
      
      package simple;
      
      import java.io.FileInputStream;
      import java.io.IOException;
      import java.security.KeyStore;
      
      public class TestLoadKeyStore {
       private String symmKeyStoreURL;
       private String symmKeyStorePassword;
       private String symmKeyStoreType;
       private KeyStore symmKeyStore;
      
       public TestLoadKeyStore() {
       symmKeyStoreType = "JCEKS";
       symmKeyStorePassword = "changeit";
       symmKeyStoreURL = "d:/jwsdp1_6/xws-security/etc/server-symmkeystore.jceks";
       }
       public static void main(String[] args) {
      
       TestLoadKeyStore tlks = new TestLoadKeyStore();
       try {
       tlks.initSymmKeyStore();
       }
       catch (Exception e) {
       System.out.println(e.getClass().getName()+":"+
       e.getMessage());
       e.printStackTrace();
       }
       }
       private void initSymmKeyStore() throws IOException {
       try {
       symmKeyStore = KeyStore.getInstance(symmKeyStoreType);
       FileInputStream fis = new FileInputStream(symmKeyStoreURL);
       symmKeyStore.load(fis, symmKeyStorePassword.toCharArray());
       } catch (Exception e) {
      
       throw new IOException(e.getClass().getName() + " " + e.getMessage()/* kdd + " " + symmKeyStoreURL + " " + symmKeyStorePassword */);
       }
       }
      }
      

      I ran the sample program by executing this ant target from within the build script provided by JWSDP for the simple example:

      <target name="run-test"
       depends="clean, prepare, build-client"
       description="Runs the example client">
       <echo message="Running the simple.TestLoadKeyStore program...."/>
       <java fork="on" classname="simple.TestLoadKeyStore">
       <sysproperty key="java.endorsed.dirs" value="${java.endorsed.dir}"/>
       <sysproperty key="http.proxyHost" value="${http.proxyHost}"/>
       <sysproperty key="http.proxyPort" value="${http.proxyPort}"/>
       <sysproperty key="endpoint.host" value="${endpoint.host}"/>
       <sysproperty key="endpoint.port" value="${endpoint.port}"/>
       <sysproperty key="service.url" value="${service.url}"/>
       <sysproperty key="jwsdp.home" value="${jwsdp.home}"/>
       <classpath>
       <pathelement location="${build.home}/client"/>
       <fileset dir="${build.home}/client">
       <include name="secenv-handler.jar"/>
       </fileset>
       <path refid="app.classpath"/>
       </classpath>
       </java>
       </target>
      

      Since here the jars in the classpath are exactly those provided by JWSDP and the ant target was almost directly copied from the target meant to run the sample application, I hoped I had eliminated any discrepancies between my enviroment and that in which the code is intended to run. Unfortunately since the problem still occurs, I don't know what else could be wrong.

      Any help would be much appreciated. I've wasted many hours looking for a fix for this but haven't had much luck finding related information.

      -Kyle