Multiple constructors in jruby

Hallo all,

I’m in need to re-implement this bean in jruby:

package camelinaction;

import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;

public class OrderStatusBean {

private ProducerTemplate template;

public OrderStatusBean() {

public OrderStatusBean(CamelContext context) {

public void setTemplate(ProducerTemplate template) {
    this.template = template;


Well: the problem is with the overloaded constructor. No problem if I
don’t need the CamelContext (just leave only the no-params constructor).

But when I need to receive the CamelContext I stumble in this problem:
if I omit the no-params constructor camel complains the lack of the
defaults constructor:

Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘epiReplicaQuery’ defined in file
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [it.unimore.cesia.EpiReplicaQuery]: No default
constructor found; nested exception is java.lang.NoSuchMethodException:

My (non working) translation in jruby is:

require ‘java’

java_import “org.apache.camel.ProducerTemplate”
java_import “org.apache.camel.CamelContext”
java_import “org.slf4j.Logger”
java_import “org.slf4j.LoggerFactory”
java_import “ch.qos.logback.classic.LoggerContext”

java_package “camelinaction”

class OrderStatusBean
def initialize(context)
@template = context.createProducerTemplate
@logger =
“.rb”)}”)“Hello from #{FILE}.”)

def send_msg“Sent mesg”)
@template.sendBody(“this is a test”);

Thank you for your help,


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs