开发者

How to access EJBs in integration tests with Maven and Embedded Glassfish?

I'm doing integration tests in my app using maven-embedded-glassfish-plugin. Tests work well, except the ones where I'm trying to access EJBs using JDNI. How to access my EJBs?

EDIT

I managed to get a bit closer (I think so, anyway) to success.开发者_StackOverflow中文版 Now I get following error:

xxx.xxx.ejb.__EJB31_Generated__ItemDatabase__Intf____Bean__ cannot be cast to xxx.xxx.ejb.ItemDatabase

using InitialContext.lookup(). When I try to lookup some not existing class I get "Lookup failed" error, so clearly something is found, but it's somehow incompatible with original EJB class...


please feed us some more if you want proper help. E.g, are you accessing a remote or local EJB? What's the JNDI lookup string?

To my experience, there are 2 ways of running integration tests over a Glassfish embedded server.

  1. pragmatically create and launch a server

    • pros: minimal maven configuration, full control over the folder to deploy.
    • cons: you are stuck with only an EJB container. No JMS, nor web nor WS.
  2. run a server from the maven plugin

    • pros: full server running
    • cons: I still cannot access EJB through initial context, connection is refused. I'm asking a question in a separate thread about this.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