Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload is failing - 500 internal server error #4

Closed
manjunathgudisi opened this issue Jun 26, 2020 · 6 comments
Closed

upload is failing - 500 internal server error #4

manjunathgudisi opened this issue Jun 26, 2020 · 6 comments

Comments

@manjunathgudisi
Copy link

Screen Shot 2020-06-26 at 3 59 21 PM

I'm getting 500 internal server error. Here is the log
cf log app_name

Any help where I'm doing wrong.

C02Z2D46LVCG:cloud-objectstore-java-sample i302342$ cf logs objectstore-sample-svc
Retrieving logs for app objectstore-sample-svc in org in-demos-org / space demos as manjunath.gudisi@sap.com...

2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT 2020-06-26 10:24:14.996 ERROR 6 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: identity] with root cause
2020-06-26T15:54:14.99+0530 [RTR/4] OUT i302342-objectstore-sample-svc.cfapps.eu10.hana.ondemand.com - [2020-06-26T10:24:13.463510818Z] "POST /objectstorage.svc/api/v1/storage/ HTTP/1.1" 500 155045 154 "-" "PostmanRuntime/7.25.0" "-" "10.0.138.188:61037" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"0c1375a1-a8e0-41b0-450b-1f12f0785211" response_time:1.536086 gorouter_time:0.000189 app_id:"b6990b82-d375-40c7-ace1-a5840d74309c" app_index:"0" x_correlationid:"-" tenantid:"-" x_scp_request_id:"cf67bb70-e4e4-427d-abc2-cc0a032daec4-5EF5CCCC-B36EF5" x_cf_app_instance:"-" x_b3_traceid:"3a7889186484db24" x_b3_spanid:"3a7889186484db24" x_b3_parentspanid:"-" b3:"3a7889186484db24-3a7889186484db24"
2020-06-26T15:54:14.99+0530 [RTR/4] OUT
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT java.lang.NullPointerException: identity
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:895) ~[guava-27.0.1-jre.jar:na]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.jclouds.ContextBuilder.credentials(ContextBuilder.java:259) ~[jclouds-core-2.2.0.jar:2.2.0]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at com.sap.refapps.objectstore.config.AmazonWebServiceConfiguration.getBlobStoreContext(AmazonWebServiceConfiguration.java:53) ~[classes/:na]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at com.sap.refapps.objectstore.service.AWSObjectStoreService.uploadFile(AWSObjectStoreService.java:35) ~[classes/:na]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at com.sap.refapps.objectstore.controller.ObjectstoreController.uploadFile(ObjectstoreController.java:84) ~[classes/:na]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.cloudfoundry.router.ClientCertificateMapper.doFilter(ClientCertificateMapper.java:79) ~[client_certificate_mapper-1.11.0_RELEASE.jar:na]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_252]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.30.jar:9.0.30]
2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT at java.lang.Thread.run(Thread.java:748) [na:1.8.0_252]

@manjunathgudisi
Copy link
Author

BTW, I have created only aws-s3 instance. No GCP.

@biswaranjanray
Copy link
Contributor

biswaranjanray commented Jun 26, 2020

Hi Manjuath,

From the logs its evident that the objectstore credentials which are required to configure AmazonWebServiceConfiguration.java class are not able to be injected from the VCAP_SERVICE and so its throwing the error: 2020-06-26T15:54:14.99+0530 [APP/PROC/WEB/0] OUT java.lang.NullPointerException: identity

Could you please verify the service-instance name you would have created in aws landscape.
For instance if the service-instance name is "objectstore-service" the same instance name should be used in the manifest.yaml file as well as in the AmazonWebServiceConfiguration.java class at the given line:
@ConfigurationProperties(prefix = "vcap.services.objectstore-service.credentials")

The same information can also be found in readme in step 2 here.

Thanks

@manjunathgudisi
Copy link
Author

manjunathgudisi commented Jun 27, 2020

Hi-
Thanks for your reply.
Yes, I have used the same service name.

I have created aws-s3 as instance of objectstore with s3-standard plan.

Screen Shot 2020-06-27 at 1 01 01 PM

Same instance name I have used in AmazonWebServiceConfiguration.java

```public BlobStoreContext getBlobStoreContext() {
	return ContextBuilder.newBuilder("aws-s3").credentials(this.getAccessKeyId(), this.getSecretAccessKey())
			.buildView(BlobStoreContext.class);
}```

and also, in yaml file

applications:
- name: objectstore-sample-svc
  host: i302342-objectstore-sample-svc
  memory: 2G
  buildpack: https://github.com/cloudfoundry/java-buildpack.git
  path: target/objectstore-sample-1.0.0.jar
  services:
    - aws-s3

I think Im doing it correctly.

@biswaranjanray
Copy link
Contributor

biswaranjanray commented Jun 28, 2020

Hi,

As I mentioned in my previous reply the service-instance that you have created as "aws-s3" should match in two places:

  1. manifest.yaml (You did it correctly)
  2. At @ConfigurationProperties(prefix = "vcap.services.aws-s3.credentials") in AmazonWebServiceConfiguration.java class (Have you changed this as well?)

You've placed the instance name in the below code which is not correct.

public BlobStoreContext getBlobStoreContext() {
	return ContextBuilder.newBuilder("aws-s3").credentials(this.getAccessKeyId(), this.getSecretAccessKey())
			.buildView(BlobStoreContext.class);
}


The job of the above code is to configure aws provider with the objectstore credentials which application automatically injects from VCAP_SERVICES. Please don't change the getBlobStoreContext() method.

Thanks

@manjunathgudisi
Copy link
Author

Yes, thanks for rectifying my mistake. Its working fine now after changing,
from
"vcap.services.objectstore-service.credentials"
to
"vcap.services.aws-s3.credentials"

@biswaranjanray
Copy link
Contributor

Thanks for your confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants