Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Tomás Augusto Müller 6:16 pm on April 28, 2013 Permalink | Reply
    Tags: , playframework, scala, ,   

    PlayFramework with Spring Data Neo4j 

    Hello!

    Check my sample application using PlayFramework and Spring Data Neo4j.

    This is just a skeleton app, that also features:

    • Neo4j Graph Database
    • Scala and Java integration
    • CDI (javax.inject)
    • Spring
    • Spring Data
    • Spring Data Neo4j

    Sources: https://github.com/tomasmuller/playframework-neo4j-template

    See it live here: http://playframework-neo4j.herokuapp.com/

     
    • Rosalía 6:39 pm on May 16, 2013 Permalink

      hello! I have used your template Play+Spring Data Neo and it woks fine first time you start your server, problems come when you simple change the message in index.scala.html and try to reload to see your new message… it comes and error like this:

      Caused by: java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component ‘org.neo4j.kernel.StoreLockerLifecycleAdapter@51f2c9bf’ was successfully initialized, but failed to start. Please see attached cause exception.
      at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:282) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:90) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:75) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:60) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_45]
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_45]
      Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component ‘org.neo4j.kernel.StoreLockerLifecycleAdapter@51f2c9bf’ was successfully initialized, but failed to start. Please see attached cause exception.
      at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:260) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:90) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:75) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:60) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: target/neo4j-db/store_lock
      at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:90) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:260) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:90) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      Caused by: java.nio.channels.OverlappingFileLockException: null
      at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166) ~[na:1.6.0_45]
      at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068) ~[na:1.6.0_45]
      at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:868) ~[na:1.6.0_45]
      at java.nio.channels.FileChannel.tryLock(FileChannel.java:962) ~[na:1.6.0_45]
      at org.neo4j.kernel.impl.nioneo.store.FileLock.getOsSpecificFileLock(FileLock.java:83) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]
      at org.neo4j.kernel.DefaultFileSystemAbstraction.tryLock(DefaultFileSystemAbstraction.java:83) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1]

      Any kind of suggestion about how to fix this? I’m having a bad feeling about this, should I really bet on this combination?

      Many Thxs Thomás.

    • Tomás Augusto Müller 8:20 pm on May 16, 2013 Permalink

  • Tomás Augusto Müller 9:24 pm on November 5, 2012 Permalink | Reply
    Tags: , TDD   

    Do you really get TDD? 

    “Turns out, sometimes, you need to be of age and experience, to truly understand the things you learn.

    Even the best of tools, when used poorly, can turn against you. And the easier the tool, the easier it seems to use it, the easier it is to fall into the trap of I-know-how-it-works thinking.”

    Just to recap some important points:

    • Test Driven Development and tests, are two completely different things. Tests are only a byproduct of TDD, nothing more.
    • What is the point of TDD? What does TDD brings? Why do we do TDD?
      1. To find the best design, by putting ourselves into the user’s shoes.
      2. To manage our fear.
      3. To have fast feedback.
    • How to write great tests?
      1. Verify the right thing.
      2. Verify *only* the right thing.
      3. Provide safety and good design, or be gone.

    The first criterion for your tests is confidence. Never delete a test if it reduces your confidence in the behavior of the system.

    The second criterion is communication. If you have two tests that exercise the same path through the code, but they speak to different scenarios for a readers, leave them alone.

    [Kent Beck, Test Driven Development: by Example]

     

    Read on:

    http://www.javacodegeeks.com/2012/09/test-driven-traps-part-1.html
    http://www.javacodegeeks.com/2012/09/test-driven-traps-part-2.html

     

     
  • Tomás Augusto Müller 5:21 pm on June 22, 2012 Permalink | Reply
    Tags: , ,   

    Git How to’s 

    git checkout -b refactor

    Courtesy of git animals

    This post intends to be a collection of useful commands and explanations of common tasks involving this awesome tool, and how to contribute to Open-source software using it. Perhaps it comes in handy to someone else too.

    Find forgotten TODOs and FIXMEs

    grep -RIn TODO target_directory/*

    Forking and contributing with Github

    Go to project repository page and click on ‘Fork’ button. After that, clone it to your local machine:

    git clone **your ssh/git url**

    Add a upstream branch (helps to get the updates from the original project repository):

    git remote add --track master upstream git://github.com/upstreamname/projectname.git

    Create a new branch to accommodate your work (help the pull request workflow):

    git checkout -b name-of-your-branch

    Get updates from the original repository:

    git fetch upstream
    git merge upstream/master

    Submitting a Pull Request:

    git push origin name-of-your-branch

    Go to your forked repository page on Github, and change the branch to the one recently pushed.

    Next, click on the button that says ‘Pull Request’. Describe it the best as you can, then submit.

    Whenever you commit and push more things to that branch of your code, they will be included in that pull request until it is closed.

    Github <3 Git

    For those who doesn’t have a Github account yet, follow this link to create one.setuptocat - github and git

    And, here’s how to setup Git under Ubuntu:

      sudo apt-get update && sudo apt-get upgrade
      sudo apt-get install git-core git-doc

    Next, configure Github:

      git config --global user.name <git-username>
      git config --global user.email <git-email-address>
      ssh-keygen -t rsa -C <git-email-address>

    The key that you just generated must be added to your Github account. If you don’t know how to do this, click here.

    References

    http://ivanzuzak.info/2012/03/03/todos-ideas-for-contributing-to-open-source-projects.html

    http://robots.thoughtbot.com/post/5133345960/keeping-a-git-fork-updated

    http://gun.io/blog/how-to-github-fork-branch-and-pull-request/

    https://help.github.com/articles/fork-a-repo

    http://anders.janmyr.com/2012/01/finding-with-git.html

    http://eagain.net/articles/git-for-computer-scientists/

     
  • Tomás Augusto Müller 2:42 pm on April 26, 2012 Permalink | Reply
    Tags: , , short,   

    [short-tip] Extract range of pages from a PDF file 

    Let’s assume you downloaded a PDF file with 700 pages. But you want to send by email only pages 7 to 27.

    Ghostscript to the rescue! Available in every UNIX/Linux distribution, you can leverage the gs command to do this.

    gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER /
       -dFirstPage=7 -dLastPage=27 /
       -sOutputFile=name_of_outfile.pdf name_of_inputfile.pdf
     
  • Tomás Augusto Müller 9:49 pm on March 29, 2012 Permalink | Reply
    Tags: , , openshift, ,   

    10 Steps to run Spring Data Neo4j at OpenShift 

    It’s very easy to get Neo4j running on RedHat’s OpenShift Cloud Platform. Note that at the time of writing this, there is no Neo4j cartridge available at OpenShift.

    If you are familiar with Heroku, think that a cartridge is like a Heroku Add-on. It plugs functionality into the PaaS environment.

    So, how we can use Neo4j at OpenShift? First, remember to always read a README file, if there’s one.

    When you create a project at OpenShift, a README file can be located at the root directory of your app. Among other things, we have this line:

    ../data – For persistent data (also in env var OPENSHIFT_DATA_DIR)

    Hmmm that’s interesting! Heroku doesn’t have a place for persistent data across Heroku’s dynos. They are ephemeral, as said by James Ward, here.

    From now on, you can guess what to do, right?

    The answer is inside of Spring applicationContext.xml file:

    <neo4j:config storeDirectory="${OPENSHIFT_DATA_DIR}/graph.db"/> 

    To let things more easy, I built a OpenShift skeleton app so I don’t have to do it again and again..

    You can view and fork it here: https://github.com/tomasmuller/openshift-neo4jtemplate

    Oh! Almost forgot! You can read all the 10 steps of this post title, in the project README.md file!

    ;-)

     
    • Steven Citron-Pousty 4:04 pm on March 30, 2012 Permalink

      Nicely done on your post. When I try to get neo4j spatial running I will reference you guys for the getting started.

    • Tomás Augusto Müller 10:15 pm on March 30, 2012 Permalink

      Thank you Steven!

    • Hata 12:27 am on April 10, 2012 Permalink

      When I deploy my project (CDI, JSF, Spring, Neo4j) to openshift, the server alway throw th waning log as:

      WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.neo4j.kernel.impl.osgi.OSGiActivator in Module “deployment.ROOT.war:main” from Service Module Loader: java.lang.LinkageError: Failed to link org/neo4j/kernel/impl/osgi/OSGiActivator (Module “deployment.ROOT.war:main” from Service Module Loader)
      … …
      Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
      at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_22]

      Please give me any suggestion in this situation
      Thanks Steven.

  • Tomás Augusto Müller 2:09 pm on February 28, 2012 Permalink | Reply
    Tags: benchmark, , , , JIT, , ,   

    Benchmarking NeoQuotes (Jetty + JRubyRack) 

    To perform basic HTTP benchmarks against a web application, you can start with ab – Apache HTTP server benchmarking tool. speed

    If you use Ubuntu, the installation is very simple:

    sudo apt-get install apache2-utils

    I used this tool to benchmark NeoQuotes application, testing how Jetty with JRuby-Rack are performing against multiple concurrent requests.

    First, start up Jetty with mvn jetty:run or with the command defined in project Procfile (sh target/bin/jruby -S config/jetty.rb for NeoQuotes).

    Next, execute multiple times the following command:

    ab -n 10000 -c 25 http://localhost:8080/

    where n = number of requests and c = concurrency level.

    Is worth to look to the number of requests per second, that are increasing every time the benchmark is executed. This happens thanks to JIT!

    Below some results after running ab -n 10000 -c 25 http://localhost:55012/ three times in a commodity hardware (all tests were performed on the application homepage where there is no interaction with Neo4j and no cache mechanism is configured):

    First execution:

    Time taken for tests:   73.162 seconds
    Requests per second:    136.68 [#/sec] (mean)

    Second execution:

    Time taken for tests:   67.006 seconds
    Requests per second:    149.24 [#/sec] (mean)

    Third execution:

    Time taken for tests:   65.725 seconds
    Requests per second:    152.15 [#/sec] (mean)

    Also, take a look at Min and Max threads of Jetty QueuedThreadPool, at config/jetty.rb configuration.

    Depending of your hardware and your VM configuration,the more threads you configure into min and max, the worse your throughput gets when your VM starts to reach its resource limits.

     
  • Tomás Augusto Müller 9:41 pm on February 13, 2012 Permalink | Reply
    Tags: , heroku, , , , , , , voice interfaces   

    Talking with Neo4j Graphs 

    Hello!

    In this post I will be covering all main details regarding the development of my entry for the Neo4j Challenge.

    The main objective of this challenge is to create a Heroku-ready template or demo application using Neo4j. So, I neo4j challenge websitethought to myself: – what kind of application would be nice to show up in this contest?

    After many ideas, here it is!  neoquotes logo

    In short, the application is a Stock Exchange symbol lookup using Neo4j and your voice.

    Ok! Let me explain what I did.

    My mainly objective was try to combine all the joy of Ruby programming, with the power and ease of use provided by the awesome Spring Data Neo4j, Spring Framework and JVM, to this amazing piece of software called Neo4j which let me curious since 2011 in the Jim Webber talk at QCONSP conference of that year.qconsp 2011

    So, to start things up, JRuby comes in as a perfect fit. It also allowed me to use Sinatra to easily develop the user interface (both, voice interface and GUI). I choose Sinatra in this case because of it’s simplicity and as long the application stay small, it beat Rails (as said by @DHH).

    Jetty is another very nice (and old) project, which provides a Web server and javax.servlet container, plus support for Web Sockets, OSGi, JMX, JNDI, JASPI, AJP and many other integrations, and can be used to develop self contained applications. In this article from Heroku blog we have a nice introduction to create a Java Web Application using Jetty. Its integration with Maven was also another motivation point.

    Talking about Maven, possibly in POM.xml resides one of the trickiest parts of the application.

    After configuring all the dependencies, aspectj-maven-plugin, jetty-maven-plugin, let’s look to configuration of appassembler-maven-plugin and jruby-rake-plugin:

    jruby-rake-plugin:

    <executions>
        <execution>
            <id>install-bundler</id>
            <phase>process-resources</phase>
            <goals>
                <goal>jruby</goal>
            </goals>
            <configuration>
                <args>-S gem install bundler --no-ri --no-rdoc --install-dir vendor/bundle</args>
            </configuration>
        </execution>
        <execution>
            <id>bundle-install</id>
            <phase>process-resources</phase>
            <goals>
                <goal>jruby</goal>
            </goals>
            <configuration>
                <args>script/bundle install --without development:test</args>
            </configuration>
        </execution>
    </executions>

    As we can see, the plugin execution is responsible for download and install Bundler, then next execute the specified script witch lives in application script folder. This script basically starts Bundler client (pre-configuring ENV['GEM_HOME'], ENV['GEM_PATH'] and ENV['BUNDLE_GEMFILE']), and following the parameters, all gems except the ones for development and test, are installed.

    Last, but not least, the appassembler-maven-plugin:

    <configuration>
        <assembleDirectory>target</assembleDirectory>
        <extraJvmArguments>-Djruby.native.enabled=false -Djruby.cext.enabled=false -Djruby.compat.version=1.9 -Xmx256m -Xss2048k</extraJvmArguments>
        <programs>
            <program>
                <mainClass>org.jruby.Main</mainClass>
                <name>jruby</name>
            </program>
        </programs>
    </configuration>

    Above we have the configuration for the assemble goal execution. The trick here is to generate the executable with JRuby (org.jruby.Main) as main class. And you can also set extra JVM arguments, like the version of Ruby language to use.

    After this brief look into POM.xml, let’s see how Heroku starts Jetty. This is defined in the Procfile:

    web: sh target/bin/jruby -S config/jetty.rb

    So, that’s it! Now our app is running on Heroku Cloud! For more details take a look into /config/jetty.rb to see how Jetty is being started up and /src/main/webapp/WEB-INF/web.xml to see the JRuby-Rack configuration. Other technical details you can find at application readme file.

    Now, let’s talk about Neo4j.

    Your life is a huge graph.

    (…) and I think it can be handled by Neo4j. Back to 2011, Jim Webber let me very

    Ok... not quite a graph. But you get the idea!

    Ok... not quite a graph. But you get the idea!

    interested in Neo4j with his talk at QCONSP 2011. Maybe because in that year I was working on my final graduation project – a recommender system to support fundamental analysis of the Stock Market using natural language processing, and I never forgot of one thing that he said. More or less like this: “MapReduce processing between http requests can be very expensive! Some problems cannot be resolved with this approach.”. Well, I did this. And I must confess: a graph database would have changed a lot my project.

    So, when I discovered this challenge, I decided “- ok, now is the time to take a closer look on Neo4j.”

    First thing I did: accessed Neo4j download page and downloaded the 1.6 Community version.

    After that, the server installation. It is super easy. Just follow this instructions.

    So, what’s next step? Learn, learn and learn!

    I was able to make some initial experiments very fast after a dynamic reading of this *superb* online resource: Good Relationships: The Spring Data Neo4j Guide Book. Thank’s to Michael Hunger, David Montag, Andreas Kollegger by this material.

    Also, I learned a lot from the following links:

    And that’s it. This is the magic of open-source software. Have a doubt of how one given thing work? Go to source code and read it! All you need to get started with Neo4j is this. Trust me ; )

    Giving voice to a graph

    I used Arbor.js library to display the Neo4j data to the user. But how differently the information can be visualized? Through voice interfaces of course!

    As I already worked with Voice Interfaces some years ago (in 2008 actually, when I won the Sun Students Contest. More info here and here), this was not a mystery. Again I used VoiceXML markup language, and the free service provided by Voxeo. Refer to the links above for more information about VoiceXML.

    Who is talking with who? (a high level view of NeoQuotes architecture)

    Who is talking with who? (a high level view of NeoQuotes architecture)

    Sinatra eased this part even more, through it’s easiness of building API’s like applications. All vxml interfaces and grammars are bellow /app/views/voice folder, and there are only two voice routes in application.rb.

    To use the Voxeo service, is simple. You only need to create an account, and after that, set up a new application through Voxeo Application Manager, informing the voice entry point of your application (the full URL to your route. In my case to the get ‘/voice/index.vxml’ route).

    Note that your application need to be accessible by Voxeo server. So don’t forget to git push heroku master, before setting up your app on Voxeo.

    Finishing, you’ll get the numbers to your application. I always tested with Skype VoIP number. Works very well here in Brazil and is totally free.

    You can try calling to NeoQuotes! This is the Skype VoIP number: +990009369996189207 (to see all available numbers for NeoQuotes access the application and click on the respective top nav bar link).

    Important: When you spell the stock symbol, say one letter, and wait the voice repeat what you just said. And go on. When you finish, you can say “Okay!”, “Go!” or “Search!” for example. If your desired symbol have an ‘.‘ you have to say “dot”. The voice will not repeat this (will stay in silence). Just continue with the letters or numbers.

    Summing up

    This demo application contains an interesting stack of technologies, providing an environment to develop robust and testable Neo4j applications, with a lot of fun. Certainly much more can be done and improved. And you can help filling issues and submitting pull requests!

    Please, help voting in this application at Gensen repository or help with a Tweet!

    Thank you Neo4j for running this challenge! It was very fun to participate.

     
    • Jean 4:38 am on November 24, 2012 Permalink

      Thanks for sharing your demo, it is pretty exciting stuff.

  • Tomás Augusto Müller 4:35 pm on January 20, 2012 Permalink | Reply
    Tags:   

    Right Investment 

    The one absolutely solid place to store your capital today — if you know how to do it –  is in software developers’ wallets.

    Source: http://www.forbes.com/sites/venkateshrao/2011/12/05/the-rise-of-developeronomics/
    and you might also read: http://blog.8thlight.com/angelique-martin/2012/01/19/8-thing-you-ought-to-know.html

     
  • Tomás Augusto Müller 10:34 pm on January 15, 2012 Permalink | Reply
    Tags:   

    [tip] Remote git branch – How to delete? 

    Ok, you probably delete your local branch with this command:

    $ git branch -D branchname

    But how to delete this branch in your remotes?

    From Pro Git by Scott Chacon, we have:

    Deleting Remote Branches

    Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax git push [remotename] :. If you want to delete your serverfix branch from the server, you run the following:

    $ git push origin :serverfix
    To git@github.com:schacon/simplegit.git
     - [deleted]         serverfix

    Boom. No more branch on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax that we went over a bit earlier. If you leave off the [localbranch] portion, then you’re basically saying, “Take nothing on my side and make it be [remotebranch].”

    That’s it!

    Source: http://progit.org/book/ch3-5.html

     
  • Tomás Augusto Müller 12:31 pm on January 12, 2012 Permalink | Reply
    Tags: entrepreneurship, startups   

    To remember when things get complicated 

    Escape Your Own Intelligence (Startup Daily #269)

    At times we are too smart for our own good. We attempt add value to situations by adding unnecessary complexity. This can be a great way to demonstrate our intelligence, but it’s rarely the best solution to the problem.

    Complicating a Situation Doesn’t Usually Make it Better

    When things seem to be getting too complicated, cut through the fog by bringing things back to the most basic functionality and obvious facts.

    ~ and this: ~

    Today’s Solution vs. the Best Solution (Startup Daily #270)

    When solving problems or making changes, people often attempt to create the most sustainable solution possible. But nothing is permanent. Finding and implementing a permanent solution is not always a good use of resources.

    Don’t Be Afraid to Use Quick, Temporary Solutions

    Both the problem and the solution are likely to evolve over time. Solving the problem quickly is often more important than creating a sustainable solution.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: