JetS3t - connects without exception, but “Invalid Class Name” when I try to do anything else

StackOverflow https://stackoverflow.com/questions/10144188

  •  31-05-2021
  •  | 
  •  

Question

I appear to be able to connect fine since new RestS3Service doesn't throw an exception.

However, when I try to do something like getBucket("name"), then I get: Invalid class name: org.jets3t.service.utils.RestUtils$ConnManagerFactory

Any idea how to solve this?

Thanks!

My code:

    AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey);
    S3Service s3Service = null;

    System.out.println("Credentials created, trying Service");

    try {
        s3Service = new RestS3Service(awsCredentials);
    } catch (S3ServiceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    System.out.println("Service connected, trying bucket grab");

    try {
        S3Bucket bucket = s3Service.getBucket("mrbucket");
        System.out.println("bucket grabbed: "+bucket.getName());
    } catch (S3ServiceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Output:

Credentials created, trying Service

Installer - Installer service created

Service connected, trying bucket grab

org.jets3t.service.S3ServiceException: Request Error: java.lang.IllegalStateException: Invalid class name: org.jets3t.service.utils.RestUtils$ConnManagerFactory
  at org.jets3t.service.S3Service.getBucket(S3Service.java:1911)
  at org.red5.core.Application.myFunction(Application.java:78)
  at org.red5.core.Application.appStart(Application.java:42)
  at org.red5.server.adapter.MultiThreadedApplicationAdapter.start(MultiThreadedApplicationAdapter.java:408)
  at org.red5.server.adapter.ApplicationAdapter.start(ApplicationAdapter.java:54)
  at org.red5.server.Scope.start(Scope.java:1170)
  at org.red5.server.Scope.init(Scope.java:905)
  at org.red5.server.WebScope.register(WebScope.java:207)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
  at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:577)
Caused by: java.lang.IllegalStateException: Invalid class name: org.jets3t.service.utils.RestUtils$ConnManagerFactory
  at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:308)
  at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
  at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:274)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:797)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
  at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:334)
  at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:281)
  at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRestGet(RestStorageService.java:981)
  at org.jets3t.service.impl.rest.httpclient.RestStorageService.listAllBucketsImpl(RestStorageService.java:1373)
  at org.jets3t.service.StorageService.listAllBucketsImpl(StorageService.java:1379)
  at org.jets3t.service.StorageService.listAllBuckets(StorageService.java:563)
  at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:1367)
  at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:84)
  at org.jets3t.service.StorageService.getBucket(StorageService.java:729)
  at org.jets3t.service.S3Service.getBucket(S3Service.java:1909)
  ... 24 more
Was it helpful?

Solution

It looks like org.jets3t.service.utils.RestUtils$ConnManagerFactory.class is missing from your class path. Do you have the entire JetS3t library available? There are about 19 jars in the library, RestUtils$ConnManagerFactory.class is in jet3t-0.8.1a.jar in the 0.8.1a version.

OTHER TIPS

Groovy users: this exception is also thrown if you are declaring jets3t as a dependency in a groovy script with Grape.

If this is your case, you’ll need to configure Grape to use the system class loader:

@GrabConfig(systemClassLoader=true)
@Grab(group='net.java.dev.jets3t', module='jets3t', version='0.9.4')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top