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

openstack4j 2.0.0-SNAPSHOT compatible with java 1.6?? #134

Closed
vinodborole opened this Issue Nov 20, 2014 · 12 comments

Comments

Projects
None yet
3 participants
@vinodborole
Contributor

vinodborole commented Nov 20, 2014

I am using openstack4j 2.0.0-Snapshot with java 1.6 and a basic authentication code is throwing me below jersey error

Exception in thread "main" com.google.common.util.concurrent.ExecutionError: java.lang.UnsupportedClassVersionError: org/glassfish/jersey/jackson/JacksonFeature : Unsupported major.minor version 51.0
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at org.openstack4j.connectors.jersey2.ClientFactory.create(ClientFactory.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.initialize(HttpCommand.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.create(HttpCommand.java:45)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:33)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
at org.openstack4j.openstack.internal.OSAuthenticator.authenticateV2(OSAuthenticator.java:77)
at org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:41)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:84)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:65)
at com.osp4j.Osp4jApp.main(Osp4jApp.java:33)
Caused by: java.lang.UnsupportedClassVersionError: org/glassfish/jersey/jackson/JacksonFeature : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.openstack4j.connectors.jersey2.ClientFactory.buildClientFromConfig(ClientFactory.java:57)
at org.openstack4j.connectors.jersey2.ClientFactory.access$100(ClientFactory.java:31)
at org.openstack4j.connectors.jersey2.ClientFactory$1.load(ClientFactory.java:39)
at org.openstack4j.connectors.jersey2.ClientFactory$1.load(ClientFactory.java:36)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
... 14 more

Pom.xml

org.pacesys openstack4j 2.0.0-SNAPSHOT

Code:
final OSClient os = OSFactory.builder().endpoint(serverUrl).credentials(username, credential).tenantName(tenant).authenticate();

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Nov 20, 2014

Member

I just confirmed that Jersey 2 (2.7+) is no longer compiling with JDK 6 as the target and that JDK 7 is required.

Couple questions:

  1. Is it possible to use a different connector such as OkHttp, HttpClient, etc?
  2. Is it possible to use JDK 7?

If no to the above I could look into adding a connector for a pre Jersey 2.7 version for JDK6 usage.

Member

gondor commented Nov 20, 2014

I just confirmed that Jersey 2 (2.7+) is no longer compiling with JDK 6 as the target and that JDK 7 is required.

Couple questions:

  1. Is it possible to use a different connector such as OkHttp, HttpClient, etc?
  2. Is it possible to use JDK 7?

If no to the above I could look into adding a connector for a pre Jersey 2.7 version for JDK6 usage.

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Nov 21, 2014

Contributor

JDK 7 is no longer an option for us now, and we need to use Jersey and no longer a different connector. It will be helpful if you can add Jersey with JDK6 usage

I did try okHttp and it also requires JDK 7 and when i use HTTPClient connector with openstack4j-core-2.0.0-SNAPSHOT I get below exception for image upload code

    final Payload<File> payload = Payloads.create(new File(imagePath + "/" + imageName));
    final Image image = Builders.image().name(imageName).containerFormat(ContainerFormat.BARE).diskFormat(DiskFormat.RAW).build();
    os.images().create(image, payload);



     Exception in thread "main" ConnectionException{message=No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.io.FileInputStream["fd"]), status=0}
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:55)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:29)
    at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:159)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:154)
    at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:107)
    at com.osp4j.Osp4jApp.main(Osp4jApp.java:70)
    Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.io.FileInputStream["fd"])
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:505)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:639)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
    at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:800)
    at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:676)
    at org.openstack4j.connectors.httpclient.HttpCommand.execute(HttpCommand.java:122)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invokeRequest(HttpExecutorServiceImpl.java:60)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
    ... 6 more
Contributor

vinodborole commented Nov 21, 2014

JDK 7 is no longer an option for us now, and we need to use Jersey and no longer a different connector. It will be helpful if you can add Jersey with JDK6 usage

