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

OpenStack throws NullPointerException when connecting #165

Open
sinharnab opened this issue Sep 21, 2014 · 5 comments

Comments

@sinharnab
Copy link

@sinharnab sinharnab commented Sep 21, 2014

I'm trying to connect OpenStack for access before creating tenant. It gives a NullPointerException from OpenStackClient.request() in the "openstack-client-3.2.1.jar".

The code and the beginning of stack trace are as below:

Keystone keystone = new Keystone("http://192.168.122.15:35357/v2.0");
//access with unscoped token
Access access = keystone.tokens().authenticate(
 new UsernamePassword("admin", "ADMIN_PASS"))
.withTenantName("admin")
.execute();`

The stacktrace is:

[java] java.lang.NullPointerException [java] at com.woorea.openstack.base.client.OpenStackClient.request(OpenStackClient.java:51) [java] at com.woorea.openstack.base.client.OpenStackClient.execute(OpenStackClient.java:66) [java] at com.woorea.openstack.base.client.OpenStackRequest.execute(OpenStackRequest.java:98) [java] at vep.openstack.OpenStackConnector.addUser(OpenStackConnector.java:624)

I looked at the source files of the package and tracing from the stack, the exception occurs while executing the line 51 in com.woorea.openstack.base.client.OpenStackClient: return connector.request(request); The variable 'connector' of type 'OpenStackClientConnector connector' doesn't get initialized (remains null). Is there anything I might need to do to initialize it?

Any help would be highly appreciated. Thank you.

@meirlaker

This comment has been minimized.

Copy link
Contributor

@meirlaker meirlaker commented Sep 21, 2014

Make sure your maven dependencies include one of the 3 Connector projects
listed under the openstack-client-connectors. For example,
resteasy-connector can be added to along with keystone client using:

com.woorea resteasy-connector 3.2.2-SNAPSHOT com.woorea keystone-client 3.2.2-SNAPSHOT

Note: I am currently using the resteasy connector, but have not seen any
arguments for / against any specific connector or which use case my prefer
one over the other.

Also, port 35357 is the default admin port for Keystone. I believe it is
better practice to initially connect and authenticate to the public
Keystone port (default is 5000) and then use the retrieved list of
endpoints to dynamically choose the admin IP address for subsequent
requests (and, by default, that will probably end up being the same address
for Keystone with the 35357 port).

On Sun, Sep 21, 2014 at 1:34 PM, sinharnab notifications@github.com wrote:

I'm trying to connect OpenStack for access before creating tenant. It
gives a NullPointerException from OpenStackClient.request() in the
"openstack-client-3.2.1.jar".

The code and the beginning of stack trace are as below:

Keystone keystone = new Keystone("http://192.168.122.15:35357/v2.0");
//access with unscoped token
Access access = keystone.tokens().authenticate(
new UsernamePassword("admin", "ADMIN_PASS"))
.withTenantName("admin")
.execute();`

The stacktrace is:

[java] java.lang.NullPointerException
[java] at
com.woorea.openstack.base.client.OpenStackClient.request(OpenStackClient.java:51)
[java] at
com.woorea.openstack.base.client.OpenStackClient.execute(OpenStackClient.java:66)
[java] at
com.woorea.openstack.base.client.OpenStackRequest.execute(OpenStackRequest.java:98)
[java] at
vep.openstack.OpenStackConnector.addUser(OpenStackConnector.java:624)

I looked at the source files of the package and tracing from the stack,
the exception occurs while executing the line 51 in
com.woorea.openstack.base.client.OpenStackClient: return
connector.request(request); Probably the variable 'connector' of type
'OpenStackClientConnector connector' doesn't get initialized before which I
might need to do probably.

Any help would be highly appreciated. Thank you.


Reply to this email directly or view it on GitHub
#165.

@winneryong

This comment has been minimized.

Copy link

@winneryong winneryong commented Sep 29, 2014

Yes, it works. Thanks!

@sinharnab

This comment has been minimized.

Copy link
Author

@sinharnab sinharnab commented Sep 29, 2014

Yes, I added the first library out of the three listed below and it worked. Thank alot.
jersey-connector
jersey2-connector
resteasy-connector

@meirlaker

This comment has been minimized.

Copy link
Contributor

@meirlaker meirlaker commented Sep 30, 2014

I'm glad it worked. As I wrote, I happen to use resteasy, but only because I tried it first (I liked the name!) and it worked.

Can anyone explain why there are multiple implementations? Are there specific environments or scenarios where one is preferred?

@woorea

This comment has been minimized.

Copy link
Owner

@woorea woorea commented Sep 30, 2014

Actually OpenStack Java SDK is generic library so you can choose the JAX-RS client provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.