camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Thygesen <pt.activ...@gmail.com>
Subject EJB Component JNDI lookup problems
Date Tue, 06 Sep 2011 14:05:02 GMT
I'm trying to get the EJB component to work with/in Glassfish 3.1.1. But I
get an lookup exception. What am I doing wrong?

/Peter

avax.naming.NamingException: Lookup failed for 'CamelInterface' in
SerialContext[myEnv={...removed...} [Root exception is
javax.naming.NameNotFoundException: CamelInterface not found]
at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
org.apache.camel.component.ejb.EjbRegistryBean.lookupBean(EjbRegistryBean.java:45)
at
org.apache.camel.component.bean.RegistryBean.getBean(RegistryBean.java:62)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:84)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)
at
org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:102)
at
org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:72)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:114)
at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:286)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:109)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:172)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:305)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:116)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:79)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)




Environment: Camel-2.8.0, Glassfish 3.1.1

INTERFACE:

@Remote

public interface CamelInterface {

public String helloWorld(String message);

}


IMPLEMENTATION:

@Stateless(name="Example", mappedName="CamelBeanJNDI")

public class CamelBean implements CamelInterface {

@Override

public String helloWorld(String message) {

  return "daws, " + message;

}

}


JNDI ENTRIES:

Checking JNDI entries on GF (asadmin list-jndi-entries)

...

CamelBeanJNDI#com.infopaq.research.sandbox.CamelInterface:
javax.naming.Reference

CamelBeanJNDI__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference

CamelBeanJNDI: javax.naming.Reference
...

CAMEL:
(project generated with camel-archetype-web)

Spring part:
<beans ....>
    <bean id="testRoute"
class="com.infopaq.research.sandbox.CamelEJBTest.RouteConfiguration"/>

    <camelContext trace="true" xmlns="http://camel.apache.org/schema/spring
">
        <camel:routeBuilder ref="testRoute"/>
    </camelContext>
</beans>

ROUTE CONFIGURATION:
public class RouteConfiguration extends RouteBuilder {

  @Override
  public void configure() throws Exception {

    // enlist EJB component using the JndiContext
    EjbComponent ejb = getContext().getComponent("ejb", EjbComponent.class);
    ejb.setContext(createEjbContext());

    from("timer://cameltest?fixedRate=true&period=6000")
        .routeId("camel-ejb-route")
        .process(new Processor() {
          @Override
          public void process(Exchange exchange) throws Exception {
            // also used for breakpoint....
            exchange.getIn().setBody("Bob", String.class);
          }
        })
        .to("ejb:CamelBeanJNDI?method=helloWorld")
        .setHeader(Exchange.FILE_NAME, constant("helloworld.txt"))   // dump
it in a file...
        .to("file:///var/tmp/camel-test")
        .to("log:com.infopaq.research.sandbox?showAll=true");

}

private static Context createEjbContext() throws NamingException {
    Properties properties = new Properties();
    properties.setProperty("java.naming.factory.initial",
        "com.sun.enterprise.naming.SerialInitContextFactory");
    properties.setProperty("java.naming.factory.url.pkgs",
        "com.sun.enterprise.naming");
    properties.setProperty("java.naming.factory.state",
        "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

    // I have tried to used these properties but it didnt help.
    // optional.  Defaults to localhost.  Only needed if web server is
running
    // on a different host than the appserver
    //properties.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    // optional.  Defaults to 3700.  Only needed if target orb port is not
3700.
    //properties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

    return new InitialContext(properties);
  }

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message