Using JRuby with myBatis?

Does anyone know how to use myBatis with JRruby ?

I tried the following:

require “rubygems”
require “java”
require ‘jruby/core_ext’

java_import “”
java_import “”
java_import “org.apache.ibatis.session.SqlSessionFactory”
java_import “org.apache.ibatis.session.SqlSessionFactoryBuilder”

inputStream = Resources::getResourceAsStream(“mybatis-config.xml”)

class Vkprlist
attr_accessor :name


sqlSessionFactory =

But I get:

Error building SqlSession.

The error may exist in VkprlistMapper.xml

Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL

Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing
Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error
resolving class . Cause: org.apache.ibatis.type.TypeException: Could not
resolve type alias ‘Vkprlist’. Cause: java.lang.ClassNotFoundException:
Cannot find class: Vkprlist
(root) at test.rb:18


BTW: I’m using JRuby-

just have a look at the Vkprlist which java class it is after


it should be something like

this is the one you need to use for myBatis xml-config.

I never used myBatis but what you wrote sounded familiar to what we
tried to do with

(which we postponed until datamapper-2.0 shaping up)

  • Kristian

On Fri, Aug 24, 2012 at 7:53 PM, Roger G. [email protected] wrote:

Does anyone know how to use myBatis with JRruby ?

No, and not familiar with it… From google, I can see it does help
connecting to SQL and it’s in java.

So quite likely you’re using jdbc. After reading some of the
documentation, it looks much more complex than traditional ruby ORM
like Sequel/DataMapper/ActiveRecord with jdbc connectors.

Though it’s always nice to use pure java libraries in jruby, for this
once, I would strongly advise to stick to simple ORM mentioned above,
unless all your business logic is already mapped using myBatis.

(I for one use Sequel)


wrong it is now

Hi thanks for the reply. But using rubyobj.Vkprlist instead of Vkrplist
leads to the same error.

Regards Roger

Am 26.08.2012 um 11:30 schrieb kristian [email protected]: