Re: Wicket with JPA and container managed transactions

2012-10-09 Thread Dieter Tremel
Am 08.10.2012 17:37, schrieb Martin Grigorov:
 The JNDI lookup just done for you in normal JavaEE setup as well.
 So I think your code is OK.

Thank you Martin for your useful answers.

I posted a little more generic solution of an AbstractEjbModel in my
blog in
http://hotchpotch-blog.de/2012/10/09/wrapping-eines-ejb-in-ein-loadabledetachablemodel/
(only in german language).

If I have some more time I will have a look at javaee-inject. That
solution of packing EJB into CDI bean I could not make run, perhaps my
code hasn't been smart enough in this tests.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Martin Grigorov
Hi,

Are you aware of
https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/javaee-inject-parent
?

https://github.com/wicketstuff/core/wiki/Java-EE-Inject

On Mon, Oct 8, 2012 at 4:05 PM, Dieter Tremel tre...@tremel-computer.de wrote:
 Moving from JSF to Wicket 6.1.0 I am used to having all JPA operations
 in a EJB facade to use the container's (Glassfish 3.2.1) transaction
 management. I use and know wicket-cdi for injection, which works fine.

 Unfortunately, if I inject an EJB in a wicket page, the serialization
 checks of wicket complain that it is not serializable. This is true for
 EJB, I suppose since they are proxied by
 EJBLocalObjectInvocationHandlerDelegate. Frustrated I have read the
 thread around http://markmail.org/message/4esc7m5subft5ngu

 My thinking is blocked at this point. If I can't use jpa with container
 managed transactions wicket how is the simpliest way do achieve it? All
 examples I googled and also these in the book Wicket in Action are
 only reading data or using Spring, what I do not want to do.

 Thank you for any hint
 Dieter Tremel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread heapifyman
As far as I understood you have two possibilities:
1. Inject your EJB into a CDI component and inject that component into your
wicket pages using @Inject annotation. That should solve the serialization
problem but you will have an additional layer.
2. Use javaee-inject from wicketstuff [1] to inject your EJBs with @EJB
annotation into your wicket pages.

I've tried the second approach (though in JBoss, not glassfish) and so
far have had no problems with using both wicket-cdi and javaee-inject in
the same project. Maybe it's not so nice because you have to include two
dependencies and use two different kinds of annotations in your wicket
pages.

[1] https://github.com/wicketstuff/core/wiki/Java-EE-Inject


2012/10/8 Dieter Tremel tre...@tremel-computer.de

 Moving from JSF to Wicket 6.1.0 I am used to having all JPA operations
 in a EJB facade to use the container's (Glassfish 3.2.1) transaction
 management. I use and know wicket-cdi for injection, which works fine.

 Unfortunately, if I inject an EJB in a wicket page, the serialization
 checks of wicket complain that it is not serializable. This is true for
 EJB, I suppose since they are proxied by
 EJBLocalObjectInvocationHandlerDelegate. Frustrated I have read the
 thread around http://markmail.org/message/4esc7m5subft5ngu

 My thinking is blocked at this point. If I can't use jpa with container
 managed transactions wicket how is the simpliest way do achieve it? All
 examples I googled and also these in the book Wicket in Action are
 only reading data or using Spring, what I do not want to do.

 Thank you for any hint
 Dieter Tremel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Dieter Tremel
Am 08.10.2012 15:14, schrieb Martin Grigorov:
 Are you aware of
 https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/javaee-inject-parent
 ?

Hi Martin,
I know this lib an had a look at it. If I am right, it is just another
way of injection.
In my running example of implementing a data provider the injection
already works and a have a beautiful rendered result of my data. But
after the request the error around serialization is:
 SEVERE: Error serializing object class 
 de.tremel_computer.buchbeispiel.wicket.BuecherPage [object=[Page class = 
 de.tremel_computer.buchbeispiel.wicket.BuecherPage, id = 0, render count = 1]]
 org.apache.wicket.core.util.io.SerializableChecker$WicketNotSerializableException:
  Unable to serialize class: 
 com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate
 Field hierarchy is:
   0 [class=de.tremel_computer.buchbeispiel.wicket.BuecherPage, path=0]
 private java.lang.Object org.apache.wicket.MarkupContainer.children 
 [class=[Ljava.lang.Object;]
   java.lang.Object org.apache.wicket.Component.data[2] 
 [class=org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable,
  path=0:datatable]
 private java.lang.Object org.apache.wicket.MarkupContainer.children 
 [class=[Ljava.lang.Object;]
   java.lang.Object org.apache.wicket.Component.data[1] 
 [class=org.apache.wicket.markup.html.WebMarkupContainer, 
 path=0:datatable:body]
 private java.lang.Object 
 org.apache.wicket.MarkupContainer.children 
 [class=org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable$1,
  path=0:datatable:body:rows]
   private final 
 org.apache.wicket.markup.repeater.data.IDataProvider 
 org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider 
 [class=de.tremel_computer.wicketcrud.modeling.EntityDataProvider]
 private 
 de.tremel_computer.wicketcrud.controller.AbstractFacade 
 de.tremel_computer.wicketcrud.modeling.EntityDataProvider.facade 
 [class=de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__IntfBean__]
   private 
 de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__Intf__
  
 de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__IntfBean__.__ejb31_delegate
  [class=$Proxy182]
 protected java.lang.reflect.InvocationHandler 
 java.lang.reflect.Proxy.h 
 [class=com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate] - 
 field that is not serializable

I suppose with javaee-inject-parent I would have the same error after
rendering.

Thank You
Dieter

-- 
Tremel Computerhttp://www.tremel-computer.de
Dieter Tremel  mailto:tre...@tremel-computer.de
Rebenring 16   Tel +49 871 9357080
84032 Altdorf  Fax +49 871 9357081

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Martin Grigorov
Hi Dieter,

javaee-inject uses wicket-ioc and injects a serializable Proxy instead
of the EJB bean itself that was returned by the container. This is the
same as how Spring and Guice work.

See the response of heapifyman. The simplest would be use only CDI in
your Wicket code. Hide any usage of EJBs behind CDI.

On Mon, Oct 8, 2012 at 4:25 PM, Dieter Tremel tre...@tremel-computer.de wrote:
 Am 08.10.2012 15:14, schrieb Martin Grigorov:
 Are you aware of
 https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/javaee-inject-parent
 ?

 Hi Martin,
 I know this lib an had a look at it. If I am right, it is just another
 way of injection.
 In my running example of implementing a data provider the injection
 already works and a have a beautiful rendered result of my data. But
 after the request the error around serialization is:
 SEVERE: Error serializing object class 
 de.tremel_computer.buchbeispiel.wicket.BuecherPage [object=[Page class = 
 de.tremel_computer.buchbeispiel.wicket.BuecherPage, id = 0, render count = 
 1]]
 org.apache.wicket.core.util.io.SerializableChecker$WicketNotSerializableException:
  Unable to serialize class: 
 com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate
 Field hierarchy is:
   0 [class=de.tremel_computer.buchbeispiel.wicket.BuecherPage, path=0]
 private java.lang.Object org.apache.wicket.MarkupContainer.children 
 [class=[Ljava.lang.Object;]
   java.lang.Object org.apache.wicket.Component.data[2] 
 [class=org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable,
  path=0:datatable]
 private java.lang.Object org.apache.wicket.MarkupContainer.children 
 [class=[Ljava.lang.Object;]
   java.lang.Object org.apache.wicket.Component.data[1] 
 [class=org.apache.wicket.markup.html.WebMarkupContainer, 
 path=0:datatable:body]
 private java.lang.Object 
 org.apache.wicket.MarkupContainer.children 
 [class=org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable$1,
  path=0:datatable:body:rows]
   private final 
 org.apache.wicket.markup.repeater.data.IDataProvider 
 org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider 
 [class=de.tremel_computer.wicketcrud.modeling.EntityDataProvider]
 private 
 de.tremel_computer.wicketcrud.controller.AbstractFacade 
 de.tremel_computer.wicketcrud.modeling.EntityDataProvider.facade 
 [class=de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__IntfBean__]
   private 
 de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__Intf__
  
 de.tremel_computer.buchbeispiel.jpa.facade.__EJB31_Generated__BuchFacade__IntfBean__.__ejb31_delegate
  [class=$Proxy182]
 protected java.lang.reflect.InvocationHandler 
 java.lang.reflect.Proxy.h 
 [class=com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate] 
 - field that is not serializable

 I suppose with javaee-inject-parent I would have the same error after
 rendering.

 Thank You
 Dieter

 --
 Tremel Computerhttp://www.tremel-computer.de
 Dieter Tremel  mailto:tre...@tremel-computer.de
 Rebenring 16   Tel +49 871 9357080
 84032 Altdorf  Fax +49 871 9357081

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Dieter Tremel
Am 08.10.2012 15:34, schrieb Martin Grigorov:
 javaee-inject uses wicket-ioc and injects a serializable Proxy instead
 of the EJB bean itself that was returned by the container. This is the
 same as how Spring and Guice work.
 
 See the response of heapifyman. The simplest would be use only CDI in
 your Wicket code. Hide any usage of EJBs behind CDI.

Thank You both for details, I will try some tests in both directions.
Dieter


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Dieter Tremel
I found a different solution I would like to post for discussion:
I encapsulated the Facade in a LoadableDetachableModel like this:
 /**
  * Model for JPA facade beans.
  * @author Dieter Tremel tre...@tremel-computer.de
  */
 public class EntityFacadeModelE extends JPAEntity extends 
 LoadableDetachableModelAbstractFacadeE {
 
 private Class? extends JPAEntity entityClass;
 
 public EntityFacadeModel(Class? extends JPAEntity entityClass) {
 this.entityClass = entityClass;
 }
 
 @Override
 protected AbstractFacadeE load() {
 AbstractFacadeE result = null;
 try {
 InitialContext ctx = new InitialContext();
 result = (AbstractFacadeE) ctx.lookup(java:module/ + 
 entityClass.getSimpleName() + Facade);
 } catch (NamingException ex) {
 
 Logger.getLogger(EntityFacadeModel.class.getName()).log(Level.SEVERE, null, 
 ex);
 }
 return result;
 }
 }

I hope the JNDI lookup is a not too expensive operation, is it?

In the page I build this like:
 EntityDataProviderBuch buchProvider = new EntityDataProvider(new 
 EntityFacadeModelBuch(Buch.class));
 DefaultDataTableBuch, String dTable = new 
 DefaultDataTable(datatable, columns, buchProvider, 10);

And in the EntityDataProvider I have overwritten:
 @Override
 public void detach() {
 facadeModel.detach();
 super.detach();
 }

As a result there are no serialization errors in my trial. The lookup
will be called once per request.

What do you think?
Dieter


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket with JPA and container managed transactions

2012-10-08 Thread Martin Grigorov
Hi,

The JNDI lookup just done for you in normal JavaEE setup as well.
So I think your code is OK.

On Mon, Oct 8, 2012 at 6:24 PM, Dieter Tremel tre...@tremel-computer.de wrote:
 I found a different solution I would like to post for discussion:
 I encapsulated the Facade in a LoadableDetachableModel like this:
 /**
  * Model for JPA facade beans.
  * @author Dieter Tremel tre...@tremel-computer.de
  */
 public class EntityFacadeModelE extends JPAEntity extends 
 LoadableDetachableModelAbstractFacadeE {

 private Class? extends JPAEntity entityClass;

 public EntityFacadeModel(Class? extends JPAEntity entityClass) {
 this.entityClass = entityClass;
 }

 @Override
 protected AbstractFacadeE load() {
 AbstractFacadeE result = null;
 try {
 InitialContext ctx = new InitialContext();
 result = (AbstractFacadeE) ctx.lookup(java:module/ + 
 entityClass.getSimpleName() + Facade);
 } catch (NamingException ex) {
 
 Logger.getLogger(EntityFacadeModel.class.getName()).log(Level.SEVERE, null, 
 ex);
 }
 return result;
 }
 }

 I hope the JNDI lookup is a not too expensive operation, is it?

 In the page I build this like:
 EntityDataProviderBuch buchProvider = new EntityDataProvider(new 
 EntityFacadeModelBuch(Buch.class));
 DefaultDataTableBuch, String dTable = new 
 DefaultDataTable(datatable, columns, buchProvider, 10);

 And in the EntityDataProvider I have overwritten:
 @Override
 public void detach() {
 facadeModel.detach();
 super.detach();
 }

 As a result there are no serialization errors in my trial. The lookup
 will be called once per request.

 What do you think?
 Dieter


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org