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

Cannot cast object BaseServiceInfo to S3ServiceInfo #7

Open
Omnipresent opened this issue Jan 6, 2017 · 1 comment
Open

Cannot cast object BaseServiceInfo to S3ServiceInfo #7

Omnipresent opened this issue Jan 6, 2017 · 1 comment

Comments

@Omnipresent
Copy link

Omnipresent commented Jan 6, 2017

I'm getting the following error on these lines of code

            BaseServiceInfo baseServiceInfo = cloud.getServiceInfo("upload-rw")
            log.info("This is the id: " + baseServiceInfo.getId())
            S3ServiceInfo serviceInfo = (S3ServiceInfo) baseServiceInfo
OUT org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 
     'org.springframework.cloud.service.BaseServiceInfo@4ad8f682' with class      
      'org.springframework.cloud.service.BaseServiceInfo' to class 
       'org.cloudfoundry.community.service.storage.S3ServiceInfo'

The log.info line actually does show the name of the service.

I'm getting this error in CloudFoundry while deploying at a customer site. Surprisingly this error doesn't happen when I deploy the same application locally on my PCFDev.

I see that S3ServiceInfo extends BaseServiceInfo so I don't see a reason for this error.

Are there any steps I can take to better troubleshoot this?

One difference I see in my local CF is when I run cf env myapp I see the following:

{
 "VCAP_SERVICES": {
  "amazon-s3": [
   {
    "credentials": {
     "access_key_id": "redacted",
     "bucket": "redacted",
     "host": "s3.amazonaws.com",
     "secret_access_key": "redacted",
     "uri": "redacted",
     "username": "redacted"
    },
    "label": "amazon-s3",
    "name": "upload-rw",
    "plan": "basic",
    "provider": null,
    "syslog_drain_url": null,

However, at customer site I see the following for the same cf env myapp command:

{
 "VCAP_SERVICES": {
  "aws-s3": [
   {
    "credentials": {
     "access_key_id": "redacted",
     "bucket": "redacted",
     "region": "us-east-1",
     "secret_access_key": "redacted"
    },
    "label": "aws-s3",
    "name": "upload-rw",
    "plan": "standard",
    "provider": null,
    "syslog_drain_url": null,

Notice the difference in label from amazon-s3 to aws-s3 and username property missing.

Would this cause the error that I'm getting? If so, is there a way I can still do to get the information like below?

S3ServiceInfo serviceInfo = (S3ServiceInfo) cloud.getServiceInfo("upload-rw")
def props =  [serviceInfo.getAccessKeyId(), serviceInfo.getSecretAccessKey()]
@Tanvishah1
Copy link

Tanvishah1 commented Oct 15, 2018

Even I am getting the same issue. Did you get any solution for this? @Omnipresent

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