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

Need help for initial compile with Maven #101

Closed
lexar opened this issue Apr 29, 2013 · 9 comments
Closed

Need help for initial compile with Maven #101

lexar opened this issue Apr 29, 2013 · 9 comments

Comments

@lexar
Copy link

lexar commented Apr 29, 2013

Hello,

my Java knowledge is a bit rusty and I am trying to catchup with this maven thing.

First I tried to run the TickerDemo from the release jars and then snapshot jars. Those failed with the same problem as in
#75

I tried to get the missing lib with
org.slf4j:slf4j-api:jar:1.7.2:compile

but that couldn't find the library apparently.

So I followed the advice in #75 and went with maven.
I cloned the latest git repo and installed maven 3.0.3.
Then I edited the pom.xml by adding the and elements.
I tried to add under the root element, but that failed. Then I tried to add that element to because there is another repository there, that failed too.
So I created a new element , as it is mentioned in the pom-Documentation:


sonatype-oss-snapshot

https://oss.sonatype.org/content/repositories/snapshots

I then did
mvn clean install
which fails with this output:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] XChange Parent .................................... SUCCESS [2.273s]
[INFO] XChange Core ...................................... SUCCESS [7.929s]
[INFO] MtGox Exchange .................................... SUCCESS [7.764s]
[INFO] VirtEx Exchange ................................... SUCCESS [3.824s]
[INFO] Open Exchange Rates ............................... SUCCESS [3.738s]
[INFO] BTCE Exchange ..................................... FAILURE [1.675s]
[INFO] Bitstamp Exchange ................................. SKIPPED
[INFO] Campbx Exchange ................................... SKIPPED
[INFO] Bitcoin Charts Data Provider ...................... SKIPPED
[INFO] XChange Examples .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.492s
[INFO] Finished at: Mon Apr 29 12:14:25 CEST 2013
[INFO] Final Memory: 15M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.13:test (default-test) on project xchange-btce: There are test failures.

Now I am unsure how to proceed. Could anyone give me a hint what to try next?

@gary-rowe
Copy link
Collaborator

At present there is an issue with the release process between the develop and master branches that results in a snapshot being present on the master branch.

To build the 1.6.0 release you need to rewind your git checkout to hash: d18eec6. On the command line you issue the command:

git reset --hard d18eec6

This will have the effect of creating a detached HEAD which is fine for you when building, but not so fine when committing. Alternatively, you can just include the 1.6.0 version in your own project as a Maven dependency:

<dependency>
  <groupId>com.xeiam.xchange</groupId>
  <artifactId>xchange-core</artifactId>
  <version>1.6.0</version>
<dependency>

@timmolter
Copy link
Member

You have two options:

  1. non-maven - make sure you manually download from wherever you can find the jar this listed as dependencies in the README file, and add them to your classpath.

  2. Maven - do as Gary said to use the 1.6.0 release on Master, or just use the current code on the develop branch. You do not need to edit any pom files. If Maven is set up correctly, XChange will work out of the box automatically. Maven will download all the dependencies needed. There is a steep learning curve to Maven, so don't get discouraged if it doesn't work right away for you or you don't understand it.

@lexar
Copy link
Author

lexar commented Apr 29, 2013

Dear Gary and Tim, thank you very much for your help. I cloned the development branch again, did a
git reset --hard d18eec6
then
mvn clean install
and the compile went through! Great!

Now I am trying to start the TickerDemo...it has been a long time ago with java, but I do remeber the classpath pain...

cd xchange-examples/target
'java -cp xchange-examples-1.6.0.jar com.xeiam.xchange.examples.mtgox.v1.service.marketdata.polling.TickerDemo'

Exception in thread "main" java.lang.NoClassDefFoundError: com/xeiam/xchange/ExchangeFactory
at com.xeiam.xchange.examples.mtgox.v1.service.marketdata.polling.TickerDemo.main(TickerDemo.java:39)
Caused by: java.lang.ClassNotFoundException: com.xeiam.xchange.ExchangeFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
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)
... 1 more

I guess I have to include more jars in the classpath, but they are all in different directories? Should I collect all the jars in one folder? Or is there a completely new and different way how to run classes?

@gary-rowe
Copy link
Collaborator

You really are doing this the hard way if you're not using an IDE for this. You can get Intellij for free and it will take all this pain away. You'd just right click on the TickerDemo.main() method and select Run As... | Application. Maven takes away all the classpath pain of Java.

The problem you have is that you're missing the module(s) for the exchange(s) that you want to connect to. In your project you'd add

<dependency>
  <groupId>com.xeiam.xchange</groupId>
  <artifactId>xchange-mtgox</artifactId>
  <version>1.6.0</version>
<dependency>

to get the MtGox exchange API added. You can add more as you want.

To run this up from the command line you'll need to add the JARs to your classpath. There are so many that I honestly wouldn't recommend this approach.

@lexar
Copy link
Author

lexar commented Apr 29, 2013

Ok, I installed IntelliJ and now I am able to run the demos. Thank you very much!

My plan with XChange is to ultimately run it as a "demon" on a server for polling market data. It seemed that I could get around learning Tomcat and just have a cronjob starting a java file which writes to a database. Is that a bad idea? Or better, is there a recommendation how to run XChange on a server?

@timmolter
Copy link
Member

What are your plans with the server? Just to sink marketdata in a DB for another application to access? Or are you planning on making the data available via a REST API or something similar over HTTP?

@lexar
Copy link
Author

lexar commented Apr 29, 2013

For now, sinking data into a DB for another application. But I might be interested into streaming/ sockets in the future...a REST API is not planned, unless there would be a good reason for it.

@timmolter
Copy link
Member

For just sinking data into a DB you definitely don't need Tomcat and all that complication. Your idea of CRON running a script to start a Java "job" is good and simple. I do it similarly, but I use Sundial instead, which let's you basically run jobs in a Java App using cron expressions defined in a jobs.xml file. It's all more encapsulated that way. Sundial is just a simplified fork of the Quartz job scheduler for Java. You could use Quartz though if you wanted with the same result. It'd be a steeper learning curve, that's all.

@lexar
Copy link
Author

lexar commented Apr 29, 2013

Gary and Tim, that has been a tremendous help to get me started!
I am closing this issue now. Have a nice day!

@lexar lexar closed this as completed Apr 29, 2013
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

3 participants