CatchAll block not catching JTA timeout with XA datasource

Hi,
We have a synchronous BPEL process with DB Adapters calling XA datasource. We configured a CatchAll block to catch any exception that may arise during the execution. JTA timeout is 5 min (300s). DB Adapter calls a procedure in which we have introduced delay using DBMS Lock API.
Whenever the total invoke activities timeout is greater than 5min, JTA exception is occurring, but not getting caught in CatchAll block.
Below is the log
Error Message: {http://schemas.oracle.com/bpel/extension}runtimeFault
Fault ID default/OnAlarmTest!2.0*soa_93bf9d67-975e-4998-b725-9c68903cd40f/BPELProcess1/818062-BpInv1-BpSeq0.3-3
Fault Time Jan 6, 2015 6:04:12 PM
Non Recoverable System Fault :
<bpelFault><faultType>0</faultType><runtimeFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>Global retry rollback fault thrown. The current JTA transaction is aborting due to an user rollback fault being thrown. The upstream component should retry in a new JTA transaction upon catching this fault. This exception was caused by a global retry fault being thrown from downstream component. The user had directed the BPEL engine to roll back the current JTA transaction and retry within new JTA transactions for the specified number of times and retry interval. There is no action recommended. </summary></part><part name="detail"><detail>ORABPEL-02198 Global retry rollback fault thrown. The current JTA transaction is aborting due to an user rollback fault being thrown. The upstream component should retry in a new JTA transaction upon catching this fault. This exception was caused by a global retry fault being thrown from downstream component. The user had directed the BPEL engine to roll back the current JTA transaction and retry within new JTA transactions for the specified number of times and retry interval. There is no action recommended. at com.collaxa.cube.ws.WSInvocationManager.invoke(WSInvocationManager.java:336) at com.collaxa.cube.engine.ext.common.InvokeHandler.__invoke(InvokeHandler.java:1099) at com.collaxa.cube.engine.ext.common.InvokeHandler.handleNormalInvoke(InvokeHandler.java:594) at com.collaxa.cube.engine.ext.common.InvokeHandler.handle(InvokeHandler.java:132) at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.__executeStatements(BPELInvokeWMP.java:74) at com.collaxa.cube.engine.ext.bpel.common.wmp.BaseBPELActivityWMP.perform(BaseBPELActivityWMP.java:173) at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:2718) at com.collaxa.cube.engine.CubeEngine._handleWorkItem(CubeEngine.java:1197) at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1100) at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:76) at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:251) at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:330) at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4652) at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4583) at com.collaxa.cube.engine.CubeEngine._createAndInvoke(CubeEngine.java:714) at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:559) at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.createAndInvoke(CubeEngineBean.java:103) at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.syncCreateAndInvokeParticipate(CubeEngineBean.java:181) at sun.reflect.GeneratedMethodAccessor1631.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:103) at oracle.security.jps.ee.ejb.JpsAbsInterceptor$1.run(JpsAbsInterceptor.java:113) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460) at oracle.security.jps.ee.ejb.JpsAbsInterceptor.runJaasMode(JpsAbsInterceptor.java:100) at oracle.security.jps.ee.ejb.JpsAbsInterceptor.intercept(JpsAbsInterceptor.java:154) at oracle.security.jps.ee.ejb.JpsInterceptor.intercept(JpsInterceptor.java:113) at sun.reflect.GeneratedMethodAccessor1095.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:68) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34) at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54) at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy311.syncCreateAndInvokeParticipate(Unknown Source) at com.collaxa.cube.engine.ejb.impl.bpel.BPELEngineBean_51369e_ICubeEngineLocalBeanImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:39) at com.collaxa.cube.engine.ejb.impl.bpel.BPELEngineBean_51369e_ICubeEngineLocalBeanImpl.syncCreateAndInvokeParticipate(Unknown Source) at com.collaxa.cube.engine.delivery.DeliveryHandler.callCreateAndInvoke(DeliveryHandler.java:914) at com.collaxa.cube.engine.delivery.DeliveryHandler.initialRequestAnyType(DeliveryHandler.java:631) at com.collaxa.cube.engine.delivery.DeliveryHandler.initialRequest(DeliveryHandler.java:565) at com.collaxa.cube.engine.delivery.DeliveryHandler.request(DeliveryHandler.java:238) at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.request(CubeDeliveryBean.java:541) at sun.reflect.GeneratedMethodAccessor1630.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:103) at oracle.security.jps.ee.ejb.JpsAbsInterceptor$1.run(JpsAbsInterceptor.java:113) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460) at oracle.security.jps.ee.ejb.JpsAbsInterceptor.runJaasMode(JpsAbsInterceptor.java:100) at oracle.security.jps.ee.ejb.JpsAbsInterceptor.intercept(JpsAbsInterceptor.java:154) at oracle.security.jps.ee.ejb.JpsInterceptor.intercept(JpsInterceptor.java:113) at sun.reflect.GeneratedMethodAccessor1095.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:68) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34) at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54) at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy307.request(Unknown Source) at com.collaxa.cube.engine.ejb.impl.bpel.BPELDeliveryBean_5k948i_ICubeDeliveryLocalBeanImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:39) at com.collaxa.cube.engine.ejb.impl.bpel.BPELDeliveryBean_5k948i_ICubeDeliveryLocalBeanImpl.request(Unknown Source) at oracle.fabric.CubeServiceEngine.request(CubeServiceEngine.java:458) at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139) at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:182) at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:190) at sun.reflect.GeneratedMethodAccessor1570.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseEventAspect.java:59) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy325.request(Unknown Source) at oracle.integration.platform.blocks.soap.WebServiceEntryBindingComponent.doMessageProcessing(WebServiceEntryBindingComponent.java:1636) at oracle.integration.platform.blocks.soap.WebServiceEntryBindingComponent.processIncomingMessage(WebServiceEntryBindingComponent.java:1016) at oracle.integration.platform.blocks.soap.FabricProvider.processMessage(FabricProvider.java:113) at oracle.j2ee.ws.server.provider.ProviderProcessor.doEndpointProcessing(ProviderProcessor.java:1187) at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementation(WebServiceProcessor.java:1123) at oracle.j2ee.ws.server.provider.ProviderProcessor.doRequestProcessing(ProviderProcessor.java:581) at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServiceProcessor.java:235) at oracle.j2ee.ws.server.WebServiceProcessor.doService(WebServiceProcessor.java:195) at oracle.j2ee.ws.server.WebServiceServlet.doPost(WebServiceServlet.java:487) at oracle.integration.platform.blocks.soap.FabricProviderServlet.doPost(FabricProviderServlet.java:523) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) Caused by: oracle.fabric.common.FabricInvocationException: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'test1' failed due to: Stored procedure invocation error. Error while trying to prepare and execute the HR.PROC_DELAY1 API. An error occurred while preparing and executing the HR.PROC_DELAY1 API. Cause: java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation ORA-06512: at "SYS.DBMS_LOCK", line 201 ORA-06512: at "HR.PROC_DELAY1", line 7 ORA-06512: at line 1 Check to ensure that the API is defined in the database and that the parameters match the signature of the API. This exception is considered retriable, likely due to a communication failure. Because the global transaction is rolling back the invoke must be retried in a new transaction, restarting from the place of the last transaction commit. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "1013" to your deployment descriptor (i.e. weblogic-ra.xml). ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. at oracle.integration.platform.blocks.adapter.fw.jca.cci.EndpointInteractionException.getFabricInvocationException(EndpointInteractionException.java:75) at oracle.integration.platform.blocks.adapter.AdapterReference.getFabricInvocationException(AdapterReference.java:316) at oracle.integration.platform.blocks.adapter.AdapterReference.request(AdapterReference.java:219) at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139) at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:182) at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:190) at sun.reflect.GeneratedMethodAccessor1570.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseEventAspect.java:71) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy325.request(Unknown Source) at oracle.fabric.CubeServiceEngine.requestToMesh(CubeServiceEngine.java:858) at com.collaxa.cube.ws.WSInvocationManager.invoke(WSInvocationManager.java:267) ... 146 more Caused by: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'test1' failed due to: Stored procedure invocation error. Error while trying to prepare and execute the HR.PROC_DELAY1 API. An error occurred while preparing and executing the HR.PROC_DELAY1 API. Cause: java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation ORA-06512: at "SYS.DBMS_LOCK", line 201 ORA-06512: at "HR.PROC_DELAY1", line 7 ORA-06512: at line 1 Check to ensure that the API is defined in the database and that the parameters match the signature of the API. This exception is considered retriable, likely due to a communication failure. Because the global transaction is rolling back the invoke must be retried in a new transaction, restarting from the place of the last transaction commit. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "1013" to your deployment descriptor (i.e. weblogic-ra.xml). ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:486) at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeJcaReference(JCAInteractionInvoker.java:572) at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeSyncJcaReference(JCAInteractionInvoker.java:545) at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAEndpointInteraction.performSynchronousInteraction(JCAEndpointInteraction.java:547) at oracle.integration.platform.blocks.adapter.AdapterReference.request(AdapterReference.java:179) ... 161 more Caused by: BINDING.JCA-11811 Stored procedure invocation error. Error while trying to prepare and execute the HR.PROC_DELAY1 API. An error occurred while preparing and executing the HR.PROC_DELAY1 API. Cause: java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation ORA-06512: at "SYS.DBMS_LOCK", line 201 ORA-06512: at "HR.PROC_DELAY1", line 7 ORA-06512: at line 1 Check to ensure that the API is defined in the database and that the parameters match the signature of the API. This exception is considered retriable, likely due to a communication failure. Because the global transaction is rolling back the invoke must be retried in a new transaction, restarting from the place of the last transaction commit. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "1013" to your deployment descriptor (i.e. weblogic-ra.xml). at oracle.tip.adapter.db.exceptions.DBResourceException.createXARetriableException(DBResourceException.java:686) at oracle.tip.adapter.db.exceptions.DBResourceException.createEISException(DBResourceException.java:658) at oracle.tip.adapter.db.sp.SPUtil.createResourceException(SPUtil.java:180) at oracle.tip.adapter.db.sp.AbstractStoredProcedure.execute(AbstractStoredProcedure.java:131) at oracle.tip.adapter.db.sp.SPInteraction.executeStoredProcedure(SPInteraction.java:142) at oracle.tip.adapter.db.DBInteraction.executeStoredProcedure(DBInteraction.java:1167) at oracle.tip.adapter.db.DBInteraction.execute(DBInteraction.java:254) at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:357) ... 165 more Caused by: java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation ORA-06512: at "SYS.DBMS_LOCK", line 201 ORA-06512: at "HR.PROC_DELAY1", line 7 ORA-06512: at line 1 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548) at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:213) at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1111) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1488) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3954) at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:9353) at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1539) at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:99) at oracle.tip.adapter.db.sp.AbstractStoredProcedure.execute(AbstractStoredProcedure.java:123) ... 169 more </detail></part><part name="code"><code>com.collaxa.cube.engine.EngineException</code></part></runtimeFault></bpelFault>
Request your suggestions/ pointers on this.
Environment details
SOA 11.1.1.7.0.
Weblogic 10.3.6
Oracle EE 11.2.0.1.0
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
OS: Windows Server 2008R2 Enterprise
Many thanks in advance.
Sai

