You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bastian Voigt <po...@bastian-voigt.de> on 2007/03/08 22:10:52 UTC

Accessing EJB3s via annotations?

Hi *,

in Suns EJB tutorials all EJB calls are made via annotations like so:

@EJB private MyBeanInterface myBean;
.
.
void someMethod()
{
    myBean.callEJBMethod();
}
.
.


In Tapestry (4.0.2) Page and Component classes this annotation does not 
seem to work (NullPointerException) although it gives no compiler errors 
or anything like that. Can someone tell me why it does not work this 
way? How can I efficiently access EJB3s via their local interface from a 
tapestry application?

The problem is that glassfish supports only remote interfaces when using 
JNDI lookup. But I would rather like to use local interfaces as this 
should be faster.

Thank you very much for your help...

Regards,
Bastian


Re: Accessing EJB3s via annotations?

Posted by Jesse Kuhnert <jk...@gmail.com>.
Oh I hadn't even noticed...Good point. There's no limiting reason why
javassist wouldn't be able to do it very easily or the Tapestry
enhancement API, but you're right - there is currently no standard
direct way to do this unless you are a little familiar with the API
already.

If someone doesn't mind doing the Ejb part I'd be happy to make the
necessary relatively easy changes to the enhancement workers though..

On 3/13/07, James Carman <jc...@carmanconsulting.com> wrote:
> I don't know.  Would the enhancement workers allow you to enhance a field
> like that, though?  I can see where putting it on a method would be fairly
> straight-forward, but a field might be a bit tricky.
>
> On 3/13/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> >
> > It's not for the casual visitor of course, but the "integrated" way to
> > do it would be using the enhancement workers.
> >
> >
> > http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/module/tapestry.enhance.html
> >
> > On 3/8/07, Bastian Voigt <po...@bastian-voigt.de> wrote:
> > > Hi *,
> > >
> > > in Suns EJB tutorials all EJB calls are made via annotations like so:
> > >
> > > @EJB private MyBeanInterface myBean;
> > > .
> > > .
> > > void someMethod()
> > > {
> > >     myBean.callEJBMethod();
> > > }
> > > .
> > > .
> > >
> > >
> > > In Tapestry (4.0.2) Page and Component classes this annotation does not
> > > seem to work (NullPointerException) although it gives no compiler errors
> > > or anything like that. Can someone tell me why it does not work this
> > > way? How can I efficiently access EJB3s via their local interface from a
> > > tapestry application?
> > >
> > > The problem is that glassfish supports only remote interfaces when using
> > > JNDI lookup. But I would rather like to use local interfaces as this
> > > should be faster.
> > >
> > > Thank you very much for your help...
> > >
> > > Regards,
> > > Bastian
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Accessing EJB3s via annotations?

Posted by James Carman <jc...@carmanconsulting.com>.
I don't know.  Would the enhancement workers allow you to enhance a field
like that, though?  I can see where putting it on a method would be fairly
straight-forward, but a field might be a bit tricky.

On 3/13/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> It's not for the casual visitor of course, but the "integrated" way to
> do it would be using the enhancement workers.
>
>
> http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/module/tapestry.enhance.html
>
> On 3/8/07, Bastian Voigt <po...@bastian-voigt.de> wrote:
> > Hi *,
> >
> > in Suns EJB tutorials all EJB calls are made via annotations like so:
> >
> > @EJB private MyBeanInterface myBean;
> > .
> > .
> > void someMethod()
> > {
> >     myBean.callEJBMethod();
> > }
> > .
> > .
> >
> >
> > In Tapestry (4.0.2) Page and Component classes this annotation does not
> > seem to work (NullPointerException) although it gives no compiler errors
> > or anything like that. Can someone tell me why it does not work this
> > way? How can I efficiently access EJB3s via their local interface from a
> > tapestry application?
> >
> > The problem is that glassfish supports only remote interfaces when using
> > JNDI lookup. But I would rather like to use local interfaces as this
> > should be faster.
> >
> > Thank you very much for your help...
> >
> > Regards,
> > Bastian
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Accessing EJB3s via annotations?

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's not for the casual visitor of course, but the "integrated" way to
do it would be using the enhancement workers.

http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/module/tapestry.enhance.html

