camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Thygesen <pt.activ...@gmail.com>
Subject Re: EJB Component JNDI lookup problems
Date Wed, 07 Sep 2011 12:56:33 GMT
In this little test the camel route (web project) is part of my EAR project.

After a little digging it turned out that it had something to do with
security on Glassfish.

I fixed it (quick and dirty) by annotating the EJB bean with @PermitAll
I then added a user named "camel" and finally added "sun-application.xml" to
my EAR project with then following role-mapping:
<sun-application>
    <security-role-mapping>
        <role-name>CAMELTEST</role-name>
        <!-- a user I added in admin console -->
        <principal-name>camel</principal-name>
        <!-- a group which camel is also member of -->
        <group-name>users</group-name>
    </security-role-mapping>
</sun-application>

originally I also configured the server to use "camel" user principal as
default with "Default Principal To Role Mapping" enabled. But this I
disabled afterwards and it still works.

Maybe I'll post this litte experiment on my blog...

/Peter Thygesen

2011/9/7 Willem Jiang <willem.jiang@gmail.com>

> Can you look up you EJB with the jndi setting and name CamelBeanJNDI  as a
> simple EJB client ?
> It looks more like a EJB look up issue instead of camel-ejb component
> issue.
>
>
>
> On Tue Sep  6 22:05:02 2011, Peter Thygesen wrote:
>
>> 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$**
>> ProcessorToAsyncProcessorBridg**e.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 <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);
>>   }
>>
>> }
>>
>>
>
>
> --
> Willem
> ------------------------------**----
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.**com<http://willemjiang.blogspot.com>(English)
>        http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang Weibo: willemjiang
>

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