My wicet application also houses a webservice which previously used
the entitymanager to get things done. its web.xml required the
<persistence-context-ref>. however after building the wicket app (not
sure if that had anything to do with it) it mysteriously stopped
working. so now the webservice and wicket both use the dao's. I'll see
if i can remove the <persistence-context-ref> now. Especially since
all dao's are ejb's.

One odd thing i noticed with my webservice but could be of interest to
wicket users as wel.
You need the @ejb annotation even if you have no mechanism to
automatically inject you ejb's but are instead getting them from
initialcontext yourself. Apparently the @ejb annotation signals to the
container that it needs to make that ejb available or something.

Also you are right about all the issues of having the entitymanager in
your page logic, I am not doing that myself (anymore :)) and was just
asking out of curiosity since it should work.

Maurice

On 12/18/06, Filippo Diotalevi <[EMAIL PROTECTED]> wrote:
On 12/18/06, Maurice Marrink <[EMAIL PROTECTED]> wrote:
> Hey nice work,
> Just the other day i had put something together myself, and now i find
> more people have the need for ejb.
>
> I just wonder how is it that your ejb's are available in the
> initialcontext when your web.xml has the wrong version. I needed the
> following in my web.xml to get it to work
> :
> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee";
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>

Sorry! There are actually 2 web.xml files in the sample-application,
and you have probably looked at the wrong one (my fault, I'm gonna
delete the wrong web.xml)
The correct web.xml is at
wicket-javaee-examples/web/src/webapp/WEB-INF/web.xml and, if you look
at it, you will see it has the right servlet spec version (2.5)

Thank you for your signalation, I'll re-upload the sample-app without
the wrong version of the web.ml

> Also i placed:
> <persistence-context-ref>
>                 <persistence-context-ref-name>
>                         persistence/EntityManager
>                 </persistence-context-ref-name>
>                 <persistence-unit-name>myPU</persistence-unit-name>
>         </persistence-context-ref>
>
> in web.xml to have automatic access to the entitymanager in the dao
> (when annotated)

If the dao is an EJB, you shouldn't need the <persistence-context-ref>
because the EntityManager is injected directly by you application
server

> I havent had any luck getting a valid entitymanager injected directly
> in my wicket objects (@PersistenceContext). Anybody had any luck with
> that ?

Mmm... I'd prefer not to have the EntityManager injected directly in
the Wicket Page. It's mostly a matter of style (I don't want to put
the persistence logic directly in the page code) but there could be
also some issues with serialization of the Wicket page

--
Filippo Diotalevi
[EMAIL PROTECTED]
http://www.diotalevi.com/weblog
http://www.jugmilano.it

Reply via email to