I did try okHttp and it also requires JDK 7 and when i use HTTPClient connector with openstack4j-core-2.0.0-SNAPSHOT I get below exception for image upload code

    final Payload<File> payload = Payloads.create(new File(imagePath + "/" + imageName));
    final Image image = Builders.image().name(imageName).containerFormat(ContainerFormat.BARE).diskFormat(DiskFormat.RAW).build();
    os.images().create(image, payload);



     Exception in thread "main" ConnectionException{message=No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.io.FileInputStream["fd"]), status=0}
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:55)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:29)
    at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:159)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:154)
    at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:107)
    at com.osp4j.Osp4jApp.main(Osp4jApp.java:70)
    Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.io.FileInputStream["fd"])
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:505)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:639)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
    at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:800)
    at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:676)
    at org.openstack4j.connectors.httpclient.HttpCommand.execute(HttpCommand.java:122)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invokeRequest(HttpExecutorServiceImpl.java:60)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
    ... 6 more

gondor added a commit that referenced this issue Nov 21, 2014

@gondor gondor added the enhancement label Nov 21, 2014

@gondor gondor added this to the 2.0.0 Release milestone Nov 21, 2014

@gondor gondor self-assigned this Nov 21, 2014

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Nov 21, 2014

Member

Ok I have added a JDK6 connector option which is using Jersey 2.6 (this should be 1.6 safe). You will need to modify your pom as far as openstack4j usage goes with the following:

<dependency>
  <groupId>org.pacesys</groupId>
  <artifactId>openstack4j-core</artifactId>
  <version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>org.pacesys.openstack4j.connectors</groupId>
  <artifactId>openstack4j-jersey2-jdk16</artifactId>
  <version>2.0.0-SNAPSHOT</version>
</dependency>

Let me know how this works out.

Member

gondor commented Nov 21, 2014

Ok I have added a JDK6 connector option which is using Jersey 2.6 (this should be 1.6 safe). You will need to modify your pom as far as openstack4j usage goes with the following:

<dependency>
  <groupId>org.pacesys</groupId>
  <artifactId>openstack4j-core</artifactId>
  <version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>org.pacesys.openstack4j.connectors</groupId>
  <artifactId>openstack4j-jersey2-jdk16</artifactId>
  <version>2.0.0-SNAPSHOT</version>
</dependency>

Let me know how this works out.

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Nov 24, 2014

Contributor

Thanks a lot gondor; it works!

Any idea why HttpClient did not work? Any idea of the exception in my previous reply?

Contributor

vinodborole commented Nov 24, 2014

Thanks a lot gondor; it works!

Any idea why HttpClient did not work? Any idea of the exception in my previous reply?

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Nov 24, 2014

Member

@vinodborole Thanks for the input. Actually you just found a bug with httpclient. 2.0.0-SNAPSHOT introduced options known as connectors (prior was only Jersey). The other connectors are still in beta and you just found a bug :) Thanks, I'll debug further and fix it. Regardless Jersey 2 is the most stable since it's been the default since I first started OpenStack4j and I had no issues adding a backwards compat JDK6 option for you. I'll fix the httpclient bug this evening.

Member

gondor commented Nov 24, 2014

@vinodborole Thanks for the input. Actually you just found a bug with httpclient. 2.0.0-SNAPSHOT introduced options known as connectors (prior was only Jersey). The other connectors are still in beta and you just found a bug :) Thanks, I'll debug further and fix it. Regardless Jersey 2 is the most stable since it's been the default since I first started OpenStack4j and I had no issues adding a backwards compat JDK6 option for you. I'll fix the httpclient bug this evening.

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Nov 24, 2014

Contributor

ok thanks

Contributor

vinodborole commented Nov 24, 2014

ok thanks

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Nov 27, 2014

Contributor

@gondor

The HttpClient connector issue is fixed? If yes, how should i pull the latest connector jar, can you help?

Contributor

vinodborole commented Nov 27, 2014

@gondor

The HttpClient connector issue is fixed? If yes, how should i pull the latest connector jar, can you help?

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Nov 28, 2014

Member

If your using maven to run your project you can do a mvn -U compile via command line. If your in Eclipse use Maven -> Update Project (from there make sure Force Dependencies is checked)

Member

gondor commented Nov 28, 2014

If your using maven to run your project you can do a mvn -U compile via command line. If your in Eclipse use Maven -> Update Project (from there make sure Force Dependencies is checked)

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Nov 28, 2014

Contributor

@gondor
with httpclient connector, well now it gets a OutOfMemory Exception even with -Xms2048m -Xmx4096m value

   Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2786)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
    at com.google.common.io.ByteStreams.copy(ByteStreams.java:179)
    at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:220)
    at org.openstack4j.connectors.httpclient.HttpCommand.execute(HttpCommand.java:131)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invokeRequest(HttpExecutorServiceImpl.java:60)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:29)
    at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:159)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:154)
    at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:107)
    at com.openstack4j.app.Osp4jApp.main(Osp4jApp.java:70)
Contributor

vinodborole commented Nov 28, 2014

@gondor
with httpclient connector, well now it gets a OutOfMemory Exception even with -Xms2048m -Xmx4096m value

   Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2786)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
    at com.google.common.io.ByteStreams.copy(ByteStreams.java:179)
    at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:220)
    at org.openstack4j.connectors.httpclient.HttpCommand.execute(HttpCommand.java:131)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invokeRequest(HttpExecutorServiceImpl.java:60)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
    at org.openstack4j.connectors.httpclient.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:29)
    at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:159)
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:154)
    at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:107)
    at com.openstack4j.app.Osp4jApp.main(Osp4jApp.java:70)

gondor added a commit that referenced this issue Nov 28, 2014

Issue #134 - fixed OOM by letting HttpClient handle the streams. Test…
…ed using only 64mb memory in the JDK and a 400mb image upload
@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Nov 28, 2014

Member

Ok, this is now fixed. Tested by configuring my JDK to 64mb memory and uploading a 400mb image. (previous tests failed, now passed). You'll need to update your dependency in Maven or sync the new code

Member

gondor commented Nov 28, 2014

Ok, this is now fixed. Tested by configuring my JDK to 64mb memory and uploading a 400mb image. (previous tests failed, now passed). You'll need to update your dependency in Maven or sync the new code

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Dec 1, 2014

Contributor

It works thanks a lot

Contributor

vinodborole commented Dec 1, 2014

It works thanks a lot

@mnkanojia

This comment has been minimized.

Show comment
Hide comment
@mnkanojia

mnkanojia May 5, 2015

I recently started working on writing a Openstack client and getting the same error that vinodborole mentioned above.
Our application is on JDK1.6 and Jersey 2.0. I am using openstack4j 2.0.1 and as mentioned by gondor, I have openstack4j-jersey2-jdk16-2.0.1 in the classpath as well.

Can someone please tell me how to get rid of this exception:

Exception in thread "main" com.google.common.util.concurrent.ExecutionError: java.lang.UnsupportedClassVersionError: org/glassfish/jersey/jackson/JacksonFeature : Unsupported major.minor version 51.0
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2261)
at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4004)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
at org.openstack4j.connectors.jersey2.ClientFactory.create(ClientFactory.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.initialize(HttpCommand.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.create(HttpCommand.java:45)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:33)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
at org.openstack4j.openstack.internal.OSAuthenticator.authenticateV2(OSAuthenticator.java:77)
at org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:41)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:84)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:65)
at com.gmrt.sunrise.genesis.data.utils.OpenStackClient.auth(OpenStackClient.java:91)

mnkanojia commented May 5, 2015

I recently started working on writing a Openstack client and getting the same error that vinodborole mentioned above.
Our application is on JDK1.6 and Jersey 2.0. I am using openstack4j 2.0.1 and as mentioned by gondor, I have openstack4j-jersey2-jdk16-2.0.1 in the classpath as well.

Can someone please tell me how to get rid of this exception:

Exception in thread "main" com.google.common.util.concurrent.ExecutionError: java.lang.UnsupportedClassVersionError: org/glassfish/jersey/jackson/JacksonFeature : Unsupported major.minor version 51.0
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2261)
at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4004)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
at org.openstack4j.connectors.jersey2.ClientFactory.create(ClientFactory.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.initialize(HttpCommand.java:50)
at org.openstack4j.connectors.jersey2.HttpCommand.create(HttpCommand.java:45)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53)
at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:33)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)
at org.openstack4j.openstack.internal.OSAuthenticator.authenticateV2(OSAuthenticator.java:77)
at org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:41)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:84)
at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:65)
at com.gmrt.sunrise.genesis.data.utils.OpenStackClient.auth(OpenStackClient.java:91)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment