on ‎2018 Mar 14 11:06 PM - last edited on ‎2024 Feb 04 3:18 AM by postmig_api_4
Hi,
I'm looking for answer of my trouble with running JAVA application on SAP Cloud Platform.
I need help to undestand what i'm doing wrong.
I use Eclipse Oxygen.2 Release (4.7.2) as development tool. Trying to get data using org.apache.http.client.HttpClient method.
I created marven project and use the next list of libraries:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
.classpath file contains :
classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/fluent-hc-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpclient-cache-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpclient-win-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.9.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/jna-4.4.0.jar"/>
<classpathentry kind="lib" path="lib/jna-platform-4.4.0.jar"/>
pom.xml file contains required dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.9</version>
</dependency>
Buildpath also contains all needed jar files:

The core logic of the application is:
HttpClient httpClient = null;
String destinationName = request.getParameter("destname");
try {
// Get HTTP destination
Context ctx = new InitialContext();
HttpDestination destination = null;
if (destinationName != null) {
DestinationFactory destinationFactory = (DestinationFactory) ctx.lookup(DestinationFactory.JNDI_NAME);
destination = (HttpDestination) destinationFactory.getDestination(destinationName);
} else {
destinationName = "SND";
destination = (HttpDestination) ctx.lookup("java:comp/env/" + destinationName);
}
Build of the Marven project is successfull:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.030 s
[INFO] Finished at: 2018-03-15T01:50:27+03:00
[INFO] Final Memory: 18M/80M
[INFO] --------------------------------------------------------------------
But when i try ot deply on the HANA Cloud Platform, server returns the error:
2018 03 14 22:10:39#+00#ERROR#org.apache.catalina.core.ContainerBase##anonymous#localhost-startStop-3#na#d9993445343ial#jcodemo#web##na#na#na#na#ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SAPAPI]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:807)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2532)
at java.lang.Class.getDeclaredFields(Class.java:1829)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:139)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:417)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:891)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5519)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 10 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
... 24 common frames omitted
I read all the stack overflow articles and tried all the variants that can be googled, but none of them helped.
What I'm doing wrong and where i should define dependencies, to make my code executable.
I will be grateful for any idea.
Many thanks.
Request clarification before answering.
Hi Andy,
Please try to add below contents into pom.xml then try again to see if the issue could be solved.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.