Archive

Archive for the ‘sap’ Category

Jruby on Rails on SAP NetWeaver Studio

August 31st, 2009 admin No comments

Many of you have already heard about JRuby and its Rails implementation called JRuby on Rails, for those who do not I would recommend to read the following articles:

  • JRuby: The power of Java and Ruby
  • This article which clearly explain the basics is about JRuby.
  • This article from Java World gives an overview JRuby on Rails. 
  • Additionally, there is another article from Developer.com which runs over the first steps on creating and deploying a JRuby on Rails application.

Ok, once we are all on the same page, I am going to make a more detailed overview, on how to develop a JRuby on Rails project using SAP NetWeaver Studio. Just to mention that I am currently using version 7.1 SP6 which is built over Eclipse 3.3.0 and Java 5 Sdk.  I know it is a little bit more advanced than the most mayority of current SAP projects, which are probably using SAP NetWeaver Studio 7.0 but well, it is what I have.

There is an existing one-click installer from JRuby on Rails suitable for testing for a company called bitnami, which has a very interesting market proposition. I am myself I use RubyStack with no futher problems.
However, I have done manually to fully understand the development architecture. So let se which are the steps to perform:

1) Download JRuby: As first step, we are going to download latest version of JRuby from JRuby site. In this case is JRuby 1.1.4, which can be download from its repositories. Select what it suits for your operating system.

While you wait it to download, if you like you can read something or you want watch a video related to JRuby on Rails, plese the following video:

Ok, now it is already download, we have to find the file and unzip. Do not underestimate the time it takes to find the file wherever you have download it. :-) .

As I always install my Jvm on the root directory of my C: drive (c:\jdk15,c:\jdk16,..) . I am going to follow the same procedure again, as it will ease the procedure of adding it to my PATH route. I do not know you but I am a little tired of adding things to my PATH, that I am not going to use so I have created a .bat file which do this for me. For more details about how to getting started. Obviously, it is designed to support my best practices, but you know today is “Convention over configuration” or DIY.

Prerequisites

JRuby 1.1.3 or higher
Java 5 or higher
Rails 2.0 or higher

 Install Rails Framework ‘gems install rails -y’ (if behind a http proxy, set HTTP_PROXY=http://${http-proxy-host}:${http-proxy-port}/)
4. Install activerecord-jdbc ‘gems install activerecord-jdbc’
5. Install database/jdbc driver (for mysql http://mysql.com/)
6. Generate your Ruby on Rails application (http://rubyonrails.org/)
7. Modify database.yaml
       development:
           adapter: jdbc
           driver: com.mysql.jdbc.Driver (for mysql)
           url: jdbc:mysql://${database-hostname}/${db-schema}
           username: ${username}
           password: ${password}

8. Modify environment.rb by adding
       require ‘active_record/connection_adapters/jdbc_adapter’

9. Download rails-integration-${version}-SNAPSHOT.jar into the WEB-INF/lib by checking out and building the rails-integration project
svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration
10. Modify the template web.xml(see references below) with the right value of jruby.home
11. Create a WEB-INF directory in the RoR application directory
12. Copy web.xml to WEB-INF and rails-integration-${version}-SNAPSHOT.jar under WEB-INF/lib
13. Jar up the RoR application directory contents as a WAR file

Requests to appropriate context-root of the deployed web application should invoke your Ruby code !

If you’d like to automate the building of a war file:
Edit rails-integration/build.xml and add the following XML snippet
  <property environment=”env”/>
  <target name=”build-rails-war” depends=”jar”>
    <delete file=”${rails-app-dir}/${rails-app-name}.war”/>
    <mkdir dir=”${rails-app-dir}/WEB-INF/lib”/>
    <copy todir=”${rails-app-dir}/WEB-INF/lib”>
      <fileset file=”${maven.build.directory}/${maven.build.final.name}.jar”/>
      <fileset file=”${maven.repo.local}/org/jruby/jruby/0.9.1/jruby-0.9.1.jar”/>
      <fileset file=”${maven.repo.local}/asm/asm/2.2.2/asm-2.2.2.jar”/>
      <fileset file=”${maven.repo.local}/javax/activation/activation/1.1/activation-1.1.jar”/>
    </copy>
    <copy todir=”${rails-app-dir}/WEB-INF/”>
      <fileset file=”samples/scaffold/WEB-INF/web.xml”/>
    </copy>
    <replace file=”${rails-app-dir}/WEB-INF/web.xml” token=”/usr/local/jruby” value=”${env.JRUBY_HOME}”/>
    <jar jarfile=”${rails-app-dir}/${rails-app-name}.war” basedir=”${rails-app-dir}”/>
  </target>
Make sure JRUBY_HOME is set and run
‘ant -Drails-app-dir=${ror-app-dir} -Drails-app-name=${war-file-name} build-rails-war’
${ror-app-dir}/${ror-app-name}.war should be ready for deployment !

jruby -S gem install -y rails warbler

$JRUBY_HOME/bin/gem install activerecord-jdbc-adapter -y

modify database.yml

development:
adapter: jdbc
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost/blabla_development
username: root
password: root

Modify environment.rb

require File.join(File.dirname(__FILE__), 'boot')
if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end
I would recommend to read of The empty Way
JRuby entries on Wordpress

Rails::Initializer.run do |config|

This article is based on the following references:

Kind regards

Categories: JRuby, sap Tags: , ,

Developing Java with SAP MaxDB Database – Part 1

August 27th, 2008 admin No comments

SAP MaxDB is a relational database that provides functions for creating, using, and managing databases and the software comprises the database kernel, tools, and interfaces.

SAP MaxDB has its own JDBC Driver which we can used to execute SQL statements with Java. It is a JDBC 2.0, that you can find on the following location of the installed MaxDB JDBC driver file at:
\runtime\jar\sapdbc.jar . For instance, when I installed on my local machine I did it on the following location:
D:\sapdb\programs\runtime\jar
The java class for the JDBC drive is the com.sap.dbtech.jdbc.DriverSapDB

Well, that enough for today. On the next
Kind regards

SAP MaxDB Database is like Phoenix Bird

August 27th, 2008 admin 1 comment

All:

Due to the acquisition of MySQL by Sun, from October 5, 2007 MaxDB returns to be maintained by SAP again. This is an important news in two senses, on one side it is sad since mysql and maxdb have always been my favorite databases and having both supported by the same team was something that pleased me a lot.

But now situation have change and although I am going to still using mysql for many of my projects, I have decided to give some support to this database as well apart from the one that SAP gives to it on its own developer’s web siteand in itsown wiki site.

To make a little bit of history and put everybody in context, this is a open source project SAP launched in order to compete with its biggest rival Oracle on the database market. If the database was previously acquired from another vendor that something I do not know. Codename as sapdb it was released 7.3 and 7.4 versions.

In 2004, not having the sucess expected, they decided to handle this project to MySQL AB at the same time that SAP Ventures (SAP Venture Capital company )takes a participation at the company. They changed the name to MaxDB and together with MySQL AB, they launched around to 2005 the MaxDB 7.5. This project was meant to be an Open Source Enterprise Database alternative to Oracle for companies using MySQL for small applications.

As we said before, since SUN has acquire mysql, the MaxDB support has returned back home to SAP as it is going to be used by the german software company as an alternative for its clients to comercial databases.   Additionally, it is going to be used by SAP as the database of choice for its SaaS software, called, at least today, SAP BusinessByDesign. Obviously, considering it is no being yet launched this name will obviously changed in the future.

What will be future of SAP MaxDb now that it has been separated from mysql, some will say not very good, on my opinion that I have been working with SAP products for almost 10 years, it’s life it is about to begin. One I have learned from SAP is that never quit an idea. It will change names, strategies, versions, but if they believe they need to launch a database. Do not worry, it will take 20 years but they will make SAPDB, MaxDB , SAP MaxDB or whatever name leader on the database market.

Kind regards

Categories: sap, sap maxdb Tags: , , ,