Re: [Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-10 Thread Luis Gervaso
I copy this to the list because somebody can have similar issues

-

Actually I think the issue is sbt ... (It seems that is not resolving
transitive dependencies)

First:  Look and check if you added

https://maven.java.net/content/repositories/snapshots
https://raw.github.com/woorea/maven/master/snapshots
as maven repositories


A dirty way (but can help you):

dependency
groupIdorg.glassfish.jersey.core/groupId
artifactIdjersey-client/artifactId
version2.0-SNAPSHOT/version
/dependency
dependency
groupIdorg.glassfish.jersey.media/groupId
artifactIdjersey-media-json-jackson/artifactId
version2.0-SNAPSHOT/version
/dependency
dependency
groupIdorg.codehaus.jackson/groupId
artifactIdjackson-jaxrs/artifactId
version1.9.8/version
/dependency
dependency
groupIdorg.codehaus.jackson/groupId
artifactIdjackson-xc/artifactId
version1.9.8/version
/dependency





On Thu, Jan 10, 2013 at 6:55 PM, Gui Maluf guimal...@gmail.com wrote:

 I could find the pathway, but if I try

 scala var openstack = new OpenStack

 I get this

 java.lang.RuntimeException: java.lang.ClassNotFoundException:
 org.glassfish.jersey.client.JerseyClientFactory
 at org.openstack.OpenStack.initialize(OpenStack.java:96)
 at org.openstack.OpenStack.clinit(OpenStack.java:33)
 at .init(console:23)

 at .clinit(console)
 at .init(console:11)
 at .clinit(console)
 at $print(console)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at
 scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
 at
 scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:914)
 at
 scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:546)
 at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:577)
 at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543)
 at
 scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694)
 at
 scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
 at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651)
 at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542)
 at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550)
 at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
 at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:851)
 at xsbt.ConsoleInterface.run(ConsoleInterface.scala:57)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:73)
 at
 sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:64)
 at sbt.Console.console0$1(Console.scala:23)
 at
 sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
 at sbt.TrapExit$.executeMain$1(TrapExit.scala:33)
 at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)
 Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException:
 org.glassfish.jersey.client.JerseyClientFactory
 at
 javax.ws.rs.client.ClientFactory.getFactory(ClientFactory.java:92)
 at
 javax.ws.rs.client.ClientFactory.newClient(ClientFactory.java:103)
 at org.openstack.OpenStack.initialize(OpenStack.java:57)
 ... 33 more
 Caused by: java.lang.ClassNotFoundException:
 org.glassfish.jersey.client.JerseyClientFactory
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at
 javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:114)
 at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:206)
 at
 javax.ws.rs.client.ClientFactory.getFactory(ClientFactory.java:75)
 ... 35 more


 If I try
 

Re: [Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-03 Thread Gui Maluf
Luis, thanks for your quick reply! Seems I'm missing something very
important, because I can't use all this classes/types(Access, Authenticate,
Tenants, KeystoneUtils, ObjectForUpload,etc).
I've installed the os-java-sdk in this way:

$ git clone
$ mvn compile package
$ find . -name '*.jar' -exec cp {} sbt_lib_dir/. \;
$ sbt console
 import org.openstack._

What am I doing wrong? What am I missing?
Is there a proper way to install the os-java-sdk?

Thank you very much!
With lots of regards.




On Thu, Jan 3, 2013 at 4:00 AM, Luis Gervaso l...@woorea.es wrote:

 Hi Gui!

 I just upgraded the code to work properly with latest Jersey release

 Below the swift example code (just tested and working with HPCloud)

 Hope it helps you :)

 private static final File TEST_FILE = new File(pom.xml);

  private static final String KEYSTONE_AUTH_URL = 
 https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0;;

  private static final String KEYSTONE_USERNAME = ;

  private static final String KEYSTONE_PASSWORD = ;


  /**

  * @param args

  */

 public static void main(String[] args) throws Exception {

  KeystoneClient keystone = new KeystoneClient(KEYSTONE_AUTH_URL);

  //access with unscoped token

  Access access = keystone.execute(Authenticate.withPasswordCredentials(
 KEYSTONE_USERNAME, KEYSTONE_PASSWORD));

   //use the token in the following requests

  keystone.setToken(access.getToken().getId());

   Tenants tenants = keystone.execute(new ListTenants());

   //try to exchange token using the first tenant

  if(tenants.getList().size()  0) {

access =
 keystone.execute(Authenticate.withToken(access.getToken().getId()).withTenantId(tenants.getList().get(0).getId()));

SwiftClient swiftClient = 
 newSwiftClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(),
 object-store, null, public), access.getToken().getId());

//swiftClient.execute(new DeleteContainer(navidad2));

swiftClient.execute(new CreateContainer(navidad2));

System.out.println(swiftClient.execute(new ListContainers()));

ObjectForUpload upload = new ObjectForUpload();

  upload.setContainer(navidad2);

  upload.setName(example2);

  upload.setInputStream(new FileInputStream(TEST_FILE));

  swiftClient.execute(new UploadObject(upload));

System.out.println(swiftClient.execute(new ListObjects(navidad2, new 
 HashMapString,
 String() {{

   put(path, );

  }})).get(0).getContentType());

}


  }

 On Wed, Jan 2, 2013 at 8:01 PM, Gui Maluf guimal...@gmail.com wrote:

 Hey guys,
 I'm trying to extend a software 
 projecthttps://github.com/VirtualCloudDrive/CloudDriveto talk with Swift.

 This project was developed on Scala, and my issue is: how should I access
 Swift resource? Should I use 
 openstack-java-sdkhttps://github.com/woorea/openstack-java-sdk/,
 jclouds http://www.jclouds.org/documentation/quickstart/openstack/ or
 develop my own library to access the REST API?
 I've tried to use openstack-java-sdk but I wasn't able to import the
 libraries exposed at examples.

 I'm really confuse about that and I'll appreciate any help, hint, advice!

 Thanks in advance.!

 --
 *guilherme* \n
 \t *maluf*

 ___
 Mailing list: https://launchpad.net/~openstack
 Post to : openstack@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~openstack
 More help   : https://help.launchpad.net/ListHelp




 --
 ---
 Luis Alberto Gervaso Martin
 Woorea Solutions, S.L
 CEO  CTO
 mobile: (+34) 627983344
 luis@ luis.gerv...@gmail.comwoorea.es




-- 
*guilherme* \n
\t *maluf*
___
Mailing list: https://launchpad.net/~openstack
Post to : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp


Re: [Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-03 Thread Luis Gervaso
Gui,

In your own swift project you _only_ will need (take a look pom.xml in
openstack-examples project) 2 dependencies

dependency
groupIdorg.openstack/groupId
artifactIdkeystone-client/artifactId
version2.0.0-SNAPSHOT/version
/dependency
dependency
groupIdorg.openstack/groupId
artifactIdswift-client/artifactId
version2.0.0-SNAPSHOT/version
/dependency




On Thu, Jan 3, 2013 at 4:56 PM, Gui Maluf guimal...@gmail.com wrote:

 Luis, thanks for your quick reply! Seems I'm missing something very
 important, because I can't use all this classes/types(Access, Authenticate,
 Tenants, KeystoneUtils, ObjectForUpload,etc).
 I've installed the os-java-sdk in this way:

 $ git clone
 $ mvn compile package
 $ find . -name '*.jar' -exec cp {} sbt_lib_dir/. \;
 $ sbt console
  import org.openstack._

 What am I doing wrong? What am I missing?
 Is there a proper way to install the os-java-sdk?

 Thank you very much!
 With lots of regards.




 On Thu, Jan 3, 2013 at 4:00 AM, Luis Gervaso l...@woorea.es wrote:

 Hi Gui!

 I just upgraded the code to work properly with latest Jersey release

 Below the swift example code (just tested and working with HPCloud)

 Hope it helps you :)

 private static final File TEST_FILE = new File(pom.xml);

  private static final String KEYSTONE_AUTH_URL = 
 https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0;;

  private static final String KEYSTONE_USERNAME = ;

  private static final String KEYSTONE_PASSWORD = ;


  /**

  * @param args

  */

 public static void main(String[] args) throws Exception {

  KeystoneClient keystone = new KeystoneClient(KEYSTONE_AUTH_URL);

  //access with unscoped token

  Access access = keystone.execute(Authenticate.withPasswordCredentials(
 KEYSTONE_USERNAME, KEYSTONE_PASSWORD));

   //use the token in the following requests

  keystone.setToken(access.getToken().getId());

   Tenants tenants = keystone.execute(new ListTenants());

   //try to exchange token using the first tenant

  if(tenants.getList().size()  0) {

access =
 keystone.execute(Authenticate.withToken(access.getToken().getId()).withTenantId(tenants.getList().get(0).getId()));

SwiftClient swiftClient = 
 newSwiftClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(),
 object-store, null, public), access.getToken().getId());

//swiftClient.execute(new DeleteContainer(navidad2));

swiftClient.execute(new CreateContainer(navidad2));

System.out.println(swiftClient.execute(new ListContainers()));

ObjectForUpload upload = new ObjectForUpload();

  upload.setContainer(navidad2);

  upload.setName(example2);

  upload.setInputStream(new FileInputStream(TEST_FILE));

  swiftClient.execute(new UploadObject(upload));

System.out.println(swiftClient.execute(new ListObjects(navidad2, new 
 HashMapString,
 String() {{

   put(path, );

  }})).get(0).getContentType());

}


  }

 On Wed, Jan 2, 2013 at 8:01 PM, Gui Maluf guimal...@gmail.com wrote:

 Hey guys,
 I'm trying to extend a software 
 projecthttps://github.com/VirtualCloudDrive/CloudDriveto talk with Swift.

 This project was developed on Scala, and my issue is: how should I
 access Swift resource? Should I use 
 openstack-java-sdkhttps://github.com/woorea/openstack-java-sdk/,
 jclouds http://www.jclouds.org/documentation/quickstart/openstack/ or
 develop my own library to access the REST API?
 I've tried to use openstack-java-sdk but I wasn't able to import the
 libraries exposed at examples.

 I'm really confuse about that and I'll appreciate any help, hint, advice!

 Thanks in advance.!

 --
 *guilherme* \n
 \t *maluf*

 ___
 Mailing list: https://launchpad.net/~openstack
 Post to : openstack@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~openstack
 More help   : https://help.launchpad.net/ListHelp




 --
 ---
 Luis Alberto Gervaso Martin
 Woorea Solutions, S.L
 CEO  CTO
 mobile: (+34) 627983344
 luis@ luis.gerv...@gmail.comwoorea.es




 --
 *guilherme* \n
 \t *maluf*




-- 
---
Luis Alberto Gervaso Martin
Woorea Solutions, S.L
CEO  CTO
mobile: (+34) 627983344
luis@ luis.gerv...@gmail.comwoorea.es
___
Mailing list: https://launchpad.net/~openstack
Post to : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp


Re: [Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-03 Thread Everett Toews
Hi Gui,

If you're still interested in trying out jclouds, I just updated the quick 
start page over at jclouds.org

http://www.jclouds.org/documentation/quickstart/openstack/

The example there is for Nova so here's an example with Swift that creates a 
container and some objects

https://gist.github.com/4446492

Regards,
Everett

From: Gui Maluf guimal...@gmail.commailto:guimal...@gmail.com
Date: Wednesday, January 2, 2013 1:01 PM
To: openstack@lists.launchpad.netmailto:openstack@lists.launchpad.net 
openstack@lists.launchpad.netmailto:openstack@lists.launchpad.net
Subject: [Openstack] Developing with Scala/Java on OpenStack Swift

Hey guys,
I'm trying to extend a software 
projecthttps://github.com/VirtualCloudDrive/CloudDrive to talk with Swift.

This project was developed on Scala, and my issue is: how should I access Swift 
resource? Should I use 
openstack-java-sdkhttps://github.com/woorea/openstack-java-sdk/, 
jcloudshttp://www.jclouds.org/documentation/quickstart/openstack/ or develop 
my own library to access the REST API?
I've tried to use openstack-java-sdk but I wasn't able to import the libraries 
exposed at examples.

I'm really confuse about that and I'll appreciate any help, hint, advice!

Thanks in advance.!

--
guilherme \n
\t maluf
___
Mailing list: https://launchpad.net/~openstack
Post to : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp


[Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-02 Thread Gui Maluf
Hey guys,
I'm trying to extend a software
projecthttps://github.com/VirtualCloudDrive/CloudDriveto talk with
Swift.

This project was developed on Scala, and my issue is: how should I access
Swift resource? Should I use
openstack-java-sdkhttps://github.com/woorea/openstack-java-sdk/,
jclouds http://www.jclouds.org/documentation/quickstart/openstack/ or
develop my own library to access the REST API?
I've tried to use openstack-java-sdk but I wasn't able to import the
libraries exposed at examples.

I'm really confuse about that and I'll appreciate any help, hint, advice!

Thanks in advance.!

-- 
*guilherme* \n
\t *maluf*
___
Mailing list: https://launchpad.net/~openstack
Post to : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp


Re: [Openstack] Developing with Scala/Java on OpenStack Swift

2013-01-02 Thread Luis Gervaso
Hi Gui!

I just upgraded the code to work properly with latest Jersey release

Below the swift example code (just tested and working with HPCloud)

Hope it helps you :)

private static final File TEST_FILE = new File(pom.xml);

 private static final String KEYSTONE_AUTH_URL = 
https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0;;

 private static final String KEYSTONE_USERNAME = ;

 private static final String KEYSTONE_PASSWORD = ;


 /**

 * @param args

 */

public static void main(String[] args) throws Exception {

 KeystoneClient keystone = new KeystoneClient(KEYSTONE_AUTH_URL);

 //access with unscoped token

 Access access = keystone.execute(Authenticate.withPasswordCredentials(
KEYSTONE_USERNAME, KEYSTONE_PASSWORD));

  //use the token in the following requests

 keystone.setToken(access.getToken().getId());

  Tenants tenants = keystone.execute(new ListTenants());

  //try to exchange token using the first tenant

 if(tenants.getList().size()  0) {

   access =
keystone.execute(Authenticate.withToken(access.getToken().getId()).withTenantId(tenants.getList().get(0).getId()));

   SwiftClient swiftClient =
newSwiftClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(),
object-store, null, public), access.getToken().getId());

   //swiftClient.execute(new DeleteContainer(navidad2));

   swiftClient.execute(new CreateContainer(navidad2));

   System.out.println(swiftClient.execute(new ListContainers()));

   ObjectForUpload upload = new ObjectForUpload();

 upload.setContainer(navidad2);

 upload.setName(example2);

 upload.setInputStream(new FileInputStream(TEST_FILE));

 swiftClient.execute(new UploadObject(upload));

   System.out.println(swiftClient.execute(new ListObjects(navidad2,
new HashMapString,
String() {{

  put(path, );

 }})).get(0).getContentType());

   }


 }

On Wed, Jan 2, 2013 at 8:01 PM, Gui Maluf guimal...@gmail.com wrote:

 Hey guys,
 I'm trying to extend a software 
 projecthttps://github.com/VirtualCloudDrive/CloudDriveto talk with Swift.

 This project was developed on Scala, and my issue is: how should I access
 Swift resource? Should I use 
 openstack-java-sdkhttps://github.com/woorea/openstack-java-sdk/,
 jclouds http://www.jclouds.org/documentation/quickstart/openstack/ or
 develop my own library to access the REST API?
 I've tried to use openstack-java-sdk but I wasn't able to import the
 libraries exposed at examples.

 I'm really confuse about that and I'll appreciate any help, hint, advice!

 Thanks in advance.!

 --
 *guilherme* \n
 \t *maluf*

 ___
 Mailing list: https://launchpad.net/~openstack
 Post to : openstack@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~openstack
 More help   : https://help.launchpad.net/ListHelp




-- 
---
Luis Alberto Gervaso Martin
Woorea Solutions, S.L
CEO  CTO
mobile: (+34) 627983344
luis@ luis.gerv...@gmail.comwoorea.es
___
Mailing list: https://launchpad.net/~openstack
Post to : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp