tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quintin Beukes <quin...@skywalk.co.za>
Subject Re: Maven + OpenEjb 3.1.2 Embed + spring 3 + tomcat (6.0.14 / mvn:tomcat plugin doesn't work
Date Fri, 06 Nov 2009 20:15:41 GMT
Have a look at this test case (put it in a project with OpenEJB as a
dependency). Or just copy the 2 listJndi() methods and invoke:
listJndi(myInitialContext). It will list the all the bindings to STDOUT.

--- SNIP ---
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import junit.framework.TestCase;

public class TestJndiBrowser extends TestCase
{
  public TestJndiBrowser(String testName)
  {
    super(testName);
  }


  public void listJndi(InitialContext ctx) throws Exception
  {
    listJndi(ctx, "", null);
  }

  public void listJndi(InitialContext ctx, String path, String clazz) throws
Exception
  {
    System.out.println(path + (clazz != null ? " (" + clazz + ")" : ""));

    NamingEnumeration<NameClassPair> list = ctx.list(path);

    if (list == null) return;

    while (list.hasMore())
    {
      NameClassPair pair = list.next();
      listJndi(ctx, path + "/" + pair.getName(), pair.getClassName());
    }
  }

  public void testSomeMethod() throws Exception
  {
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
    InitialContext ctx = new InitialContext(env);
    listJndi(ctx);
  }
}
--- SNIP ---

I put it with the following 2 EJBs:

@Stateless(mappedName="/alternative/mapping/NewSessionBean1")
public class NewSessionBean1 implements NewSessionBean1Remote,
NewSessionBean1Local {

@Stateless
public class NewSessionBean2 implements NewSessionBean2Remote,
NewSessionBean2Local {

It gives this output (check at the end how it lists the mappings):
Running test.testmavenejb.TestJndiBrowser
Apache OpenEJB 3.1.2    build: 20091010-03:11
http://openejb.apache.org/
INFO - openejb.home = /home/quintin/tmp/test-maven-ejb
INFO - openejb.base = /home/quintin/tmp/test-maven-ejb
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath:
/home/quintin/tmp/test-maven-ejb/target/classes
INFO - Beginning load: /home/quintin/tmp/test-maven-ejb/target/classes
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean NewSessionBean2:
Container(type=STATELESS, id=Default Stateless Container)
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
INFO - Jndi(name=NewSessionBean2Local) -->
Ejb(deployment-id=NewSessionBean2)
INFO - Jndi(name=NewSessionBean2Remote) -->
Ejb(deployment-id=NewSessionBean2)
INFO - Jndi(name=NewSessionBean1Local) -->
Ejb(deployment-id=NewSessionBean1)
INFO - Jndi(name=/alternative/mapping/NewSessionBean1) -->
Ejb(deployment-id=NewSessionBean1)
INFO - Created Ejb(deployment-id=NewSessionBean2, ejb-name=NewSessionBean2,
container=Default Stateless Container)
INFO - Created Ejb(deployment-id=NewSessionBean1, ejb-name=NewSessionBean1,
container=Default Stateless Container)
INFO - Deployed Application(path=classpath.ear)

/. (java.lang.String)
/NewSessionBean2Remote
(org.apache.openejb.core.ivm.naming.BusinessRemoteReference)
/alternative (org.apache.openejb.core.ivm.naming.IvmContext)
/alternative/mapping (org.apache.openejb.core.ivm.naming.IvmContext)
/alternative/mapping/NewSessionBean1
(org.apache.openejb.core.ivm.naming.BusinessRemoteReference)
/NewSessionBean2Local
(org.apache.openejb.core.ivm.naming.BusinessLocalReference)
/NewSessionBean1Local
(org.apache.openejb.core.ivm.naming.BusinessLocalReference)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.908 sec

On Fri, Nov 6, 2009 at 9:37 PM, Quintin Beukes <quintin@skywalk.co.za>wrote:

> Re. your JNDI browser. It's pretty easy to write a browser using a
> recursive function. The InitialContext has a way to list all names under a
> certain root.
>
> So you would have a function, which in pseudo code is something like this:
> function listJndi(path) {
>   print(path);
>   for all sub-path in context.lookup(path) {
>     listJndi(sub-path);
>   }
> }
>
> Quintin Beukes
>
>
>
> On Wed, Nov 4, 2009 at 5:45 PM, Cae Fernandes <ragedd@gmail.com> wrote:
>
>>
>> Just a quick followup, the description of the error that happens is the
>> same
>> as here:
>>
>> http://www.mulesoft.org/jira/browse/MULE-210
>>
>>
>> Cae Fernandes wrote:
>> >
>> > Hello guys,
>> >
>> > I would like some help please, I'll try to provide as much info as
>> > necessary.
>> > I'm developing a new project with maven, I decided to go with OpenEJb
>> for
>> > it's light embeded capabilities and also its spring integration.
>> >
>> > So, basically, embending openEjb would allow for my project to run with
>> > mvn:tomcat plugin.
>> > It doesn't.
>> >
>> > The problem is, in order for openEjb features to work, there is a
>> > dependency: org.apache.openejb + javaee-api - 5.0-2, which is geronimo's
>> > javaee api.
>> > The thing is that this API conflicts with tomcat's servlet api. This is
>> > actually pretty well known elsewhere. I found a post in a jira somewhere
>> > talking about this, and saying how the user had to replace tomcat's
>> > servlet
>> > jar with jeronimo's for this to work. But this doesn't seem like an
>> embed
>> > solution for me. The solution that worked for me was to get javaee6's
>> SDK
>> > modules from glassfish and put it inside tomcat's lib directory,
>> excludind
>> > geronimos's javaee api jars. But again, not an embed solution. I want to
>> > be
>> > able to do mvn install, mvn tomcat:run !
>> > I thought about downloading a javaeeapi.jar from maven, but not
>> geronimo's
>> > since it generated conflict, but there are no 'oficial' spots to
>> download
>> > this kind of jar, since it only comes with java ee SDK. I saw at
>> openejb's
>> > website that it was tested and it worked embeded with tomcat 6.0.14,
>> That
>> > was the tomcat local version I tried to make it work with and it didn't.
>> I
>> > wonder what could be the solution for this? Any OpenEJB embed solution
>> > with
>> > any tomcat + spring will require a j2ee api of some sort, since tomcat's
>> > default installation does not come with it.
>> >
>> > Any thoughts?
>> >
>> > The second thing is I declared a org.apache.openejb.spring.Resource
>> > DataSource bean with spring and it worked.
>> > But, I tried binding it back with spring jdniobjectfactory and I cannot
>> > find
>> > the DataSource resource bound to the JDNI env.
>> > I tried a whole bunch of paths, com:env:, java:env:Resource, tried
>> looking
>> > up only the bean id itself, nothing worked. Since there is no OpenEJB
>> JNDI
>> > Browser, how can I look at whatever is bound to jndi? I did this:
>> >
>> > <bean id="MySQLDataSource" name="MySQLDataSource"
>> > class="org.apache.openejb.spring.Resource"/>
>> > type=javax.sql.DataSource etc.. it worked, I could do a select at the DB
>> > and
>> > everything, I saw openejb's log saying it was configuring the service as
>> > default jdbc provider. I just think it may not have bound it to the jndi
>> > env
>> > (I tried all names and paths described at openejb documentation online).
>> >
>> > Any help is apreciated.
>> >
>> > Thanks,
>> > Carlos.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Maven-%2B-OpenEjb-3.1.2-Embed-%2B-spring-3-%2B-tomcat-%286.0.14---mvn%3Atomcat--plugin-doesn%27t-work-tp26196130p26198709.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>

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