You can use the SOA Fault Management Framework to capture this error and handle it accordingly.  Use a <test> condition in the fault policy file to test for the specific $fault values you're getting in this error and then link to what you need to execute to handle the error in the corresponding <action> element. In the fault binding file bind this aforementioned fault policy to the DB Adapter reference component via the <reference> element. Alternatively you could bind it to the composite if the test condition is sufficiently detailed enough.
Hope it helps.

Similar Messages

  • CatchAll does not catch exception in ora:translateFromNative

    Hello,
    In a BPEL process, I have an Assign step where I use the ora:translateFromNative function. There is a CatchAll around the Sequence. When I provide wrong data in the inputvariable for the native translation (for instance a typo in the root element name), the XPATH function fails but the CatchAll does not catch this. Furthermore, the process state is not dehydrated so in the BPEL console you don't see anything about this. The log file however shows the following information:
    <2007-06-25 13:31:01,723> <ERROR> <default.collaxa.cube.engine.dispatch> <BaseScheduledWorker::process> Failed to handle dispatch message ... exception ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.instance.PerformMessage"; the exception is: XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:translateFromNative(bpws:getVariableData('ReceiveBodConfirmation_confirm_InputVariable','payload','/client:PlasPOImportConfirmRequest/client:request'),'mro_confirm_bod.xsd','CONFIRM_BOD_002')", the reason is FOTY0001: type error.
    Please verify the xpath query.
    My gut feeling after reading this is that an exception occurs while BPEL is creating the fault that should be thrown.
    In any case, this behaviour prevents me from creating a robust BPEL process. Any ideas on how I could deal with this would be much appreciated.
    Kind regards,
    Peter

    Hoi Peter,
    Is the message still in the recovery area? So BPEL is thinking that it is a runtime error and could be revoverd?
    Did you log a TAR?
    Marc

  • Firefox 9.0.1 with Flash player not catch keyboard event with mouse click.

    In a flash application, I need select mutil items using shite key and mouse click, it is not working. looks like firefox didn't pass the keyboard even alone with the click event. This happen on Window 7, IE and Chrome have no problem. only FF

    i have the same problem everytime i open a website with flashcontent firefox freezes and i have to kill the flash process to unfreeze the browser the only way i can see a youtube video is in html5 mode.
    Hardware
    Acer aspire 4553
    Turion X2 p520
    3gb of ddr3 ram
    Ati Mobility Radeon 4250

  • Handling JTA timeouts within WLS client application

              Hello
              I have a Java program which is a JMS client to WLS 7.0. I use JTA(javax.transaction.UserTransaction)
              to handle txns. I am not sure which is the best way to handle JTA timeouts.
              I found that I could catch the javax.transaction.RollbackException when I try
              to do a UserTransaction.commit(). But I am not allowed to catch weblogic.transaction.TimedOutException().
              My code looks something like this....
              UserTransaction utx;
              utx.begin();
              doSomeJMS()
              doSomeSQL()
              utx.commit();
              I would like to know what is the suggested way of catching JTA timeouts within
              my application so that I can retry the transaction.
              Thanks
              Ramdas
              

              Steve,
              Thanks for the code. It is exactly what I was looking for.
              Ramdas
              "Stephen Felts" <[email protected]> wrote:
              >The attached code works - you will get back "GOT A TIMEOUT".
              >
              >
              >
              >
              >"Ramdas Hegde" <[email protected]> wrote in message news:3f130b34$[email protected]..
              >>
              >> Hello
              >>
              >> I have a Java program which is a JMS client to WLS 7.0. I use JTA(javax.transaction.UserTransaction)
              >> to handle txns. I am not sure which is the best way to handle JTA timeouts.
              >> I found that I could catch the javax.transaction.RollbackException
              >when I try
              >> to do a UserTransaction.commit(). But I am not allowed to catch weblogic.transaction.TimedOutException().
              >>
              >> My code looks something like this....
              >>
              >> UserTransaction utx;
              >> utx.begin();
              >>
              >> ...
              >> doSomeJMS()
              >> doSomeSQL()
              >>
              >> utx.commit();
              >>
              >> I would like to know what is the suggested way of catching JTA timeouts
              >within
              >> my application so that I can retry the transaction.
              >>
              >> Thanks
              >>
              >> Ramdas
              >
              >
              

  • Itunes document manager pro will not open a document with .cwk extension. It will catch the document then error message states that it cannot open document. Can anyone tell me what Im doing wrong?

    Itunes document manager pro will not open a document with .cwk extension. It will catch the document then error message states that it cannot open document. Can anyone tell me what Im doing wrong?

    Forgive my ignorance but I have never hear of iTunes Document Manager Pro. If you mean Document Manager Pro, i was able to find that. Back to your problem, have you tried opening one of those files in the iOS iWorks apps? Form the quick read that I did about this, .cwk files can be opened by Pages, Numbers or Keynote, depending on what type of document that it is and those files can be read by Document Manager Pro, after properly saving them. I don't see that you can go directly from the .cwk file in Document Manager Pro without converting them first.
    I took a very quick look at the app, so I may be a missing something about its capability.

  • JWSDP 1.6 xws-security Simple fails with "block not properly padded"

    Environment:
    - Windows 2000
    - Tomcat50-jwsdp
    - JAVA_HOME=C:/Progra~1/Java/jdk1.5.0_05
    - Security environment handler: SecurityEnvironmentHandler.java supplied with JWSDP 1.6 (Hello, Ron!)
    I get the following in the Tomcat Window:
    ==== Received Message End ====
    Nov 13, 2005 10:38:56 AM com.sun.org.apache.xml.internal.security.encryption.XMLCipher decryptKey
    INFO: Decryption of key type http://www.w3.org/2001/04/xmlenc#tripledes-cbc OK
    Nov 13, 2005 10:38:56 AM com.sun.xml.wss.impl.apachecrypto.DecryptionProcessor decryptElementWithCipher
    SEVERE: WSS_ENC0004: Exception [ Given final block not properly padded ] while trying to decrypt message
    Nov 13, 2005 10:38:56 AM com.sun.xml.wss.impl.filter.DumpFilter process
    INFO: ==== Sending Message Start ====
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/enco
    ding/" xmlns:ns0="http://xmlsoap.org/Ping" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.or
    g/2001/XMLSchema-instance">
    <env:Body>
    <env:Fault>
    <faultcode xmlns:ans1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ans1:Fail
    edCheck</faultcode>
    <faultstring>Unable to decrypt message</faultstring>
    </env:Fault>
    </env:Body>
    </env:Envelope>
    ==== Sending Message End ====
    Please help!
    George

    Hi, I got the xws-security/samples/simple application
    working successfully with my own keystores. I have 2
    questions regarding this sample application.
    1) When running the application with the
    encrypt-server.xml and encrypt-client.xml
    configuration, why is it necessary to import the
    client's certificate into the server's truststore and
    the server's certificate into client's truststore when
    their certificates have already been signed by a
    trusted root CA (e.g. Verisign), whose certificate is
    in both truststores? Shouldn't their certificates
    containing their public keys get automatically
    exchanged during the connection request? It's a pain
    to publish a web service and expect a manual public
    certificate import for each client wanting to use the
    service.Certificates are sent only when the keyReferenceType is "Direct" which is the default. It's possible that our code is checking the certificate sent with one found in the KeyStore, but a quick scan of the code doesn't show it. If that's what's happening it's a bug. All of the other key reference strategies send only a referece to the sender's certificate in which case the reciever must have a copy of that certificate in its keystore.
    2) I use Tomcat to run the sample application and did
    set up the SSL connector to point to the keystores.
    When the client connects to the server, it uses a
    http endpoint not https. I'm aware that htpps is
    needed for SSL support but not clear on where does
    https come into play during the client's
    request/server's response process.We share the SSL keystore so that certificates don't have to be stored in more than one place. The functionality of XWS-Security and SSL is logically the same so it make sense to use the same keystore. XWS-Security operates completely separately from the transport and never knows whether HTTPS is in use or not.
    Phil Goodwin
    Technical Lead
    XWS-Security

  • How can I interrupt the blocking call when call timeout?

    Hi,Guys
    I wrote an application server(daemon process) to talk with oracle server
    continuous which used oracle9 OCCI lib, each 5 min it executes the procedure
    on the DB server.
    Now I have come cross a problem:
    If the network is blocked, app server will blocked at occi call and would
    never pass, and no exception was catched :-(
    for e.g.
    1. Oracle server reboot without shutdown oracle process
    2. udp broadcast message storm blocked the connection between app server and
    oracle DB.
    I consider maybe it's because OCCI using the blocking mode of connection
    that caused this problem.
    How can I interrupt the blocking call when call timeout?

    Manage the timeout using a separate thread. When the timeout happens, issue a break on the OCCI connection. There is no direct way as of now. You need to do this to break a OCCI connection.
    retrieve the OCI handle from the OCCI handle (e.g. using Connection::getOCIServer or Connection::getOCIServiceContext methods) and issue a OCIBreak on it. Do not forget to allocate a error handle which should be passed to OCIBreak call.

  • JTA timeout value doesn't take effect within stateful EJB

    Platform : weblogic10.3.5
    problem description: I have 2 ejbs: ejb1 is a stateful bean and the transaction is bean managed, the trans-timeout-seconds is set to 60; ejb2 is a stateless bean, transaction is container managed, transaction type is required, trans-timeout-seconds is 35. And the JTA timeout value set in weblogic console is 20.
    ejb1 invokes the ejb2's interface to access db, and this transaction should be committed since ejb2 is container managed transaction. Then ejb1 create userTransaction to access db. And I found the transaction will be timed out after 35 seconds, which is the trans-timeout-seconds of ejb2.
    Here is the sample code
    ejb1.method(){
         ejb2.method();
         try{
              Context ctx = new InitialContext();
              UserTransaction ut = (UserTransaction) ctx.lookup(USER_TRANSACTION_REF_NAME);
              ut.begin();
                   //do some operation
              ut.commit();
         }catch(Exception e){
                   try{
              ut.rollback();
                   }catch(Exception ee){
    Is timeout value of the user transaction created in ejb1 should be jta timeout 20? why the ejb2's trans-timeout-seconds affects the ejb1's usertransaction timeout value? does any body know the reason?
    Thanks

    A transaction timeout will not and cannot terminate user code as there
    is no Java API for doing so. If you wish the user code to timeout, try
    using the "setQueryTimeout()" method on the SQL statement. The WebLogic
    JTS will timeout the transaction using another thread and will prevent
    any JDBC activity associated with the global transaction from being
    commited.
    Sincerely,
    Charlie Therit
    Developer Relations Engineer
    BEA Support
    hjkuob wrote:
    "Dear Support,
    We encounter problems with transaction timeout and details as follows:
    A swing UI calls a session bean in which a DAO(Data Access Object) is invoked,
    In this DAO, it try to invoke a store procedure like following :
    dateSource = getTxDataSource();
    conn = (Connection)dataSource.getConnection();
    cstmt = conn.prepareCall("{call PK_AP_OO_CATCH_UP.P_AP_MAIN(?,?) }");
    cstmt.registerOutParameter(...........);
    cstmt.execute();
    When a irrevalent guy carelessly locked the table , the swing keep running for 5 hours and
    the transaction never throws exception ( both JTA and trans-timeout-seconds are set).
    I've also survey docments , however, we are not sure about the definition of Container-managed transactions
    and Bean-managed transactions. So there are two problems to be solved :
    1. How to solve the timeout problem as the sample code above for calling store procedures,
    and what kind of transctions it uses according to the definition ?
    2. If a normal sql statement is executed as follows , should we declare explicit transaction ( begin and commit) ? %

  • Weblogic JTA timeout and PreparedStatement cache problem (Closed Statement)

    Hello,
    I am facing up a problem using a Weblogic connection pool with a PreparedStatement.
    Here is the environement :
    - Weblogic application server 10.3
    - JDBC connection pool with Oracle Thin driver (from server library) - all parameters by default i.e. StatementCache size = 10
    - JTA transaction timeout = 30s
    The problem is : if a prepared statement ends because of a JTA timeout, I receive the following stack exception/ stack trace
    java.sql.SQLException: The transaction is no longer active - status: 'Rolling Back. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 33 seconds
    BEA1-000D8AE7230EFAA3EDC9]'. No further JDBC access is allowed within this transaction.
    at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:178)
    at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:188)
    at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:92)
    at weblogic.jdbc.wrapper.Connection.clearCachedStatement(Connection.java:814)
    at weblogic.jdbc.wrapper.PreparedStatement.clearCachedStatement(PreparedStatement.java:1357)
    and then, if we try to re-execute immediately the same operation (*same statement* but new request, new thread, new JTA transaction ...) we receive without delay the following exception :
    java.sql.SQLException: Closed Statement
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
    It seems like a bug in the caching mechanism of Weblogic, the 1st stack trace shows method from the statement cache implementation, I presume weblogic is trying the clear the statement from the cache after the iniitial TimedOutException (SQLException), but as the JDBC connection is unusable at this point, the clearing fails and the statement remains in the cache but is physically closed by JDBC.
    1st question, why weblogic does need to call JTSConnection.checkConnection() for clearing a statement from its internal cache, it is a pure java memory operation isnt'it ?
    2nd question : How to solve the problem without setting the StatementCache size to 0 (I tried, it solves the problem)? I don't want to disable completely the Weblogic statement caching, I have a small PreparedStatement called very frequently.
    Thanks for any help

    The main issue is that the transactional context that is supposed to underlay the JDBC code being executed,
    has gone away. Indeed, any DBMS changes that may have been made by your code so far, have been rolled
    back and are gone. Your code should not be trying to continue JDBC as normal, and WebLogic is trying to stop
    you. The control flow should go back up to the location where the transaction was initiated, so as to restart from
    the beginning if that is what is desired, including getting a new JDBC connection and remaking all the statements
    etc.
    HTH,
    Joe
    Edited by: Joe Weinstein on Dec 3, 2010 9:12 AM

  • Why can not catch the standard BACK event in ALV's USER_COMMAND event,

    Hi expert, why i can not catch the standard BACK event in ALV's USER_COMMAND event,
    Code:
    DATA G_CON_UC_FORM   TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = SY-REPID
          I_CALLBACK_TOP_OF_PAGE  = G_CON_FORM
          I_CALLBACK_USER_COMMAND = G_CON_UC_FORM
          IT_FIELDCAT             = G_TAB_FIELDCAT
          IT_SORT                 = G_TAB_SORT_INF
          I_SAVE                  = G_CON_U
    *<<<Liang
        IT_EVENTS               = G_TAB_ALV_EVENTS
    *<<<Liang
        TABLES
          T_OUTTAB                = G_TAB_OUTPUT_DATA
        EXCEPTIONS
          PROGRAM_ERROR           = 1
          OTHERS                  = 2.
    *&      Form  F_USER_COMMAND
          ALV USER COMMAND processing
    FORM F_USER_COMMAND .
      IF SY-UCOMM = '&FO3'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDFORM.                    " F_USER_COMMAND
    When I set breakpoint on this subrouting ,and try to click stardard  BACK or CANCEL button, the callback form do not run, but if double click one of line of alv report, the callback form works well,
    so why??

    hi
    good
    check this report and change your code accordingly.
    THESE LINES ARE FOR THE MAIN PROGRAM ***
    SAP V40B ***
    REPORT Z_PICK_LIST .
    TABLES: RESB.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant
                    S_AUFNR FOR RESB-AUFNR," Order number
                    S_BDTER FOR RESB-BDTER." Req. date
    SELECTION-SCREEN END OF BLOCK BL1.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
    DATA: BEGIN OF OUT OCCURS 10,
            AUFNR LIKE RESB-AUFNR,         " Order number
            MATNR LIKE RESB-MATNR,         " Material
            BDMNG LIKE RESB-BDMNG,         " Requirements in UM
            MEINS LIKE RESB-MEINS,         " Unit of Measure (UM)
            ERFMG LIKE RESB-ERFMG,         " Requirements in UE
            ERFME LIKE RESB-ERFME,         " Unit of Entry (UE)
            MAKTX LIKE MAKT-MAKTX,         " Mat. description
          END OF OUT.
    INCLUDE Z_ALV_VARIABLES.
    INITIALIZATION.
      REPNAME = SY-REPID.
      PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
      PERFORM BUILD_EVENTTAB USING EVENTS[].
      PERFORM BUILD_COMMENT USING HEADING[].
      PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
      PERFORM GET_ORDERS.
      PERFORM GET_MATERIAL_DESCRIPTION.
    END-OF-SELECTION.
      PERFORM BUILD_LAYOUT USING LAYOUT.
      PERFORM BUILD_PRINT  USING PRINTS.
      PERFORM WRITE_USING_ALV.
          FORM INITIALIZE_FIELDCAT                               *
    -->  P_TAB                                                         *
    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  GET_ORDERS
          text
    FORM GET_ORDERS.
      SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME
             FROM RESB
             APPENDING TABLE OUT
             WHERE XLOEK EQ SPACE          " deletion indicator
             AND   XWAOK EQ 'X'            " goods movement indicator
             AND   WERKS IN S_WERKS        " plant
             AND   BDTER IN S_BDTER        " req. date
             AND   AUFNR IN S_AUFNR.       " pr. order
    ENDFORM.                               " GET_ORDERS
    *&      Form  GET_MATERIAL_DESCRIPTION
          text
    FORM GET_MATERIAL_DESCRIPTION.
      SORT OUT BY MATNR.
      LOOP AT OUT.
        SELECT SINGLE MAKTX
               INTO OUT-MAKTX
               FROM MAKT
               WHERE MATNR EQ OUT-MATNR
               AND   SPRAS EQ 'EN'.
        MODIFY OUT.
      ENDLOOP.
      SORT OUT BY AUFNR MATNR.
    ENDFORM.                               " GET_MATERIAL_DESCRIPTION
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: L_POS TYPE P.
    first line
      WRITE:/ TEXT-001.                    " Plant:
      IF S_WERKS-HIGH NE SPACE.
        WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.
      ELSEIF S_WERKS-LOW NE SPACE.
        LOOP AT S_WERKS.
          WRITE: S_WERKS-LOW.
        ENDLOOP.
      ELSEIF S_WERKS-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).
      POSITION L_POS. WRITE: TEXT-TIT.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED.  " User:
    second line
      WRITE:/ TEXT-002.                    " Order:
      IF S_AUFNR-HIGH NE SPACE.
        WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.
      ELSEIF S_AUFNR-LOW NE SPACE.
        LOOP AT S_AUFNR.
          WRITE: S_AUFNR-LOW.
        ENDLOOP.
      ELSEIF S_AUFNR-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-012,SY-DATUM.      " Date:
    third line
      WRITE:/ TEXT-003.                    " Req. Date:
      IF S_BDTER-HIGH(1) NE '0'.
        WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.
      ELSEIF S_BDTER-LOW(1) NE '0'.
        LOOP AT S_BDTER.
          WRITE: S_BDTER-LOW.
        ENDLOOP.
      ELSEIF S_BDTER-LOW(1) EQ '0'.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-013, SY-PAGNO.   " Page:
    ENDFORM.                               " TOP_OF_PAGE
          FORM END_OF_LIST                                              *
    FORM END_OF_LIST.
      DATA: L_POS TYPE P.
      ULINE.
      WRITE:/ '|', TEXT-021.      " Delivered by:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-031.            " Received by:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
      WRITE:/ '|', TEXT-012.      " Date:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-012.            " Date:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
    ENDFORM.                               " END_OF_LIST
    *&      Form  WRITE_USING_ALV
          text
    FORM WRITE_USING_ALV.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME     = REPNAME
                I_INTERNAL_TABNAME = 'OUT'
                I_INCLNAME         = REPNAME
           CHANGING
                CT_FIELDCAT        = FIELDTAB.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM       = REPNAME
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
                I_STRUCTURE_NAME         = 'OUT'
                IS_LAYOUT                = LAYOUT
                IT_FIELDCAT              = FIELDTAB
                I_DEFAULT                = 'A'
                I_SAVE                   = G_SAVE
                IS_VARIANT               = G_VARIANT
                IT_EVENTS                = EVENTS[]
                IS_PRINT                 = PRINTS
           TABLES
                T_OUTTAB                 = OUT.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
      ENDIF.
    ENDFORM.                               " WRITE_USING_ALV
    THESE LINES ARE FOR THE INCLUDE ***
    ***INCLUDE Z_ALV_VARIABLES .
    TYPE-POOLS: SLIS.
    DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
          HEADING  TYPE SLIS_T_LISTHEADER,
          LAYOUT   TYPE SLIS_LAYOUT_ALV,
          EVENTS   TYPE SLIS_T_EVENT,
          REPNAME  LIKE SY-REPID,
          F2CODE   LIKE SY-UCOMM VALUE  '&ETA',
          PRINTS   TYPE SLIS_PRINT_ALV,
          TITLE(40) TYPE C,
          G_SAVE(1) TYPE C,
          G_EXIT(1) TYPE C,
          G_VARIANT LIKE DISVARIANT,
          GX_VARIANT LIKE DISVARIANT.
    CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
               FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
               FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
               FORMNAME_BEFORE_LINE TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE',
               FORMNAME_AFTER_LINE TYPE SLIS_FORMNAME VALUE 'AFTER_LINE'.
          FORM MAIN_STATEMENTS                                          *
    THIS IS THE CODE THAT MUST BE INSERTED IN THE MAIN PROGRAM
    FORM MAIN_STATEMENTS.
    Declare the parameter P_VARI wherever you want it. If you don't
    want it, hide it with NO-DISPLAY, but it must exist.
    parameters: p_vari like disvariant-variant. " ALV Variant
    You have to add the following line after the data and parameter
    declaration:
    include z_alv_variables.
    Then, after the data/parameter declaration, add these lines:
    *initialization.
    repname = sy-repid.
    perform initialize_fieldcat using fieldtab[].
    perform build_eventtab using events[].
    perform build_comment using heading[].
    perform initialize_variant.
    If you are using the variable P_VARI (ALV Variant), also add this:
    *at selection-screen on value-request for p_vari.
    perform f4_for_variant.
    *at selection-screen.
    perform pai_of_selection_screen.
    After the "END-OF-SELECTION" statement, add these lines:
    perform build_layout using layout.
    perform build_print  using prints.
    perform write_using_alv.
    You also have to create the following forms: (you can find samples
    in this program)
    INITIALIZE_FIELDCAT
    USER_COMMAND     (only if you are creating a STATUS)
    WRITE_USING_ALV
    ENDFORM.
    *&      Form  INITIALIZE_FIELDCAT_SAMPLE
          THIS IS A SAMPLE, DO NOT USE THIS FORM IN YOUR PROGRAM
         -->P_FIELDTAB[]  text                                           *
    FORM INITIALIZE_FIELDCAT_SAMPLE USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.                           " Always clear before use
      CAT-TABNAME = 'I'.                   " Your internal table
      CAT-REF_TABNAME = 'ZCUSTMAS'.  " The data dictionary reference table
      CAT-FIELDNAME = 'KUNNR'.       " Name of your field in the itable.
      CAT-COL_POS   = 1.                   " Output position
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'NAME1'.             " Next field
      CAT-COL_POS   = 2.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'STRAS'.             " and the next
      CAT-COL_POS   = 3.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'LOEVM'.
      CAT-SELTEXT_S = 'Del'.         " You can always override the descrip-
      CAT-SELTEXT_M = 'Delivery'.          " tion (short, medium, large)
      CAT-SELTEXT_L = 'Delivery Num'.
      CAT-COL_POS   = 4.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'FKIMG'.
      CAT-DO_SUM    = 'X'.                 " You want totals calculated.
      CAT-NO_OUT    = 'X'.                 " and hidden.
      APPEND CAT TO P_TAB.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  BUILD_EVENTTAB
          THIS IS THE SAME FOR ALL THE PROGRAMS
         -->P_EVENTS[]  text                                             *
    FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = P_EVENTS.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_LIST TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_BEFORE_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_BEFORE_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_AFTER_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_AFTER_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
    ENDFORM.                               " BUILD_EVENTTAB
    *&      Form  BUILD_COMMENT
    NOT REALLY NEEDED, BUT I'LL LEAVE IT THERE, JUST IN CASE...
         -->P_HEADING[]  text                                            *
    FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: HLINE TYPE SLIS_LISTHEADER,
            TEXT(60) TYPE C,
            SEP(20) TYPE C.
      CLEAR: HLINE, TEXT.
      HLINE-TYP  = 'H'.
    write: text-101 to text+23.
      HLINE-INFO = TEXT.
      APPEND HLINE TO P_HEADING.
    ENDFORM.                               " BUILD_COMMENT
    *&      Form  INITIALIZE_VARIANT
    VERY IMPORTANT WHEN YOU USE VARIANTS!!!
    FORM INITIALIZE_VARIANT.
      G_SAVE = 'A'.
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = REPNAME.
      GX_VARIANT = G_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                I_SAVE     = G_SAVE
           CHANGING
                CS_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    ENDFORM.                               " INITIALIZE_VARIANT
    *&      Form  PAI_OF_SELECTION_SCREEN
    ALSO FOR VARIANTS
    FORM PAI_OF_SELECTION_SCREEN.
      IF NOT P_VARI IS INITIAL.
        MOVE G_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = G_SAVE
             CHANGING
                  CS_VARIANT = GX_VARIANT
             EXCEPTIONS
                  WRONG_INPUT   = 1
                  NOT_FOUND     = 2
                  PROGRAM_ERROR = 3.
        IF SY-SUBRC EQ 0.
          G_VARIANT = GX_VARIANT.
        ELSE.
          PERFORM INITIALIZE_VARIANT.
        ENDIF.
      ELSE.
        PERFORM INITIALIZE_VARIANT.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  F4_FOR_VARIANT
          text
    FORM F4_FOR_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT = G_VARIANT
                I_SAVE     = G_SAVE
           IMPORTING
                E_EXIT     = G_EXIT
                ES_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 2.
        MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    ENDFORM.                               " F4_FOR_VARIANT
    *&      Form  BUILD_LAYOUT
    STANDARD LAYOUT
         -->P_LAYOUT  text                                               *
    FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
      P_LAYOUT-F2CODE       = F2CODE.
      P_LAYOUT-ZEBRA        = 'X'.
    p_layout-detail_popup = 'X'.
      P_LAYOUT-TOTALS_TEXT  = SPACE.
      P_LAYOUT-SUBTOTALS_TEXT = SPACE.
    ENDFORM.                               " BUILD_LAYOUT
          FORM BUILD_PRINT                                              *
    STANDARD PRINT OPTIONS                                             *
    -->  P_PRINT                                                       *
    FORM BUILD_PRINT USING P_PRINT TYPE SLIS_PRINT_ALV.
      P_PRINT-NO_PRINT_LISTINFOS = 'X'.
      P_PRINT-NO_PRINT_SELINFOS  = ' '.
    ENDFORM.                               " BUILD_PRINT
          FORM PF_STATUS_SET                                            *
    NAME YOUR STATUS ALV. IF YOU NEED IT..                             *
    FORM PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ALV' EXCLUDING EXTAB.
    ENDFORM.                               " PF_STATUS_SET
          FORM USER_COMMAND_SAMPLE                                      *
    -->  UCOMM                                                         *
    -->  SELFIELD                                                      *
    FORM USER_COMMAND_SAMPLE USING UCOMM    LIKE SY-UCOMM
                               SELFIELD TYPE SLIS_SELFIELD.
      CASE UCOMM.
        WHEN 'MSXL'.                       " Export to Excel
         perform set_excel_export.
          CLEAR UCOMM.
        WHEN 'MM03'.
         set parameter id 'MAT' field selfield-value.
         call transaction 'MM03' and skip first screen.
          CLEAR UCOMM.
        WHEN 'BGR1'.
         perform fill_available.
         perform graph_available.
          CLEAR UCOMM.
        WHEN 'DOCU'.
         call function 'Z_HELP' exporting repname = repname.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
    *&      Form  WRITE_USING_ALV_SAMPLE
    *THIS IS A SAMPLE AND MUST BE WRITTEN DIRECTLY IN THE MAIN PROGRAM
    FORM WRITE_USING_ALV_SAMPLE.
    YOU CAN MERGE WITH A DATA DICTIONARY TABLE USING THIS:
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
          exporting
               i_program_name     = repname
               i_internal_tabname = 'I'
               i_inclname         = repname
          changing
               ct_fieldcat        = fieldtab.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_FIELDCATALOG_MERGE'.
    endif.
    OR JUST DISPLAY IT USING THIS:
    call function 'REUSE_ALV_LIST_DISPLAY'
          exporting
               i_callback_program       = repname
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
               i_structure_name         = 'I'
               is_layout                = layout
               it_fieldcat              = fieldtab
               i_default                = 'A'
               i_save                   = g_save
               is_variant               = g_variant
               it_events                = events[]
               is_print                 = prints
          tables
               t_outtab                 = i.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_LIST_DISPLAY'.
    endif.
    ENDFORM.                               " WRITE_USING_ALV
    thanks
    mrutyun^

  • Given final block not properly not padded.....when given wrong password....

    hi..........sir
    when i am executing the following code..with wrong password....i am getting the BadPaddingException:Given final block not properly padded............
    plz help me to solve this one with the solution.
    I am doing my final project .....i am implementing an security protocol....
    here is thecode...
    String pw=JOptionPane.showInputDialog("enter the password string");
    byte[] pwb=new byte[pw.getBytes().length];
    pwb=pw.getBytes();
    String msg=JOptionPane.showInputDialog(null,"enter the message");
    byte[] msgb=new byte[msg.getBytes().length];
    msgb=msg.getBytes();
    try
    PBEKeySpec ks=new PBEKeySpec(pw.toCharArray());
    SecretKeyFactory skf= SecretKeyFactory.getInstance("PBEWithMD5AndDES");
    SecretKey ky=skf.generateSecret(ks);
    MessageDigest md=MessageDigest.getInstance("MD5");
    md.update("srikrishna".getBytes());byte[] digest=md.digest();
    byte salt[]=new byte[8];
    for(int i=0;i<8;i++)
         salt=digest[i];
    PBEParameterSpec ps=new PBEParameterSpec(salt,20);
    Cipher cf=Cipher.getInstance("PBEWithMD5AndDES");
    cf.init(Cipher.ENCRYPT_MODE,ky,ps);
    byte[]thCp=cf.doFinal(msgb);
    for(int i=0;i<thCp.length;i++)
         System.out.print((char)thCp[i]);
    System.out.println("\n\n");
    String pwbs=JOptionPane.showInputDialog("enter the password string");
    byte[] pwbsb=new byte[pwbs.getBytes().length];
    pwbsb=pwbs.getBytes();
    PBEKeySpec ks1=new PBEKeySpec(pwbs.toCharArray());
    SecretKeyFactory skf1= SecretKeyFactory.getInstance("PBEWithMD5AndDES");
    SecretKey ky1=skf1.generateSecret(ks1);
    MessageDigest md1=MessageDigest.getInstance("MD5");
    md1.update("srikrishna".getBytes());byte[] digest1=md1.digest();
    byte salt1[]=new byte[8];
    for(int i=0;i<8;i++)
         salt1[i]=digest1[i];
    PBEParameterSpec ps1=new PBEParameterSpec(salt1,20);
    Cipher cf1=Cipher.getInstance("PBEWithMD5AndDES");
    cf1.init(Cipher.DECRYPT_MODE, ky1,ps1);
    byte[]thPt=cf1.doFinal(thCp);
    for(int i=0;i<thPt.length;i++)
         System.out.print((char)thPt[i]);
    catch(Exception e)
         e.printStackTrace();
    Thanks in Advance.............
    Edited by: hareksna on Jan 12, 2009 4:36 PM

    hareksna wrote:
    sir, thanks for reply.........
    I understood .....
    sorry if am asking u once again.......
    for every encrypted data there will be an corresponding decrypted data.........even with the different key.....it shud produce some decrypted bytes.(even diff from plain text)......naa.....i.e it should produce the wrong plain text.......The encyption process -
    cleartext (adding padding) padded cleartext (encrypting) ciphertext.
    The decryption process -
    ciphertext (decrypting) padded cleartext (remove padding) cleartext.
    Even though it would be gibberish when the wrong key is used, you seem to want access to the 'padded cleartext' but using your code you do not have access to it. You could emulate the PBE process and get access to the 'padded cleartext' but what would be the point. You would just have gibberish when using the wrong key.
    but y the exception......
    ok ......and also tell me y this BPE is actually happens and how to avoid that when we use some padding.....
    plz tell me the reason.............Start by reading "Applied Cryptography"by Bruce Schneier and then "Practical Cryptography" by Ferguson and Schneier.
    >
    so finally .........
    u r saying that i need to catch the BPE and should inform client that he entered wrong password........
    so i have to end up in the second step itself.....
    is there any other way to perfom this one?......if there, plz let me know....if any alternative.....As I said earlier, the alternative is to emulate the PBE process yourself but what would be the point. You would just end up with gibberish if you use the wrong password.
    P.S. You won't always get a bad padding exception if you use the wrong password. About 1in 256 you will just get gibberish as the result without the exception.
    P.P.S. Your keyboard seems to have a problem with it's '.' key. In your place I would get it fixed because the perpetual '......' annoys the hell out of many people who respond to these forums.
    P.P.P.S. Your 'caps' key seems to be intermittently broken. Please get if fixed.
    P.P.P.P.S. You should turn off your computer's SMS mode. Using 'u' instead of 'you' makes your posts very difficult to read and it annoys the hell out of many people who respond to these forums.

  • PBE; final block not properly padded help!

    Hi there,
    I'm having problems decrypting passwords using password based encryption (PBE), throwing me a "final block not properly padded" exception.
    The passwords are also encrypted uses PBE in a seperate class called the PasswordEncryption. The code necessary to generate the Cipher is in a seperate method which is passed a String to determined if it would be initialized in "encrypt" or "decrypt" mode.
    The class where the passwords are decrypted, UserManager, is passed the encrypted passwords as a String. It calls the PasswordEncryption class gets getcipher() to get the Cipher, and then decrypts the password. The data is read from the database by another class which reads database info, and passed in as a string to the decrypting class. The decrypting class converts the string to a byte[].
    Below I have the UserManager class and PasswordEncryption class:
    public class UserManager
    implements SecurityServerInterface, PETComponent {
    public UserManager() {
    private static String decryptPassword(String asPassword) throws
    SecurityException {
    PasswordEncryption passwordEncryption = new PasswordEncryption();
    Cipher pbeCipher = passwordEncryption.getCipher("decrypt");
    String clearText = new String();
    byte[] encryptedPassword = asPassword.getBytes();
    try {
    //This is where decryption failed! Given final block not properly padded
    byte[] cipherText = pbeCipher.doFinal(encryptedPassword);
    System.out.println(cipherText);
    System.out.println("test cipher text");
    clearText = new String(cipherText);
    System.out.println("original:" + asPassword);
    System.out.println("decrypted:" + clearText);
    catch (IllegalBlockSizeException e) {
    System.out.println(e.getMessage());
    String illegalBlock = e.getMessage();
    throw new SecurityException(illegalBlock);
    catch (BadPaddingException e) {
    System.out.println(e.getMessage());
    String badPadding = e.getMessage();
    throw new SecurityException(badPadding);
    catch(Exception e) {
    System.out.println(e.getMessage());
    String exception = e.getMessage();
    throw new SecurityException(exception);
    System.out.println(clearText);
    return clearText;
    public class PasswordEncryption {
    public static void main(String[] args) throws PETDBException,
    SecurityEncryptionException {
    PasswordEncryption encryptor = new PasswordEncryption();
    ArrayList mainList = encryptor.getAllPasswords();
    mainList = encryptor.encryptAllPasswords(mainList);
    encryptor.updateAllPasswords(mainList);
    public PasswordEncryption() {
    //Get passwords from the user table of the database, e.g, loginName and passwords
    private ArrayList getAllPasswords() throws PETDBException {
    ArrayList passwordList = new ArrayList();
    DBConnection.setConnection("jdbc:mysql://localhost/Mysql/data/pet?user=root&password=");
    DBConnection dbCon = DBConnection.createConnection();
    Connection con = dbCon.getConnection();
    System.out.println(con);
    try {
    String allPasswordQuery = " SELECT " + DBColumns.USPASSWD.trim() + " , " +
    DBColumns.USLOGINNAME.trim() + " from " + DBColumns.USER;
    Statement stmt = con.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery(allPasswordQuery);
    if (rs.isFirst()) {
    throw new PETDBException("No password found in the database.");
    while (rs.next()) {
    UserDO loUserDO = new UserDO();
    loUserDO.setPassword(rs.getString(DBColumns.USPASSWD));
    loUserDO.setLoginName(rs.getString(DBColumns.USLOGINNAME));
    passwordList.add(loUserDO);
    catch (SQLException sql) {
    String sqlError = sql.getMessage();
    throw new PETDBException(sqlError);
    return passwordList;
    private ArrayList encryptAllPasswords(ArrayList aoPasswordList) throws
    SecurityEncryptionException {
    // Encrypt the password
    Cipher pbeCipher = getCipher("encrypt");
    Iterator passwordIterator = aoPasswordList.iterator();
    UserDO loUserDO = new UserDO();
    try {
    while (passwordIterator.hasNext()) {
    loUserDO = (UserDO) passwordIterator.next();
    String lsPassword = loUserDO.getPassword();
    byte[] clearTextPassword = lsPassword.getBytes();
    byte[] cipherText = pbeCipher.doFinal(clearTextPassword);
    String cipherString = new String(cipherText);
    loUserDO.setPassword(cipherString);
    System.out.println(cipherString);
    catch (IllegalBlockSizeException e) {
    throw new SecurityException("Can't encrypt password, illegal block size");
    catch (BadPaddingException e) {
    throw new SecurityException("Can't encrypt password, bad padding");
    System.out.println(aoPasswordList);
    return aoPasswordList;
    public Cipher getCipher(String mode) {
    PBEKeySpec pbeKeySpec;
    PBEParameterSpec pbeParamSpec;
    SecretKeyFactory keyFac;
    // Salt
    byte[] salt = {
    (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
    (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
    // Iteration count
    int count = 20;
    // Create PBE parameter set & a SecretKey
    pbeParamSpec = new PBEParameterSpec(salt, count);
    SecretKey pbeKey;
    // Use our own encryption password.
    // Collect the password as char array and convert
    // it into a SecretKey object, using a PBE key
    // factory.
    char[] password = new String("cmuw-team5").toCharArray();
    pbeKeySpec = new PBEKeySpec(password);
    try {
    keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
    pbeKey = keyFac.generateSecret(pbeKeySpec);
    catch (NoSuchAlgorithmException e) {
    throw new SecurityException("Can't collect password as a char array");
    catch (InvalidKeySpecException e) {
    throw new SecurityException("Can't convert password into a SecretKey Object");
    // Create PBE Cipher
    Cipher pbeCipher;
    try {
    pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
    catch(NoSuchAlgorithmException e) {
    throw new SecurityException("Can't create a PBE Cipher, no such algorithm");
    catch(NoSuchPaddingException e) {
    throw new SecurityException("Can't create a PBE Cipher, no such padding");
    // Initialize PBE Cipher with key and parameters
    if (mode == "encrypt") {
    try {
    pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
    catch(InvalidKeyException e) {
    throw new SecurityException("Can't initialize PBE Cipher with key");
    catch(InvalidAlgorithmParameterException e) {
    throw new SecurityException("Can't initialize PBE Cipher with parameters");
    if (mode == "decrypt") {
    try {
    pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);
    catch(InvalidKeyException e) {
    throw new SecurityException("Can't initialize PBE Cipher with key");
    catch(InvalidAlgorithmParameterException e) {
    throw new SecurityException("Can't initialize PBE Cipher with parameters");
    return pbeCipher;
    //Get encrypted passwords out of the ArrayList and update the database
    private void updateAllPasswords(ArrayList aoUpdatePasswordList) throws
    PETDBException {
    DataService dataService = new DataService();
    Iterator getEncryptPassword = aoUpdatePasswordList.iterator();
    String lsUpdatePassword = new String();
    String lsUserName = new String();
    Statement stmt;
    DBConnection dbCon = DBConnection.createConnection();
    Connection con = dbCon.getConnection();
    try {
    stmt = con.createStatement();
    System.out.println(stmt);
    catch (SQLException sql) {
    String sqlError = sql.getMessage();
    System.out.println(sqlError);
    throw new PETDBException(sqlError);
    while (getEncryptPassword.hasNext()) {
    UserDO loUser = (UserDO) getEncryptPassword.next();
    lsUpdatePassword = loUser.getPassword();
    lsUserName = loUser.getLoginName();
    String allUpdatePassword = " UPDATE " + DBColumns.USER + " SET " +
    DBColumns.USPASSWD + " = " + "'" + lsUpdatePassword + "'" + " WHERE "
    + DBColumns.USLOGINNAME + " = " + "'" + lsUserName + "'";
    System.out.println(allUpdatePassword);
    try {
    int returnValue = stmt.executeUpdate(allUpdatePassword);
    System.out.println(returnValue);
    catch (SQLException sql) {
    String sqlError = sql.getMessage();
    throw new PETDBException(sqlError);
    try {
    con.commit();
    con.close();
    catch (SQLException sql) {
    String sqlError = sql.getMessage();
    throw new PETDBException(sqlError);

    Thanks for the prompt response! I got this example
    from the Sun Java cryptography extensions web page at:
    http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/
    CERefGuide.html#PBEExThe code I'm pointing out did not come from there. Nowhere in Sun's examples do you see them creating Strings directly from ciphertext. (Which is good, because if you did, their examples wouldn't work). To give some more context on where the problem is:private ArrayList encryptAllPasswords(ArrayList aoPasswordList) throws SecurityEncryptionException {
      // Encrypt the password
      Cipher pbeCipher = getCipher("encrypt");
      Iterator passwordIterator = aoPasswordList.iterator();
      UserDO loUserDO = new UserDO();
      try {
        while (passwordIterator.hasNext()) {
          loUserDO = (UserDO) passwordIterator.next();
          String lsPassword = loUserDO.getPassword();
          byte[] clearTextPassword = lsPassword.getBytes();
          byte[] cipherText = pbeCipher.doFinal(clearTextPassword);
          // DOING THE FOLLOWING TO CIPHERTEXT TURNS IT INTO GARBAGE!
          String cipherString = new String(cipherText);
          loUserDO.setPassword(cipherString);
          System.out.println(cipherString);
      } catch (IllegalBlockSizeException e) {
        throw new SecurityException("Can't encrypt password, illegal block size");
      } catch (BadPaddingException e) {
        throw new SecurityException("Can't encrypt password, bad padding");
      System.out.println(aoPasswordList);
      return aoPasswordList;
    }(Note: Please use the [ code ] tags when you post code - it makes it MUCH easier to figure out what you're doing.)
    Also, my decryption code in the UserManager class does
    work for two out of 8 users....I can't really figure
    out why it's working for Only 2 users, and not the
    rests. It's possible that the ciphertext is successfully string-able in those two cases (although I doubt it). But I can absolutely guarantee to you that trying to treat ciphertext as a String will turn your ciphertext into grabage, and that will result in a BadPaddingException when you decrypt. You need to stop doing that.
    If you need to treat ciphertext or keys as Strings, the right way to do it is to Base64-encode the byte[] into a String, and then Base64-decode when you want to decrypt.
    Grant

  • Given final block not properly padded

    I am working on an application that sends encrypted data over the network using Blowfish. I developed a simple server and client to test and I getting this error when I try to decrypt the cypher in the server. Here is what I do:
    This happens on the client side:
    I encrypt my message with this method
    public byte[] encryptedMessage() throws Exception{
            KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
            keyGenerator.init(128);     
            Key key = keyGenerator.generateKey();
            Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
            cipher.init(Cipher.ENCRYPT_MODE, key);
            byte[] plaintext = getMessage().getBytes("UTF8");
            byte[] ciphertext = cipher.doFinal(plaintext);
            return ciphertext;
        }Then send it to the server like this:
    //get my cypher from the method shown before
    cipher = mc.encryptedMessage();
    //put the cypher in this simple object          
    InformationShared cipherToSend = new InformationShared(cipher.length);
    cipherToSend.setMessage(cipher);
    //Send it accross through the network
    Socket socket =  new Socket("127.0.0.1",8085);
    ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
    out.writeObject(cipherToSend);This is what happens in the server side:
    //Get the incoming object
    ObjectInputStream in = new ObjectInputStream( incoming.getInputStream() );
    //downcast the object
    InformationShared cipherIn = (InformationShared)in.readObject();
    //decypher the message  in the decypher method             
    String result = decypher(cipherIn.getMessage());
    //This is the decipher method
    public String decypher(byte cipherIn[]) throws Exception{
               KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
               keyGenerator.init(128);     // need to initialize with the keysize
               Key key = keyGenerator.generateKey();
               Cipher ciph = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
               ciph.init(Cipher.DECRYPT_MODE, key);
               // Perform the decryption
               byte[] decryptedText = ciph.doFinal(cipherIn);
               String output = new String(decryptedText,"UTF8");;
               return output;
            }The error happens in the decypher method in this line:
    byte[] decryptedText = ciph.doFinal(cipherIn);Thanks for any help!

    Hi
    I am woriking on an web application that send Encrypted data over the network and stores into the databse.After that I want to retrieve that data from database then I want decrypt it by using DES.
    After Encryting It is storing properly into the database but while retriving from database and want to decrypt it the It is giving exception like "javax.crypto.BadPaddingException: Given final block not properly padded"
    For Encryption I am using one bean class tha are
    package EncryptBean;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.spec.*;
    import com.sun.crypto.provider.*;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    import javax.crypto.Cipher;
    import java.security.NoSuchAlgorithmException;
    import java.security.InvalidKeyException;
    import java.security.InvalidAlgorithmParameterException;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.BadPaddingException;
    import javax.crypto.IllegalBlockSizeException;
    import sun.misc.BASE64Encoder;
    import sun.misc.BASE64Decoder;
    import javax.crypto.*;
    public class DesEncrypterBean {
    Cipher ecipher;
    Cipher dcipher;
    public DesEncrypterBean(SecretKey key) {
    try {
    ecipher = Cipher.getInstance("DES");
    dcipher = Cipher.getInstance("DES");
    ecipher.init(Cipher.ENCRYPT_MODE, key);
    dcipher.init(Cipher.DECRYPT_MODE, key);
    } catch(javax.crypto.NoSuchPaddingException e)
         {System.out.println("NoSuchPaddingException : "+e);     
                } catch (java.security.NoSuchAlgorithmException e)
    {System.out.println("NoSuchAlgorithmException : "+e);     
                } catch (java.security.InvalidKeyException e)
    {System.out.println("InvalidKeyException : "+e); }
    public String encrypt(String str) {
    try {
    // Encode the string into bytes using utf-8
    byte[] utf8 = str.getBytes("UTF8");
    // Encrypt
    byte[] enc = ecipher.doFinal(utf8);
    // Encode bytes to base64 to get a string
    return new sun.misc.BASE64Encoder().encode(enc);
    } catch (javax.crypto.BadPaddingException e) {
    System.out.println("encrypt BadPaddingException : "+e);
    } catch (IllegalBlockSizeException e) {
    System.out.println(" encrypt IllegalBlockSizeException : "+e);
    } catch (UnsupportedEncodingException e) {
    System.out.println("encrypt UnsupportedEncodingException : "+e);
    } catch (java.io.IOException e) {
    System.out.println("encrypt IOException : "+e);
    } return null;
    public String decrypt(String str) {
    try {
    // Decode base64 to get bytes
    // byte[] utf8 = str.getBytes("UTF8");
    byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
    // Decrypt
    byte[] utf8 = dcipher.doFinal(dec);
    // Decode using utf-8
    return new String(utf8, "UTF8");
    } catch (javax.crypto.BadPaddingException e)
         {System.out.println("encrypt BadPaddingException : "+e);
                } catch (IllegalBlockSizeException e) {
    System.out.println("encrypt IllegalBlockSizeException : "+e);
    } catch (UnsupportedEncodingException e) {
    System.out.println("encrypt UnsupportedEncodingException : "+e);
    }catch (java.io.IOException e) {
    System.out.println("encrypt IOException : "+e);
    return null;
    ** By using bellow screen I am retrieving the data from screen and encrypting it and sended to the database I is working properly
    import EncryptBean.DesEncrypterBean;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.spec.*;
    import com.sun.crypto.provider.*;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    import javax.crypto.Cipher;
    import java.security.NoSuchAlgorithmException;
    import java.security.InvalidKeyException;
    import java.security.InvalidAlgorithmParameterException;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.BadPaddingException;
    import javax.crypto.IllegalBlockSizeException;
    import sun.misc.BASE64Encoder;
    import javax.crypto.*;
    public class Secure_Encrypt extends HttpServlet
              Connection con=null;
              Statement stmt=null;
              Cipher ecipher;
    Cipher dcipher;
              String uname=null,pwd=null;
              ServletOutputStream sos;
              SecretKey key=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    uname=req.getParameter("username");               pwd=req.getParameter("password");
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:GMT","sa","iqm");
    stmt=con.createStatement();
    sos=res.getOutputStream();
    // Generate a temporary key. In practice, you would save this key.
    // See also e464 Encrypting with DES Using a Pass Phrase.
    key = KeyGenerator.getInstance("DES").generateKey();
    // Create encrypter/decrypter class
    DesEncrypterBean encrypter = new DesEncrypterBean(key);
    // Encrypt
    String encrypted = encrypter.encrypt(uname);
    System.out.println("Don't tell anybody! "+encrypted);
    stmt.execute("insert into Admin(UserName,Passward) values('"+encrypted+"','"+encrypted+"')");
    System.out.println("......record saved");
    sos.println("Record Saved : "+encrypted);
    catch(Exception e)
    {System.out.println("Exception in login" +e);}
    In above Programe Woking Properly
    ** Bellow programe using for retrieving data from database.After retrieving data I want Decrypt it but not working properly
    import EncryptBean.DesEncrypterBean;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.spec.*;
    import com.sun.crypto.provider.*;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    import javax.crypto.Cipher;
    import java.security.NoSuchAlgorithmException;
    import java.security.InvalidKeyException;
    import java.security.InvalidAlgorithmParameterException;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.BadPaddingException;
    import javax.crypto.IllegalBlockSizeException;
    import sun.misc.BASE64Encoder;
    import javax.crypto.*;
    public class Secure extends HttpServlet
              Connection con=null;
              Statement stmt=null;
              Cipher ecipher;
    Cipher dcipher;
              String uname=null,pwd=null;
              ServletOutputStream sos;
              SecretKey key=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    try
    {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:GMT","sa","iqm");
    stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select UserName,Passward from Admin");
    while(rs.next())
         uname=rs.getString(1);
         pwd=rs.getString(2);
    sos=res.getOutputStream();
    // Generate a temporary key. In practice, you would save this key.
    // See also e464 Encrypting with DES Using a Pass Phrase.
    key = KeyGenerator.getInstance("DES").generateKey();
    // Create encrypter/decrypter class
    DesEncrypterBean encrypter = new DesEncrypterBean(key);
    // Decrypt
    uname=uname.trim();
    String decrypted = encrypter.decrypt(uname);
    System.out.println("Original message is! "+decrypted);
    }catch(Exception e)
    {System.out.println("Exception in login" +e);
    In above Programe giving Exception " javax.crypto.BadPaddingException: Given final block not properly padded"
    Please analyze my application and send me suitable solution for decryption
    one more thing When I encrypting that time KeyGenerator generating one key.same as when I Decrypting that time also KeyGenerator generating one key but both are not same.
    How can we generate both key are same

  • Given final block not properly padded : PLEASE HELP!!

    hi guys
    please can you help me with the following error that i am getting.
    i appear to be encyrpting ok as image a am readin in and the file reading out are the same size.
    but i am getting this pading error. been at it all day and cant find the answer to this error.
    Exception: javax.crypto.BadPaddingException: Given final block not properly padd
    ed
    javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
    at javax.crypto.Cipher.doFinal(DashoA13*..)
    at Securitytest.decrypt(Securitytest.java:208)
    at Securitytest.byteConvert(Securitytest.java:117)
    at Securitytest.main(Securitytest.java:265)
    the code i am using is the following. please help me i am going mad! the iv is the same for reading in and out and the secret key appears to be the same.
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.PrintStream;
    import java.security.interfaces.RSAPrivateKey;
    import java.security.spec.PKCS8EncodedKeySpec;
    import java.security.spec.RSAPrivateKeySpec;
    import javax.imageio.stream.FileImageInputStream;
    import java.security.*;
    import java.io.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import sun.misc.*;
    import java.lang.*;
    public class Securitytest{
    public static void imageConvert( ) throws Exception {
    try{
    System.out.println("please select the file to encrypt");
    BufferedReader fileInput = new BufferedReader(new InputStreamReader(System.in));
    String filetoread = null;
    filetoread = fileInput.readLine();
    System.out.println("please select the file to save to");
    BufferedReader fileOutput = new BufferedReader(new InputStreamReader(System.in));
    String filetostore = null;
    filetostore = fileOutput.readLine();
    FileImageInputStream input = new FileImageInputStream(new File(filetoread));
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PrintStream stream = new PrintStream(output);
    byte[] buffer = new byte[1024];
    byte[] data = null;
    int numberBytesRead = 0;
    while ((numberBytesRead = input.read(buffer)) != -1)
    output.write(buffer, 0, numberBytesRead);
    data = output.toByteArray();
    System.out.println("encrytped" + buffer);
    System.out.println("going to encrypt");
    byte[] imageOutput = encrypt(data);
    System.out.println("back to imageconvert");
    System.out.println("encrytped" + buffer);
    FileOutputStream imageOut = new FileOutputStream(new File(filetostore));
    imageOut.write(imageOutput,0,imageOutput.length);
    imageOut.close();
    //BASE64Encoder encoder = new BASE64Encoder();
    //String enc = encoder.encodeBuffer(imageOutput);
    //FileWriter fw = new FileWriter(filetostore);
    FileOutputStream fos = new FileOutputStream(filetostore);
    fos.write(imageOutput);
    fos.close();
    System.out.println("sent to file");
    output.close();
    input.close();
    } catch(Exception ex) {
    System.out.println("Exception: " + ex);
    ex.printStackTrace();
    public static void byteConvert()throws Exception{
        try{
    System.out.println("please select the file to decrypt");
    BufferedReader fileInput = new BufferedReader(new InputStreamReader(System.in));
    String filetoread = null;
    filetoread = fileInput.readLine();
    System.out.println("please select the file to save to");
    BufferedReader fileOutput = new BufferedReader(new InputStreamReader(System.in));
    String filetostore = null;
    filetostore = fileOutput.readLine();
    FileInputStream fis = new FileInputStream(filetoread);
    byte[] decrypt = new byte[fis.available()];
    fis.read(decrypt);
    fis.close();
    //String dec = new String(decrypt);
    //BASE64Decoder decoder = new BASE64Decoder();
    //byte[] byteSeed = decoder.decodeBuffer(dec);
    // FileInputStream input = new FileInputStream(new File(filetoread));
    // ByteArrayOutputStream inStream = new ByteArrayOutputStream();
    // PrintStream stream = new PrintStream(inStream);
    // PrintStream stream = new PrintStream(input);
    // BASE64Decoder decoder = new BASE64Decoder();
    // String dec = decoder.decodeBuffer(stream);
    // String dec = new String(stream);
    // byte[] decryptionBytes = inStream;
    // byte[] s = decrypt(dec);
    // decryptionBytes =(byte [])stream.readStream();
    // stream.close();
    // for(int i=0; i < decryptionBytes.length; i++)
        // System.out.print(decryptionBytes);
    byte[] imageOutput = decrypt(decrypt);
    //byte[] imageOutput = decrypt(decrypt);
    FileOutputStream imageOut = new FileOutputStream(new File(filetostore));
    imageOut.write(imageOutput,0,imageOutput.length);
    imageOut.close();
        }catch(Exception ex) {
    System.out.println("Exception: " + ex);
    ex.printStackTrace();
    //new being used for AES
    public static byte[] encrypt(byte[] imageBytes) throws Exception {
    byte[] iv = new byte[] {(byte)0x2A, (byte)0x98, (byte)0xB2, (byte)0xBA, (byte)0x99, (byte)0xC0,
                (byte)0xF1, (byte)0x22, (byte)0x72, (byte)0x54, (byte)0xBC,
                (byte)0xB5, (byte)0x34, (byte)0x2F, (byte)0xBA, (byte)0xC4};
    byte[] encrypte = new byte[imageBytes.length];
    //System.out.println("Imagebyte length: " + imageBytes.length);
    System.out.println("in encrypt");
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    SecretKey secretKeySpec = AESkeyGeneration();
    //IvParameterSpec ivSpec = new IvParameterSpec();
    //Cipher.getIV()
    System.out.println("read out" + secretKeySpec);
    //IvParameterSpec iv = new IvParameterSpec(IV_BYTE_ARRAY);
    cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec (iv));
    //byte[] encrypted = cipher.doFinal(imageBytes);
    FileOutputStream fos = new FileOutputStream("c:/text.txt");
    CipherOutputStream cOut = new CipherOutputStream(fos, cipher);
                // Your plaintext MUST be multiple of 16 bytes because NoPadding requires your input text
                // to be a multiple of block size.
    cOut.write(imageBytes);
    cOut.close();
    return cipher.doFinal(imageBytes);
    //return encrypted;
    public static byte[] decrypt(byte[] bytesIn) throws Exception{
    byte[] iv = new byte[] {(byte)0x2A, (byte)0x98, (byte)0xB2, (byte)0xBA, (byte)0x99, (byte)0xC0,
                (byte)0xF1, (byte)0x22, (byte)0x72, (byte)0x54, (byte)0xBC,
                (byte)0xB5, (byte)0x34, (byte)0x2F, (byte)0xBA, (byte)0xC4};
    System.out.println("in decrypt");
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    System.out.println("cipher instance");
    SecretKey secretKeySpec = AESkeyGeneration();
    System.out.println("key" + secretKeySpec);
    System.out.println("keyRead in");
    //PrivateKey prvk = loadPrvkey();
    System.out.println("read out" + secretKeySpec);
    cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec (iv));
    System.out.println("Decrypt mode");
    return cipher.doFinal(bytesIn);
    //byte[] decodeData= cipher.doFinal(bytesIn);
    //return decodeData;
    private static SecretKeySpec AESkeyGeneration() {
    SecretKeySpec secretKeySpec = null;
    try {
    KeyGenerator kgen = KeyGenerator.getInstance("AES");
    kgen.init(128);
    SecretKey skey = kgen.generateKey();
    byte[] key = skey.getEncoded();
    secretKeySpec = new SecretKeySpec(key, "AES");
    FileOutputStream fosKey = new FileOutputStream ("c:/AES.key");
    fosKey.write (key);
    fosKey.close();
    }catch(Exception e) {
      System.out.println("error in keygen = "+e);
      return secretKeySpec;
    public static void main (String[] unused) throws Exception {
    System.out.println("***********************************************");
    System.out.println("***    Biometric Encrytion Program          ***");
    System.out.println("***********************************************");
    System.out.println("Please select a process");
    System.out.println("e for encryption ");
    System.out.println("d for decrytion");
    boolean choose = false;
    BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
    String choice = null;
    choice = userInput.readLine();
    if (choose = choice.equals("e")){
    imageConvert();
    System.out.println("Encryption");
    else
    System.out.println("Decryption");
    byteConvert();
    }

    sorry i misinterepreted something. that program failured for some input only

  • Can not catch exception in jsp?

    It sames that it is not a must to catch exception potentially throwed.The following snippet can work well.But if in a standard java file ,we should catch the naming exception.How to explain this phenomena?
    <%! int a=8;%>
              <%
              System.out.println("begin jsp");
              Hashtable h=new Hashtable();
              h.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
              h.put(Context.PROVIDER_URL,"jnp://127.0.0.1:1099");
              InitialContext ic=new InitialContext(h);
              CalcHome ch=(CalcHome) ic.lookup(CalcHome.JNDI_NAME);
              System.out.println("begin create cal");
              Calc c=ch.create();
              a=c.calcBonus(2,2);
              System.out.println(a);
              %>
              <%=a%>

    But don't forget to have isErrorPage="true" or it will ignore the try/catch, at least with my server (IPlanet).
    I have actually found it much nicer to have a full error page with JSP. All my JSP pages have errorPage set to an error.jsp and isErrorPage set to false.
    This means no try/catch blocks anywhere muddying up code. Just the error page has all the catches. I like it.

Maybe you are looking for

  • Disk can not be read from or written to

    This iPod nano second gen is brand new. Bought it today and I put like 10 songs and 10 photos on for my sister and now it's saying "disk can not be read from or written to" and now it's not showing up in iTunes or "My Computer". Help, please?

  • Why Won't my updated version of iMovie open up??

    Updated to iMovie 9.0.9, and now it will not open on my 2013 Mac Mini. It opens the iMovie window, says "Processing Event: New Event" then crashes and error reports, then when I click reopen it does the same thing. Would have included the error log h

  • Mavericks, illustrator 5.1 crashing a little AFTER launch.

    I just got a brand new macboook pro. I installed illustrator 5.1 from the original dmg I had on my old laptop, looked for illustrator updates (and found none?). I have no problem launching, but once I start working on a document (sometimes a few seco

  • 7iweb with keynote flash animation cannot open with IE6 or

    hello, i have a problem with my web site that i relaesed with i web and keynote. the problem is that i not can see the fkeynote aniamtion with an internet explorer browser. It's perfect working with safari , firefox & netscape...on mac or pc.... than

  • Ever since I installed apple lion

    Ever since I installed apple lion i have been unable to send mail on Version 5.1 (1251/1251.1), and only a limited number of my old e-mails trasferred over...can anybody help?