On 3/8/07, Bastian Voigt <po...@bastian-voigt.de> wrote:
> Hi *,
>
> in Suns EJB tutorials all EJB calls are made via annotations like so:
>
> @EJB private MyBeanInterface myBean;
> .
> .
> void someMethod()
> {
>     myBean.callEJBMethod();
> }
> .
> .
>
>
> In Tapestry (4.0.2) Page and Component classes this annotation does not
> seem to work (NullPointerException) although it gives no compiler errors
> or anything like that. Can someone tell me why it does not work this
> way? How can I efficiently access EJB3s via their local interface from a
> tapestry application?
>
> The problem is that glassfish supports only remote interfaces when using
> JNDI lookup. But I would rather like to use local interfaces as this
> should be faster.
>
> Thank you very much for your help...
>
> Regards,
> Bastian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Accessing EJB3s via annotations?

Posted by Howard Lewis Ship <hl...@gmail.com>.
As an ugly work-around, you could define "dumb" servlets who would
store their EJB references (the value stored into the field) into a
ServletContext using a well-known name.

The issue here is that the servlet spec wants to run the world from a
very limited view of what an application is (for them, application ==
servlet).  Tapestry pages and components, even in T5, are not servlets
and not subject to special treatment by the servlet class loader.

You might want to look into your server (JBoss, most likely) and see
if there's a way to go beyond the normal specification and let the
container do its magic on additional classes, such as Tapestry pages
and components.

On 3/8/07, Bastian Voigt <po...@bastian-voigt.de> wrote:
> Justin Walsh schrieb:
> > Well tapestry and EJB3 are two very different animals.
> >
> > The @EJB annotation works /_within/_ an EJB component (EJB
> > stateless/stateful session bean) because the EJB3 container is in
> > control of your EJB components (you probably annotated it with
> > @Stateless of @Stateful) and thus injects the referenced EJB3 element
> > into your component (behind the scenes) before you get hold of it.
> >
> Well, that's not all there is to @EJB annotations. They also work in
> web applications, e.g. when used in servlet classes.
>
> > If you really wanted to, I suspect you may be able to write a custom
> > enhancement worker (I think thats what they call them?) which inspects
> > tapestry components (pages etc) for ejb3 annotations, injecting the
> > appropriate references - but that would be up to you.
> >
> Maybe this is what I need. Unfortunately I am not very familiar with annotation workers and especially how to inject the "appropriate reference". Where can I start?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Accessing EJB3s via annotations?

Posted by Bastian Voigt <po...@bastian-voigt.de>.
Justin Walsh schrieb:
> Well tapestry and EJB3 are two very different animals.
>
> The @EJB annotation works /_within/_ an EJB component (EJB
> stateless/stateful session bean) because the EJB3 container is in
> control of your EJB components (you probably annotated it with
> @Stateless of @Stateful) and thus injects the referenced EJB3 element
> into your component (behind the scenes) before you get hold of it.
>   
Well, that's not all there is to @EJB annotations. They also work in  
web applications, e.g. when used in servlet classes.

> If you really wanted to, I suspect you may be able to write a custom
> enhancement worker (I think thats what they call them?) which inspects
> tapestry components (pages etc) for ejb3 annotations, injecting the
> appropriate references - but that would be up to you.
>   
Maybe this is what I need. Unfortunately I am not very familiar with annotation workers and especially how to inject the "appropriate reference". Where can I start?




Re: Accessing EJB3s via annotations?

Posted by Justin Walsh <ju...@sadalbari.com>.
Well tapestry and EJB3 are two very different animals.

The @EJB annotation works /_within/_ an EJB component (EJB
stateless/stateful session bean) because the EJB3 container is in
control of your EJB components (you probably annotated it with
@Stateless of @Stateful) and thus injects the referenced EJB3 element
into your component (behind the scenes) before you get hold of it.

Since tapestry is not an EJB container (and likewise EJB is not a
tapestry container) there is no way for tapestry to know what the
annotation @EJB means and it is ignored.

If you really wanted to, I suspect you may be able to write a custom
enhancement worker (I think thats what they call them?) which inspects
tapestry components (pages etc) for ejb3 annotations, injecting the
appropriate references - but that would be up to you.

Hope that helps

Bastian Voigt wrote:
> Hi *,
>
> in Suns EJB tutorials all EJB calls are made via annotations like so:
>
> @EJB private MyBeanInterface myBean;
> .
> .
> void someMethod()
> {
>    myBean.callEJBMethod();
> }
> .
> .
>
>
> In Tapestry (4.0.2) Page and Component classes this annotation does
> not seem to work (NullPointerException) although it gives no compiler
> errors or anything like that. Can someone tell me why it does not work
> this way? How can I efficiently access EJB3s via their local interface
> from a tapestry application?
>
> The problem is that glassfish supports only remote interfaces when
> using JNDI lookup. But I would rather like to use local interfaces as
> this should be faster.
>
> Thank you very much for your help...
>
> Regards,
> Bastian
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


-- 
Justin Walsh 
http://www.ewage.co.za