Stripersist and dropdown menu / lazy loading

View: New views
9 Messages — Rating Filter:   Alert me  

Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I get this Exception when I initialise a dropdown with a Proxied entity.

ERROR EntityFormatter: 150 - The object passed in was not annotated with
@Entity or @MappedSuperclass!
java.lang.NullPointerException
at
net.sourceforge.stripes.tag.InputTagSupport.isItemSelected(InputTagSupport.java:218)


How can I avoid this ?
Thanks




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Aaron Porter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Lionel,
We'll probably need more than that to go on. Can you paste in some code?
A class or two and the JSP that demonstrates the problem would be very
helpful.

The only time I've had problems with lazy loading was when I was trying
to use entities that I had stored in the HttpSession on previous requests.

Aaron

Lionel wrote:

> Hi,
>
> I get this Exception when I initialise a dropdown with a Proxied entity.
>
> ERROR EntityFormatter: 150 - The object passed in was not annotated with
> @Entity or @MappedSuperclass!
> java.lang.NullPointerException
> at
> net.sourceforge.stripes.tag.InputTagSupport.isItemSelected(InputTagSupport.java:218)
>
>
> How can I avoid this ?
> Thanks
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@...
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Aaron Porter wrote:
> Hi Lionel,
> We'll probably need more than that to go on. Can you paste in some
> code?


Here is what I to in a Filter before chaining the request to Stripersist:

User user= (User)httpSession.getAttribute("user");
if(user==null){
  user.setUserNbConnect(user.getUserNbConnect()+1);
  Stripersist.getEntityManager().persist(user);
  httpSession.setAttribute("user", user);
  Stripersist.getEntityManager().getTransaction().commit();
}


In the ActionBean:

order = new Order();
order.setUser((User)httpSession.getAttribute("user"));


In the JSP:
<s:select name="order.user">


Here is the class seen by Entityformatter:
class com.package.User_$$_javassist_9

(or cglib)


> The only time I've had problems with lazy loading was when I was
> trying
> to use entities that I had stored in the HttpSession on previous
> requests.

this is the case.







-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lionel wrote:
> User user= (User)httpSession.getAttribute("user");
> if(user==null){

forgot:
user = userDao.findById(principal.getName());

>  user.setUserNbConnect(user.getUserNbConnect()+1);
> }


I need the user on each request for visibility filters and to display its
name.
I don't want to load the user on each request, and would like to avoid
second level cache...




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Aaron Porter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sounds like I need to dust of the old deproxify code that Remi wrote for Stripernate and stick it into Stripersist.

OK. I've updated SVN. Give that a shot and let me know if it works.

Aaron

Lionel wrote:
Aaron Porter wrote:
  
Hi Lionel,
We'll probably need more than that to go on. Can you paste in some
code?
    


Here is what I to in a Filter before chaining the request to Stripersist:

User user= (User)httpSession.getAttribute("user");
if(user==null){
  user.setUserNbConnect(user.getUserNbConnect()+1);
  Stripersist.getEntityManager().persist(user);
  httpSession.setAttribute("user", user);
  Stripersist.getEntityManager().getTransaction().commit();
}


In the ActionBean:

order = new Order();
order.setUser((User)httpSession.getAttribute("user"));


In the JSP:
<s:select name="order.user">


Here is the class seen by Entityformatter:
class com.package.User_$$_javassist_9

(or cglib)


  
The only time I've had problems with lazy loading was when I was
trying
to use entities that I had stored in the HttpSession on previous
requests.
    

this is the case.







-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Aaron Porter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The problem with sticking entities in the HttpSession is they get
detached when the request ends. If you're trying to do lazy loading
after they're detached it won't work.

What I do now is stick the id in the session instead of the entity then
I have a getUser() either in a base ActionBean or ActionBeanContext that
loads the entity if not cached, caches it, and gives it back.

The other option is to force the lazy loading properties to load before
the entity gets detached but that gets to be a maintenance nightmare.

Aaron

Lionel wrote:

> I need the user on each request for visibility filters and to display its
> name.
> I don't want to load the user on each request, and would like to avoid
> second level cache...
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@...
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I tried, but it didn't change.
 

DEBUG EntityUtil:194 - Finding..... @Id for com.package.User$$EnhancerByCGLIB$$d8977ea6

DEBUG EntityUtil:194 - Looking for @Id on field userLogin

DEBUG EntityUtil:194 - Found @Id for com.package.User on field userLogin

But the id value is still null.

 

If I log user.getUserLogin() in the actionBean, I can see it's value.

 

If I use a session.get(login) instead of a session.load(login) everything works fine so I will use that for now.

 

By the way, your deproxyfication only works for cglib. With javassist (the new default with hibernate 3.3) the classname is not the same:

com.package.User_$$_javassist_9

There an underscore that needs to be removed:

Unable to deproxify CGLIB proxy: com.package.User_ not found !

 

"Aaron Porter" a écrit dans le

OK. I've updated SVN. Give that a shot and let me know if it works.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Aaron,
 
I updated from svn and now everything works fine.
Thanks for the update !
 
Lionel
"Aaron Porter" <aaron@...> a écrit dans le message de news: 48935194.6000903@......
Sounds like I need to dust of the old deproxify code that Remi wrote for Stripernate and stick it into Stripersist.

OK. I've updated SVN. Give that a shot and let me know if it works.

Aaron


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Stripersist and dropdown menu / lazy loading

by Lionel-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Just a little issue with the last release: Stripersist now searches for persistance units in every loaded jar it finds.
I have an activemq-all.jar in my tomcat/lib, and it crashes: No Persistence provider for EntityManager named activemq.
Not a big deal, but on the production envrionment, it's not very nice to have such an exception when the server starts.
 
Is there some way to avoid that ?
"Lionel" <lionel@...> a écrit dans le message de news: hcc7ub$bnt$1@......
Hi Aaron,
 
I updated from svn and now everything works fine.
Thanks for the update !
 
Lionel

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users