I'm trying to integrate Apache jClouds into a Java project so I can access the OpenStack API. The following code fails:
neutronApi = ContextBuilder.newBuilder("openstack-neutron")
.credentials(USERNAME, API_KEY)
.endpoint(AUTH_URL)
.modules(modules)
.buildApi(NeutronApi.class);
With the following error message:
Java.util.NoSuchElementException: key [openstack-neutron] not in the list of providers or apis: {providers=[ultradns-ws], apis=[swift, swift-keystone]}
This is apparently a common problem, however the suggestions offered in jClouds troubleshooting don't resolve it. There's another StackOverflow discussion about this problem but does not have an accepted answer.
A few useful points:
- Our Java project uses Ant, whereas jClouds is based on Maven. The jClouds Installation Guide provides directions to install using Ant, but none of them work correctly. Instead, I compiled jClouds from source (https://github.com/jclouds/jclouds) and copied the .jar files into a folder on my classpath. Now I can access the jClouds objects in my code.
- The default jclouds source does not include OpenStack Neutron objects. I eventually found these in the OpenStack Labs source (https://github.com/jclouds/jclouds-labs-openstack). Compiled from source, copied the openstack-neutron-1.9.1.jar file into classpath folder, now I can access Neutron objects.
- All online sources suggest this is a classpath/dependency problem. I've verified the openstack-neutron-1.9.1.jar library is available in both my .classpath and build.xml files. No resolution.
I'd appreciate any ideas or suggestions!