Spring Web MVC项目中的Dropbox V1到V2迁移错误

时间:2016-08-26 09:51:46

标签: spring dropbox

根据Dropbox API V2(dropbox-core-sdk-2.1.1.jar) tutorial,我已在Java控制台应用程序中迁移,如以下代码所示。

Aug 26, 2016 3:18:30 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/dropboxz] threw exception [Handler processing failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
java.lang.RuntimeException: Error loading version from resource "sdk-version.txt": Text doesn't follow expected pattern: "${project.version}"
    at com.dropbox.core.DbxSdkVersion.loadVersion(DbxSdkVersion.java:66)
    at com.dropbox.core.DbxSdkVersion.<clinit>(DbxSdkVersion.java:17)
    at com.dropbox.core.DbxRequestUtil.buildUserAgentHeader(DbxRequestUtil.java:144)
    at com.dropbox.core.DbxRequestUtil.addUserAgentHeader(DbxRequestUtil.java:129)
    at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:226)
    at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:100)
    at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:252)
    at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:97)
    at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:629)
    at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:656)
    at com.doj.spring4.controller.HelloSpring4Controller.viewDropboxLoginScreen(HelloSpring4Controller.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:445)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:433)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:947)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:878)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:946)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:822)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

以上代码编译并运行完美。但是我在Spring Web应用程序中实现了相同的代码。但它不起作用,只抛出以下异常。

ticket_number[int(11)], datetime_created[datetime], requester[int(11)], title[longtext], description[longtext], followup_datetime[datetime], last_followup[longtext], technician_user[int(11)]

请给出解决方案。

1 个答案:

答案 0 :(得分:0)

这个错误来自:

https://github.com/dropbox/dropbox-sdk-java/blob/3cfa878e5d73f06ed4782c8833b229838fd21472/src/main/java/com/dropbox/core/DbxSdkVersion.java#L66

所以,它看起来像你的&#34; sdk-version.txt&#34;文件包含&#34; $ {project.version}&#34;当一个数字是预期的。

sdk-version.txt文件最初包含该字符串:

https://github.com/dropbox/dropbox-sdk-java/blob/af7a43e691dccc95eca0a591f7d61250c16db314/src/main/resources/sdk-version.txt

但是,它应该在gradle构建期间替换:

https://github.com/dropbox/dropbox-sdk-java/blob/af7a43e691dccc95eca0a591f7d61250c16db314/build.gradle#L96

因此,听起来您的Spring Web应用程序中没有发生gradle构建。