我已经创建了一个 OSGI 包并部署在 karaf 上,它将文件上传到 Azure blob。(比如说 B1)我还有另一个用于其他功能的包。(比如说 B2)
现在,当我单独部署 B1 时,它工作正常,当我同时部署 B1 和 B2 包时,我的上传包给了我以下异常。
2013-08-26 20:09:45,633[qtp26738776-145]|DEBUG|<My_Pack>fileupload.service.uploadservice.impl.UploadServiceImpl|Exception while uploading a file java.lan
g.IllegalArgumentException: Null InputStream is not a valid argument
java.lang.IllegalArgumentException: Null InputStream is not a valid argument
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:595)
at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:309)
at com.microsoft.windowsazure.services.core.storage.utils.Utility.createXMLStreamReaderFromStream(Utility.java:327)
at com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse.<init>(StorageErrorResponse.java:59)
at com.microsoft.windowsazure.services.core.storage.StorageException.getErrorDetailsFromRequest(StorageException.java:54)
at com.microsoft.windowsazure.services.core.storage.StorageException.translateException(StorageException.java:85)
at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.java:147)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer.createIfNotExist(CloudBlobContainer.java:339)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer.createIfNotExist(CloudBlobContainer.java:257)
at <My_Pack>fileupload.service.uploadservice.impl.UploadServiceAzureProcess.uploadFileWithDetails(UploadServiceAzureProcess.java:82)
at <My_Pack>fileupload.service.uploadservice.impl.UploadServiceImpl.uploadFile(UploadServiceImpl.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:193)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1040)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:976)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:363)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
以下是我得到该异常的代码。
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Create the container if it does not exist. NOTE: The container name must be lower case.
CloudBlobContainer container = blobClient.getContainerReference(containerName);
container.createIfNotExist();
logger.debug("Uploading...");
uploadMyBlob(container.getName(),blobClient,fileName,fileSize,stream);
logger.debug("Uploaded...");
我在container.createIfNotExist();
尝试寻找原因时遇到了异常,我遇到了这个但找不到解决方案:(
以下是 B1 的 pom 依赖项 xml
<dependencies>
<!-- Microsoft related dependencies START -->
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>${com.microsoft.windowsazure.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${org.codehaus.jackson.version}</version>
</dependency>
<!-- i tried adding following too
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency> -->
<!-- Microsoft related dependencies END -->
<!-- Other dependencies START -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<!-- Other dependencies END -->
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
<My_Pack>.fileupload.service.uploadService
</Export-Package>
<Import-Package>
org.codehaus.jackson.jaxrs;version="1.9.2",
com.microsoft.windowsazure.services.blob.client<!-- ;version="0.4.2" -->,
com.microsoft.windowsazure.services.core.storage<!-- ;version="0.4.2" -->,
javax.servlet.http;version="2.4",
javax.ws.rs;version="2.0-m02",
javax.ws.rs.core;version="2.0-m02",
org.apache.commons.fileupload;version="1.2.1",
org.apache.commons.fileupload.disk;version="1.2.1",
org.apache.commons.fileupload.servlet;version="1.2.1",
org.slf4j;version="1.6.0",
org.springframework.beans.factory.config
</Import-Package>
<Embed-Dependency>
<!-- jackson-jaxrs -->
</Embed-Dependency>
<Bundle-ClassPath>.</Bundle-ClassPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
以下是捆绑 B2 的 pom 依赖项
<dependencies>
<!-- WSO2 Dependencies -->
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.identity.entitlement.stub</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.um.ws.api</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.authenticator.stub</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.wso2.securevault</groupId>
<artifactId>org.wso2.securevault</artifactId>
<version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<!-- End of WSO2 dependencies -->
<!-- Apache dependencies for WSO2 -->
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
<version>1.2.11.wso2v2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.1.wso2v5</version>
</dependency>
<dependency>
<groupId>org.apache.axiom.om.util</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema.wso2</groupId>
<artifactId>XmlSchema</artifactId>
<version>1.4.7.wso2v2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.neethi.wso2</groupId>
<artifactId>neethi</artifactId>
<version>2.0.4.wso2v4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.wso2</groupId>
<artifactId>httpcore</artifactId>
<version>4.1.0-wso2v1</version>
</dependency>
<!-- End of Apache dependecies for WSO2 -->
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- End of Spring dependencies -->
<!-- Spring OSGi framework dependencies -->
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-core</artifactId>
<version>${spring-osgi-version}</version>
<exclusions>
<exclusion>
<artifactId>org.springframework.aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework.beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework.context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework.core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- End of Spring OSGi framework dependencies -->
<!-- Jackson dependencies -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.7</version>
</dependency>
<!-- End of Jackson dependencies -->
<!-- Jasypt dependencies -->
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>${jasypt.version}</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-spring31</artifactId>
<version>${jasypt.version}</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-spring3</artifactId>
<version>${jasypt.version}</version>
</dependency>
<!-- End of Jasypt dependencies -->
<!-- Other third party dependencies -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0-m02</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
<My_Pack>.security.*
</Export-Package>
<Import-Package>
org.osgi.framework;version="[1.5,2.0)",
org.osgi.service.*;version="[1.0, 2.0)",
org.codehaus.jackson,
org.codehaus.jackson.map,
org.codehaus.jackson.jaxrs;version="1.9.7",
org.apache.cxf.jaxrs.provider;version="${org.apache.cxf.version}",
org.apache.cxf.jaxrs.client;version="${org.apache.cxf.version}",
javax.ws.rs.*;version="[1.0,2)",
javax.xml.namespace.*,
org.apache.commons.httpclient.*; version="3.1.0",
org.xml.sax.*,
org.w3c.dom.*,
javax.xml.stream;version="1.0.1",
javax.xml.stream.events;version="1.0.1",
javax.xml.stream.util;version="1.0.1",
javax.xml.bind.*;version="2.1.0";resolution:=optional,
javax.xml.datatype,
javax.xml.parsers,
javax.xml.transform.*,
javax.xml.validation,
javax.xml.xpath,
javax.xml,
javax.sql.*,
*;resolution:=optional
</Import-Package>
<Embed-Dependency>
org.wso2.carbon.um.ws.api,
org.wso2.carbon.authenticator.stub,
org.wso2.carbon.identity.entitlement.stub,
org.wso2.carbon.user.core,
org.wso2.carbon.user.api,
org.wso2.securevault,
axiom,
axis2,
httpcore,
XmlSchema,
neethi
</Embed-Dependency>
<Bundle-ClassPath>.</Bundle-ClassPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>