Results 1 to 3 of 3

Thread: Another problem connecting to remote EJB's

  1. #1

    Default Another problem connecting to remote EJB's

    Hi,

    I've been trying to follow the Pro-Spring example on javaWorld, example in Rod's book and discussions on this list to connect to remote EJB's but all seems to be falling down at the JNDI lookup.

    I'm using Jboss 4.01 with Spring 1.2.1.

    I have three examples here but only one works. The old fashioned lookup job. The other two via Spring continue to give BeanCreation exceptions that the Object cannot be found, yet the jndi name is correct. I'm probably doing something wrong but can't figure out what at the moment.

    Here are the definitions in the applicationContext file

    <bean id="jndiJBoss" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g:org.jnp.interfaces</prop>
    </props>
    </property>
    </bean>

    <bean id="adminServiceHome" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate"><ref bean="jndiJBoss"/>
    </property>
    <property name="jndiName">
    <value>ejb/adminService</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    </bean>

    <bean id="adminService"
    class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiTemplate"><ref bean="jndiJBoss"/>
    </property>
    <property name="jndiName">
    <value>ejb/adminService</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    <property name="businessInterface">
    <value>
    nl.anwb.anwbnl.services.generic.admin.AdminService
    </value>
    </property>
    </bean>

    The ejb/jboss files

    <session>
    <display-name>AdminService</display-name>
    <ejb-name>AdminService</ejb-name>
    <home>
    nl.anwb.anwbnl.ejb.generic.admin.AdminServiceRemot eHome
    </home>
    <remote>
    nl.anwb.anwbnl.ejb.generic.admin.AdminServiceRemot e
    </remote>
    <local-home>
    nl.anwb.anwbnl.ejb.generic.admin.AdminServiceLocal Home
    </local-home>
    <local>
    nl.anwb.anwbnl.ejb.generic.admin.AdminServiceLocal
    </local>
    <ejb-class>
    nl.anwb.anwbnl.ejb.generic.admin.AdminServiceBean
    </ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <env-entry>
    <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>
    applicationContext.xml
    </env-entry-value>
    </env-entry>
    </session>

    <session>
    <ejb-name>AdminService</ejb-name>
    <jndi-name>ejb/adminService</jndi-name>
    </session>

    This code works, but via Spring doesn't seem to :-(

    Properties props = System.getProperties();
    props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
    props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
    props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

    Context ctx = new InitialContext(props);

    Object obj = ctx.lookup("ejb/adminService");

    What's strange is that adding the JNDI ref to the proxy doesn't seem to make much difference. So perhaps I'm setting that incorrectly?

    Colin

  2. #2

    Default Problem solved

    Well I went back to the book, had a beer and read chapter 7.

    My problem was that I had set the resourceRef property to true which meant that the jndi name was being prepended, which was not what I wanted.

    (this) problem solved, sorry for the noise.

    Colin

  3. #3
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Hey no problem - thanks for taking the time to come back and post your solution for others.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

Similar Threads

  1. Replies: 7
    Last Post: Feb 9th, 2006, 09:30 PM
  2. Swing accessing remote EJB's.
    By gegas in forum EJB
    Replies: 7
    Last Post: Sep 22nd, 2005, 05:23 AM
  3. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  4. Replies: 2
    Last Post: Apr 15th, 2005, 09:28 AM
  5. Problem: Return List w/ a Hessian Remote Serivce
    By charleszq in forum Remoting
    Replies: 1
    Last Post: Jan 11th, 2005, 09:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •