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
Open

OpenStack throws NullPointerException when connecting #165

sinharnab opened this issue Sep 21, 2014 · 5 comments

Comments

@sinharnab
Copy link

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
Copy link
Contributor

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 [email protected] 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
Copy link

Yes, it works. Thanks!

@sinharnab
Copy link
Author

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

@meirlaker
Copy link
Contributor

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
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants