You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by dablomatique <in...@dabla.be> on 2012/08/21 17:33:34 UTC

Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Hello,

I'm trying to make my Tomcat 6 + OpenEJB 3.1.4 project (almost identical to
this setup: 
http://dablomatique.wordpress.com/2012/01/31/building-collapsed-ear-through-maven-for-weblogic-tomcat-with-openejb-aka-tomee/
http://dablomatique.wordpress.com/2012/01/31/building-collapsed-ear-through-maven-for-weblogic-tomcat-with-openejb-aka-tomee/
) run on TomEE 1.0.1-SNAPSHOT.

Everything works fine after some minor modifications, except the fact that I
cannot invoke my deployed EJB's remotely.

Here is the client code:

@Test
    public void test() throws Exception
    {
        Properties props = new Properties();
       
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
        props.put(Context.PROVIDER_URL,"http://127.0.0.1:8081/tomee/ejb");
// http://127.0.0.1:8081/openejb/ejb
        Context ctx = new InitialContext(props);
        System.out.println("ctx: " + ctx);
        listContext(ctx, "");
        Object ref = ctx.lookup("PersonEJB");
        System.out.println("ref: " + ref);
        PersonEJBRemote remote =
(PersonEJBRemote)PortableRemoteObject.narrow(ref,PersonEJBRemote.class);
        System.out.println("remote: " + remote);
        PersonDetail result = remote.findByUserId("TestUser1");
        System.out.println(result);
    }

    // http://denistek.blogspot.be/2008/08/list-jndi-names.html
    /**
    * Recursively exhaust the JNDI tree
    */
    private static final void listContext(Context ctx, String indent) {
    try {
       NamingEnumeration list = ctx.listBindings("");
       while (list.hasMore()) {
           Binding item = (Binding) list.next();
           String className = item.getClassName();
           String name = item.getName();
           System.out.println("" + indent + className + " " + name);
           Object o = item.getObject();
           if (o instanceof javax.naming.Context) {
        listContext((Context) o, indent + " ");
           }
       }
    } catch (NamingException ex) {
       ex.printStackTrace();
    }
    }

When I runt this client against my Tomcat 6 + OpenEJB 3.1.4 server, then it
works and i see following output from JNDI listing:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running PersonEJBClient
ctx: javax.naming.InitialContext@74341960
java.lang.String .
javax.naming.Context openejb
 org.apache.openejb.core.ivm.naming.BusinessRemoteReference
ConfigurationInfoBus
inessRemote
 org.apache.openejb.core.ivm.naming.BusinessRemoteReference
DeployerBusinessRemo
te
org.apache.openejb.core.ivm.naming.BusinessRemoteReference AssignmentEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
RequestTimerTaskEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference PersonEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
RequestProcessorEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference PasswordEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference ResponseEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference SignalEJB
org.apache.openejb.core.ivm.naming.ObjectReference MEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference RequestEJB
org.apache.openejb.core.ivm.naming.BusinessRemoteReference RequestMDBSender
org.apache.openejb.core.ivm.naming.BusinessRemoteReference UserEJB
org.apache.openejb.core.ivm.naming.IntraVmJndiReference RequestMDB
ref: proxy=org.apache.openejb.client.StatelessEJBObjectHandler@61542a75
remote: proxy=org.apache.openejb.client.StatelessEJBObjectHandler@61542a75
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.388 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0


But when I run the same client against TomEE 1.0.0 or TomEE 1.0.1-SNAPSHOT,
then I only see those JNDI listings + the remote invocation fails (as the
remote EJB isn't found):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running PersonEJBClient
ctx: javax.naming.InitialContext@74341960
java.lang.String .
javax.naming.Context openejb
 org.apache.openejb.core.ivm.naming.BusinessRemoteReference
DeployerBusinessRemote
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.275 sec
<<< FAILURE!

Results :

Tests in error:
  test(PersonEJBClient)

Of course I change the provider URL according if I use TomEE or Tomcat with
OpenEJB (see comment in client test code).

Now I'm wondering why TomEE doesn't expose the Remote EJB's through JNDI?

Snippet from EJB code:

@Stateless(name="PersonEJB",mappedName="PersonEJB")
public class PersonEJB implements PersonEJBLocal, PersonEJBRemote { 
}

@Local
public interface PersonEJBLocal extends PersonEJBRemote {	
}

@Remote
public interface PersonEJBRemote {
	public PersonDetail findByUserId(final String userId) throws Exception;
	public PersonDetail activate(final PersonDetail person) throws Exception;
	public PersonDetail deactivate(final PersonDetail person) throws Exception;
	public PersonDetail changePassword(final PersonDetail person) throws
Exception;
	public PersonDetail create(final PersonDetail entity) throws Exception;
	public void delete(final Person entity) throws Exception;
	public PersonDetail update(final PersonDetail entity) throws Exception;
}

If this would work, then everything would be fine on TomEE, which is a great
solution by the way :)

Thanks for the support.



--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by dablomatique <da...@gmail.com>.
Never mind Romain, it is indeed working.

I forgot to change my open-ejb test dependency in Maven from version 3.1.4
to 4.0.0:

Was:

        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>openejb-cxf</artifactId>
            <version>3.1.4</version>
            <scope>test</scope>
        </dependency>

Changed to:

        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>openejb-cxf</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>

I also had to change lookup from "PersonEJB" to "PersonEJBRemote" as you
stated before, then it works.

Thank you for the fast support!

Greetz




--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954p4656979.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes that's the place,

not sure what can be the issue, we use remote lookup everyday in our build
and for TCKs.

If you are able to share a small project reproducing the issue we could
have a more efficient look i think

*Romain Manni-Bucau*
*Twitter: @rmannibucau*
*Blog: http://rmannibucau.wordpress.com*




2012/8/22 dablomatique <da...@gmail.com>

> Hi Romain,
>
> I've already tried that, it also doesn't work.
>
> The thing that worries me is that I've putted some code to display the JNDI
> entries from the given context int the PersonEJBClient code, when running
> against Tomcat with OpenEJB I see all the remote EJB's listed, but when
> running against TomEE I only see 3 entries (see original post).
>
> I suspect it has something to do with configuration.  Maybe to location of
> the ejb-jar.xml or something else, I don't know...
>
> Now the ejb-jar.xml is located under the WEB-INF, which was picked up in
> Tomcat with OpenEJB but I think it is also picked up in TomEE.
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954p4656977.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by dablomatique <da...@gmail.com>.
Hi Romain,

I've already tried that, it also doesn't work.

The thing that worries me is that I've putted some code to display the JNDI
entries from the given context int the PersonEJBClient code, when running
against Tomcat with OpenEJB I see all the remote EJB's listed, but when
running against TomEE I only see 3 entries (see original post).

I suspect it has something to do with configuration.  Maybe to location of
the ejb-jar.xml or something else, I don't know...

Now the ejb-jar.xml is located under the WEB-INF, which was picked up in
Tomcat with OpenEJB but I think it is also picked up in TomEE.





--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954p4656977.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by Romain Manni-Bucau <rm...@gmail.com>.
i'd go for a lookup on "PersonEJBRemote" to get the remote EJB

*Romain Manni-Bucau*
*Twitter: @rmannibucau*
*Blog: http://rmannibucau.wordpress.com*




2012/8/22 dablomatique <in...@dabla.be>

> http://openejb.979440.n4.nabble.com/file/n4656975/catalina.2012-08-22.log
> catalina.2012-08-22.log
>
> Hi Romain,
>
> Thanks for the reply, I uploaded the log file.
>
> Kind regards,
> David
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954p4656975.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by dablomatique <in...@dabla.be>.
http://openejb.979440.n4.nabble.com/file/n4656975/catalina.2012-08-22.log
catalina.2012-08-22.log 

Hi Romain,

Thanks for the reply, I uploaded the log file.

Kind regards,
David



--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954p4656975.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Remote EJB not accessible from TomEE 1.0.0 and TomEE 1.0.1-SNAPSHOT

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

Can you share the logs?

- Romain
Le 21 août 2012 18:32, "dablomatique" <in...@dabla.be> a écrit :

> Hello,
>
> I'm trying to make my Tomcat 6 + OpenEJB 3.1.4 project (almost identical to
> this setup:
>
> http://dablomatique.wordpress.com/2012/01/31/building-collapsed-ear-through-maven-for-weblogic-tomcat-with-openejb-aka-tomee/
>
> http://dablomatique.wordpress.com/2012/01/31/building-collapsed-ear-through-maven-for-weblogic-tomcat-with-openejb-aka-tomee/
> ) run on TomEE 1.0.1-SNAPSHOT.
>
> Everything works fine after some minor modifications, except the fact that
> I
> cannot invoke my deployed EJB's remotely.
>
> Here is the client code:
>
> @Test
>     public void test() throws Exception
>     {
>         Properties props = new Properties();
>
>
> props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
>         props.put(Context.PROVIDER_URL,"http://127.0.0.1:8081/tomee/ejb");
> // http://127.0.0.1:8081/openejb/ejb
>         Context ctx = new InitialContext(props);
>         System.out.println("ctx: " + ctx);
>         listContext(ctx, "");
>         Object ref = ctx.lookup("PersonEJB");
>         System.out.println("ref: " + ref);
>         PersonEJBRemote remote =
> (PersonEJBRemote)PortableRemoteObject.narrow(ref,PersonEJBRemote.class);
>         System.out.println("remote: " + remote);
>         PersonDetail result = remote.findByUserId("TestUser1");
>         System.out.println(result);
>     }
>
>     // http://denistek.blogspot.be/2008/08/list-jndi-names.html
>     /**
>     * Recursively exhaust the JNDI tree
>     */
>     private static final void listContext(Context ctx, String indent) {
>     try {
>        NamingEnumeration list = ctx.listBindings("");
>        while (list.hasMore()) {
>            Binding item = (Binding) list.next();
>            String className = item.getClassName();
>            String name = item.getName();
>            System.out.println("" + indent + className + " " + name);
>            Object o = item.getObject();
>            if (o instanceof javax.naming.Context) {
>         listContext((Context) o, indent + " ");
>            }
>        }
>     } catch (NamingException ex) {
>        ex.printStackTrace();
>     }
>     }
>
> When I runt this client against my Tomcat 6 + OpenEJB 3.1.4 server, then it
> works and i see following output from JNDI listing:
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running PersonEJBClient
> ctx: javax.naming.InitialContext@74341960
> java.lang.String .
> javax.naming.Context openejb
>  org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> ConfigurationInfoBus
> inessRemote
>  org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> DeployerBusinessRemo
> te
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference AssignmentEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> RequestTimerTaskEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference PersonEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> RequestProcessorEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference PasswordEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference ResponseEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference SignalEJB
> org.apache.openejb.core.ivm.naming.ObjectReference MEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference RequestEJB
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference RequestMDBSender
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference UserEJB
> org.apache.openejb.core.ivm.naming.IntraVmJndiReference RequestMDB
> ref: proxy=org.apache.openejb.client.StatelessEJBObjectHandler@61542a75
> remote: proxy=org.apache.openejb.client.StatelessEJBObjectHandler@61542a75
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.388 sec
>
> Results :
>
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>
>
> But when I run the same client against TomEE 1.0.0 or TomEE 1.0.1-SNAPSHOT,
> then I only see those JNDI listings + the remote invocation fails (as the
> remote EJB isn't found):
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running PersonEJBClient
> ctx: javax.naming.InitialContext@74341960
> java.lang.String .
> javax.naming.Context openejb
>  org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> DeployerBusinessRemote
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.275 sec
> <<< FAILURE!
>
> Results :
>
> Tests in error:
>   test(PersonEJBClient)
>
> Of course I change the provider URL according if I use TomEE or Tomcat with
> OpenEJB (see comment in client test code).
>
> Now I'm wondering why TomEE doesn't expose the Remote EJB's through JNDI?
>
> Snippet from EJB code:
>
> @Stateless(name="PersonEJB",mappedName="PersonEJB")
> public class PersonEJB implements PersonEJBLocal, PersonEJBRemote {
> }
>
> @Local
> public interface PersonEJBLocal extends PersonEJBRemote {
> }
>
> @Remote
> public interface PersonEJBRemote {
>         public PersonDetail findByUserId(final String userId) throws
> Exception;
>         public PersonDetail activate(final PersonDetail person) throws
> Exception;
>         public PersonDetail deactivate(final PersonDetail person) throws
> Exception;
>         public PersonDetail changePassword(final PersonDetail person)
> throws
> Exception;
>         public PersonDetail create(final PersonDetail entity) throws
> Exception;
>         public void delete(final Person entity) throws Exception;
>         public PersonDetail update(final PersonDetail entity) throws
> Exception;
> }
>
> If this would work, then everything would be fine on TomEE, which is a
> great
> solution by the way :)
>
> Thanks for the support.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Remote-EJB-not-accessible-from-TomEE-1-0-0-and-TomEE-1-0-1-SNAPSHOT-tp4656954.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>