michaelrice/grails-jsch-ssh2

ScpFileTo().execute() always fails with exception

Opened this issue · 5 comments

execute() always causing: com.jcraft.jsch.JSchException: There was an error opening the initial input stream.

Code is virtually identical to example snippet:

		try {
			new ScpFileTo().execute() {
				host = credentials.host
				username = credentials.user
				password = credentials.password
				localFile = file.getAbsolutePath()
				remoteFile = filename
				strictHostKeyChecking = "no"
				knownHostsFile = null
			}
		} catch (JSchException e) {
			LOGGER.error("KalturaAPIService.scpFileToIIQ error: " + e)
			println "KalturaAPIService.scpFileToIIQ error: ${e}"
		}

"file" is an existing file that I want to copy. the credentials are all valid.

Can you provide the full stack trace? I use this in lots of places that run almost constantly so it makes me think you may have some kind of permission issue or something and it may show in the full stack trace.

Stack trace:

Error |
com.jcraft.jsch.JSchException: There was an error opening the initial input stream.
Error |
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Error |
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Error |
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Error |
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Error |
	at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:986)
Error |
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
Error |
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
Error |
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
Error |
	at com.toastcoders.jschssh.ScpFileTo.execute(ScpFileTo.groovy:91)
Error |
	at com.toastcoders.jschssh.ScpFileTo.execute(ScpFileTo.groovy:66)
Error |
	at com.toastcoders.jschssh.ScpFileTo$execute.call(Unknown Source)
Error |
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService.$tt__scpFileToIIQ(KalturaAPIService.groovy:76)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService$_scpFileToIIQ_closure2.doCall(KalturaAPIService.groovy)
Error |
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error |
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error |
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error |
	at java.lang.reflect.Method.invoke(Method.java:606)
Error |
	at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Error |
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
Error |
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
Error |
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
Error |
	at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
Error |
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
Error |
	at groovy.lang.Closure.call(Closure.java:411)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService$_scpFileToIIQ_closure2.call(KalturaAPIService.groovy)
Error |
	at groovy.lang.Closure.call(Closure.java:427)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService$_scpFileToIIQ_closure2.call(KalturaAPIService.groovy)
Error |
	at org.codehaus.groovy.grails.orm.support.GrailsTransactionTemplate$1.doInTransaction(GrailsTransactionTemplate.groovy:62)
Error |
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
Error |
	at org.codehaus.groovy.grails.orm.support.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:59)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService.scpFileToIIQ(KalturaAPIService.groovy)
Error |
	at com.nationwide.ea.mcc.inside.KalturaAPIService$scpFileToIIQ$0.call(Unknown Source)
Error |
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
Error |
	at com.nationwide.ea.mcc.inside.KalturaUserController.sendKMCUsersFileToIIQ(KalturaUserController.groovy:24)
Error |
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error |
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error |
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error |
	at java.lang.reflect.Method.invoke(Method.java:606)
Error |
	at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper.invoke(MixedGrailsControllerHelper.java:154)
Error |
	at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.invoke(ProxyAwareMixedGrailsControllerHelper.java)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleAction(AbstractGrailsControllerHelper.java:354)
Error |
	at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleAction(ProxyAwareMixedGrailsControllerHelper.java)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.executeAction(AbstractGrailsControllerHelper.java:231)
Error |
	at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.executeAction(ProxyAwareMixedGrailsControllerHelper.java)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:197)
Error |
	at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleURI(ProxyAwareMixedGrailsControllerHelper.java)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:121)
Error |
	at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleURI(ProxyAwareMixedGrailsControllerHelper.java)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:72)
Error |
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
Error |
	at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:355)
Error |
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
Error |
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
Error |
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
Error |
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
Error |
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
Error |
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
Error |
	at grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter.doFilter(MemoryPageFragmentCachingFilter.java)
Error |
	at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
Error |
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
Error |
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
Error |
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
Error |
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
Error |
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
Error |
	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:332)
Error |
	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:297)
Error |
	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:288)
Error |
	at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:217)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.executeFilterChainWithWrappedResponse(GrailsPageFilter.java:233)
Error |
	at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:208)
Error |
	at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:153)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at javax.servlet.FilterChain$doFilter.call(Unknown Source)
Error |
	at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanityFilter.groovy:45)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
Error |
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Error |
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
Error |
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
Error |
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
Error |
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
Error |
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
Error |
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
Error |
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
Error |
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
Error |
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
Error |
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
Error |
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
Error |
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
Error |
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
Error |
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
Error |
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
Error |
	at java.lang.Thread.run(Thread.java:745)

Are you running the tomcat server on linux or windows?

It gives the error on MacOS, and also when I deploy via ear file to WAS on linux.

One thing leading to the exception is in ConnectionInfo.checkAck(), line 185, b is -1 value:

    int checkAck(InputStream inputStream ) throws IOException {
        int b = inputStream.read()

Is the specified input file already supposed to be open and the data being read at that time? There shouldn't be any issue opening the file at this point, so I am not sure what is going on there.