Same reason i guess, you use cross ejb in your mdb?
Le 6 sept. 2012 11:47, "Luca Merolla" <luca.mero...@gmail.com> a écrit :

> I have tried to place an MDB in the WAR... It still fails in the same way
> as for the Stateless bean.
>
> On Thu, Sep 6, 2012 at 8:04 AM, Romain Manni-Bucau <rmannibu...@gmail.com
> >wrote:
>
> > It is but it leads to the kind of deployment lifecycle you have (and
> from a
> > spec point of view not sure it is well defined)
> > Le 6 sept. 2012 00:17, "Luca Merolla" <luca.mero...@gmail.com> a écrit :
> >
> > > I have been investigating on this issue. The fact is failing not to
> > lookup
> > > for the EJB that is inside the WAR, but it is failing while building
> it.
> > >
> > > If I do remove @Stateless and the interface implementation from the
> > > WarBroadcasterBean it deploys fine and I guess WarBroadcaster is
> > considered
> > > a CDI bean.
> > > But in this case I'm not able to retrieve it by lookup...
> > >
> > > It is not possible to have EJBs both inside a WAR and into a library in
> > the
> > > same EAR?
> > >
> > > On Mon, Sep 3, 2012 at 6:44 PM, Romain Manni-Bucau <
> > rmannibu...@gmail.com
> > > >wrote:
> > >
> > > > Hmm maybe i got it wrong but in an ear you can share ejb for webapps
> so
> > > > putting all ejb in  ejbmodules of the ear instead of war will make it
> > > > consistent
> > > > Le 3 sept. 2012 18:29, "Luca Merolla" <luca.mero...@gmail.com> a
> > écrit :
> > > >
> > > > > They are inside an EAR folder. Would it make any difference if I
> do a
> > > > > packaged EAR?
> > > > >
> > > > > On Mon, Sep 3, 2012 at 3:33 PM, Romain Manni-Bucau <
> > > > rmannibu...@gmail.com
> > > > > >wrote:
> > > > >
> > > > > > Hmm, either managing this case or packaging an ear should solve
> it
> > > IMO
> > > > > > Le 3 sept. 2012 14:18, "Luca Merolla" <luca.mero...@gmail.com> a
> > > > écrit :
> > > > > >
> > > > > > > I changed a bit the code and I gave a try with @EJB and I get
> the
> > > > same
> > > > > > > exception.
> > > > > > >
> > > > > > > The reason why there was JNDI lookups is because we are calling
> > > > > actually
> > > > > > 2
> > > > > > > ejbs in 2 different wars that implements the same interface
> > > > > > >
> > > > > > > private BroadcasterBeanLocal warBroadcaster;
> > > > > > > private BroadcasterBeanLocal war2Broadcaster;
> > > > > > >
> > > > > > > probably that can be solved with @EJB(name="") or something
> > > similar.
> > > > > > >
> > > > > > > However, I think the problem is related to the order of
> > deployment.
> > > > > > > Basically when the EJB application (jar) is deployed, it starts
> > > with
> > > > > > Quartz
> > > > > > > for the timers, but at that time the WAR application hasn't
> been
> > > > > deployed
> > > > > > > yet so the warBroadcaster beans are not available and the
> > > deployment
> > > > > > fails
> > > > > > > with:
> > > > > > >
> > > > > > > SEVERE: Application could not be deployed:
> > > > > > >  /home/luca/bin/apache-tomee-snapshot/apps/Test.ear
> > > > > > > org.apache.openejb.OpenEJBException: Creating application
> failed:
> > > > > > > /home/luca/bin/apache-tomee-snapshot/apps/Test.ear: Error
> > building
> > > > bean
> > > > > > > 'WarBroadcasterBean'.  Exception: class
> org.apache.openejb.OpenE
> > > > > > > JBException: Error while loading bean class
> > > > > > > org.test.galaxy.WarBroadcasterBean for bean WarBroadcasterBean.
> > > > > Received
> > > > > > > message: Cannot locate the class
> > org.test.galaxy.WarBroadcasterBean
> > > > > from
> > > > > > >  the codebase
> > > > > > > [/home/luca/bin/apache-tomee-snapshot/apps/Test.ear/pn-galaxy]:
> > > Error
> > > > > > while
> > > > > > > loading bean class org.test.galaxy.WarBroadcasterBean for bean
> > > > > > > WarBroadcasterBean. Received message: C
> > > > > > > annot locate the class org.test.galaxy.WarBroadcasterBean from
> > the
> > > > > > codebase
> > > > > > > [/home/luca/bin/apache-tomee-snapshot/apps/Test.ear/pn-galaxy]
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:929)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:521)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:422)
> > > > > > >         at
> > > > > > >
> > > > >
> > >
> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:330)
> > > > > > >         at
> > > > org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
> > > > > > >         at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
> > > > > > >         at
> > > > > > >
> > > > >
> > >
> org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:231)
> > > > > > >         at
> > > > > > >
> > org.apache.tomee.catalina.TomcatLoader.init(TomcatLoader.java:131)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:113)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
> > > > > > >         at
> > > > > > >
> > org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
> > > > > > >         at
> > > > org.apache.catalina.startup.Catalina.load(Catalina.java:624)
> > > > > > >         at
> > > > org.apache.catalina.startup.Catalina.load(Catalina.java:649)
> > > > > > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > > Method)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > > >         at
> > > > > org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
> > > > > > >         at
> > > > > org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
> > > > > > > Caused by: org.apache.openejb.OpenEJBException: Error building
> > bean
> > > > > > > 'WarBroadcasterBean'.  Exception: class
> > > > > > > org.apache.openejb.OpenEJBException: Error while loading bean
> > class
> > > > > > > org.test.galaxy.WarBroadcasterBean for bean WarBroadcasterBean.
> > > > > Received
> > > > > > > message: Cannot locate the class
> > org.test.galaxy.WarBroadcasterBean
> > > > > from
> > > > > > > the codebase
> > > > > > > [/home/luca/bin/apache-tomee-snapshot/apps/Test.ear/pn-galaxy]:
> > > Error
> > > > > > while
> > > > > > > loading bean class org.test.galaxy.WarBroadcasterBean for bean
> > > > > > > WarBroadcasterBean. Received message: Cannot locate the class
> > > > > > > org.test.galaxy.WarBroadcasterBean from the codebase
> > > > > > > [/home/luca/bin/apache-tomee-snapshot/apps/Test.ear/pn-galaxy]
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:81)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:689)
> > > > > > >         ... 20 more
> > > > > > > Caused by: org.apache.openejb.OpenEJBException: Error while
> > loading
> > > > > bean
> > > > > > > class org.test.galaxy.WarBroadcasterBean for bean
> > > WarBroadcasterBean.
> > > > > > > Received message: Cannot locate the class
> > > > > > > org.test.galaxy.WarBroadcasterBean from the codebase
> > > > > > > [/home/luca/bin/apache-tomee-snapshot/apps/Test.ear/pn-galaxy]
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.load(EnterpriseBeanBuilder.java:428)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.loadClass(EnterpriseBeanBuilder.java:405)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.build(EnterpriseBeanBuilder.java:81)
> > > > > > >         at
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:66)
> > > > > > >         ... 21 more
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Mon, Sep 3, 2012 at 1:47 PM, Thiago Veronezi <
> > > thi...@veronezi.org
> > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > You could remove the init method altogether and simple inject
> > the
> > > > > bean
> > > > > > in
> > > > > > > > your object...
> > > > > > > >
> > > > > > > > @EJB
> > > > > > > > private WarBroadcaster warBroadcaster;
> > > > > > > >
> > > > > > > > This way you avoid JNDI lookups.
> > > > > > > >
> > > > > > > > []s,
> > > > > > > > Thiago.
> > > > > > > >
> > > > > > > >
> > > > > > > > On Mon, Sep 3, 2012 at 7:10 AM, Luca Merolla <
> > > > luca.mero...@gmail.com
> > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > I have a piece of code that I would like to port from JBoss
> > to
> > > > > TomEE.
> > > > > > > > > The old code, which was working on JBoss, is like that.
> > Inside
> > > > the
> > > > > > same
> > > > > > > > EAR
> > > > > > > > > folder I have:
> > > > > > > > >
> > > > > > > > > - EJB jar (with EJBs and timers)
> > > > > > > > > - WAR (web application, with 1 EJB)
> > > > > > > > >
> > > > > > > > > I have a requirement that the ejb timers (a method
> annotated
> > > with
> > > > > > > > > @Schedule)
> > > > > > > > > will perform a task every X seconds.
> > > > > > > > > This method calls an EJB (inside the jar) that will call
> > > another
> > > > > EJB,
> > > > > > > but
> > > > > > > > > this time in a WAR application.
> > > > > > > > >
> > > > > > > > > Basically the EJB in the jar has something like that:
> > > > > > > > >
> > > > > > > > > @PostConstruct
> > > > > > > > > public void init() {
> > > > > > > > > log.info("INIT-BROADCASTERS");
> > > > > > > > > try {
> > > > > > > > >  warBroadcaster = (BroadcasterBeanLocal) initialContext
> > > > > > > > > .lookup("java:app/pn-test/WarBroadcasterBean");
> > > > > > > > > } catch (NamingException e) {
> > > > > > > > > log.error("Problem looking up for broadcasters", e);
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > This approach seems to not work on TomEE. I have tried to
> > add:
> > > > > > > > >
> > > > > > > > > Properties p = new Properties();
> > > > > > > > > p.put(Context.INITIAL_CONTEXT_FACTORY,
> > > > > > > > > "org.apache.openejb.client.LocalInitialContextFactory");
> > > > > > > > > final InitialContext initialContext = new
> InitialContext(p);
> > > > > > > > >
> > > > > > > > > But still it can't find the bean. I don't know if it's
> > possible
> > > > to
> > > > > do
> > > > > > > > > something like that but anyway if you have any suggestions
> or
> > > > > > different
> > > > > > > > > approach I would be very keen to refactor this code to make
> > it
> > > > work
> > > > > > > > > properly on TomEE.
> > > > > > > > >
> > > > > > > > > Thanks in advance,
> > > > > > > > > Luca
> > > > > > > > >
> >
>

Reply via email to