ErpConfigContext и ODataQueryBuilder выдают ошибку при попытке подключения через сервис Odata - PullRequest
3 голосов
/ 23 апреля 2019

Я пытаюсь создать приложение для облачного решения.При попытке запустить приложение локально я получил ошибку:

java.lang.NoClassDefFoundError:

com / sap / cloud / sdk / odatav2 / Connectivity / ODataException.

Это работает на сервере Tomee 7 веб-профиля Java EE 7.

Apr 22, 2019 3:48:33 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.center code hereoncurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at java.util.concurrent.FutureTask.report(FutureTask.java:122)
       at java.util.concurrent.FutureTask.get(FutureTask.java:192)
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
       at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       ... 6 more
Caused by: java.lang.NoClassDefFoundError: com/sap/cloud/sdk/odatav2/connectivity/ODataException
       at java.lang.Class.getDeclaredFields0(Native Method)
       at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
       at java.lang.Class.getDeclaredFields(Class.java:1916)
       at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:110)
       at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:269)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
       at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
       at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:768)
       at org.apache.catalina.startup.OpenEJBContextConfig.configureStart(OpenEJBContextConfig.java:124)
       at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
       at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 6 more
Caused by: java.lang.ClassNotFoundException: com.sap.cloud.sdk.odatav2.connectivity.ODataException
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
       at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:208)
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
       ... 20 more

Apr 22, 2019 3:48:33 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
       at java.util.concurrent.FutureTask.report(FutureTask.java:122)
       at java.util.concurrent.FutureTask.get(FutureTask.java:192)
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
       at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950)
       at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 6 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at java.util.concurrent.FutureTask.report(FutureTask.java:122)
       at java.util.concurrent.FutureTask.get(FutureTask.java:192)
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
       ... 8 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       ... 6 more
Caused by: java.lang.NoClassDefFoundError: com/sap/cloud/sdk/odatav2/connectivity/ODataException
       at java.lang.Class.getDeclaredFields0(Native Method)
       at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
       at java.lang.Class.getDeclaredFields(Class.java:1916)
       at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:110)
       at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:269)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
       at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
       at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:768)
       at org.apache.catalina.startup.OpenEJBContextConfig.configureStart(OpenEJBContextConfig.java:124)
       at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
       at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 6 more
Caused by: java.lang.ClassNotFoundException: com.sap.cloud.sdk.odatav2.connectivity.ODataException
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
       at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:208)
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
       ... 20 more

Apr 22, 2019 3:48:33 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950)
       at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 11 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
       at java.util.concurrent.FutureTask.report(FutureTask.java:122)
       at java.util.concurrent.FutureTask.get(FutureTask.java:192)
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
       ... 13 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420)
       at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950)
       at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 6 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at java.util.concurrent.FutureTask.report(FutureTask.java:122)
       at java.util.concurrent.FutureTask.get(FutureTask.java:192)
       at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
       ... 8 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WorkOrderDemo]]
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
       ... 6 more
Caused by: java.lang.NoClassDefFoundError: com/sap/cloud/sdk/odatav2/connectivity/ODataException
       at java.lang.Class.getDeclaredFields0(Native Method)
       at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
       at java.lang.Class.getDeclaredFields(Class.java:1916)
       at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:110)
       at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:269)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
       at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
       at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
       at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:768)
       at org.apache.catalina.startup.OpenEJBContextConfig.configureStart(OpenEJBContextConfig.java:124)
       at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
       at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       ... 6 more
Caused by: java.lang.ClassNotFoundException: com.sap.cloud.sdk.odatav2.connectivity.ODataException
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
       at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:208)
       at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
       ... 20 more

Локальное назначение для сервера настроено как ErpQueryEndpoint.Pom.xml также включает в себя groupID и artifactId для Odata подключения.Пакеты были импортированы.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                 // TODO Auto-generated method stub
                 //response.getWriter().append("Served at: ").append(request.getContextPath());
                 final ErpConfigContext configContext = new ErpConfigContext(ErpDestination.getDefaultName());
                 try {
                        final List<MyWorkOrderType> workOrders = ODataQueryBuilder
                                .withEntity("/sap/opu/odata/sap/ZCF_workorder_SRV",
                                        "WorkOrderSet")
                                .select("Aufnr",
                                        "Ktext",
                                        "Auart",
                                        "Asttx")
                                .build()
                                .execute(configContext)
                                .asList(MyWorkOrderType.class);
                 } catch (IllegalArgumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                 } catch (ODataException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                 }
           }

1 Ответ

4 голосов
/ 24 апреля 2019

Как я вижу из вашего кода, вы запрашиваете пользовательский сервис OData для SAP S / 4HANA.Для запросов OData к пользовательским службам OData вы также можете рассмотреть возможность использования Виртуальной модели данных (VDM) S / 4HANA Cloud SDK вместо ODataQueryBuilder.Чтобы использовать VDM с пользовательской службой OData, можно использовать генератор VDM, как описано в следующей записи блога .Кстати, это также работает для S / 4HANA On-Premise.Вы можете найти более подробную информацию о настройке здесь .

...