You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by petros <pe...@cypoz.com> on 2008/03/27 00:00:49 UTC

ApplicationStateManager exception

I have a LayoutCmpnt.java with the following annotation and everything works
fine
   @ApplicationState
   private User currentPrincipal;

When I add the method overrideMe(User user) to the User POJO I am getting
the following exception. Removing the overrideMe(User user) fixes the
problem. Any ideas as to what I am doing wrong ?

Caused by: org.apache.tapestry.ioc.internal.util.TapestryException: Error
invoking constructor com.cypoz.ebooking.ui.model.user.User(User) (at
User.java:34) (for service 'ApplicationStateManager'): No service implements
the interface com.cypoz.ebooking.ui.model.user.User. [at
classpath:com/cypoz/ebooking/ui/components/LayoutCmpnt.tml, line 17, column
37]















public class User implements org.acegisecurity.userdetails.UserDetails
{    
    private Long id = new Long(0);
    private String username = ""; // required
    private String firstName = ""; // required
    private String lastName = ""; // required
    private Set<Role> roles = new HashSet<Role>();
    private ContactDetails contactDetails = new ContactDetails();
    private Address address = new Address();
    private String password = "";
    private boolean enabled = true;

   public User(){...}
   public User(User user){...}
   public void overrideMe(User user){...}   
   public ContactDetails getContactDetails(){...}
   public void setContactDetails(ContactDetails contactDetails){...}
   public Address getAddress(){...}
   public void setAddress(Address addressDetails){...}    
   public Long getId(){...}
   public Set<Role> getRoles(){...}
   public void addRole(Role role){...}
   public User(String username){...}
   public String getUsername(){...}
   public String getFirstName(){...}
   public String getLastName(){...}
   public String getFullName(){...}
   public void setId(Long id){...}
   public void setUsername(String username){...}
   public void setFirstName(String firstName){...}
   public void setLastName(String lastName){...}
   public void setRoles(Set<Role> roleDetails){...}
   public List<Role> getRolesAsList(){...}    
   public void setRolesAsList(List<Role> rolesAsList){...}
   public boolean equals(Object o){...}
   public int hashCode(){...}
   public String toString(){...}
   public GrantedAuthority[] getAuthorities(){...}    
   public List<String> getRoleNames(){...}        
   public String getRoleNamesAsOneString(){...}
   public String getPassword(){...}
   public void setPassword(String password){...}
   public boolean isAccountNonExpired() {...}
   public boolean isAccountNonLocked() {...}
   public boolean isCredentialsNonExpired() {...}
   public boolean isEnabled() {...}    
   public void setEnabled(boolean enabled){...}
}


-- 
View this message in context: http://www.nabble.com/ApplicationStateManager-exception-tp16318510p16318510.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: ApplicationStateManager exception

Posted by petros <pe...@cypoz.com>.
Yes, that fixed the problem but just to help debug this issue at a later
stage, adding the 
public void testMe(String test); creates the same problem also. 
It behaves as if I can't change the implementation of User. Please observe
that User extends the acegi UserDetails interface. I am not sure if that
contributes to the problem. 

Thanks for your help
Petros




Howard Lewis Ship wrote:
> 
> Not sure why the presense of the overrideMe() method would change things.
> 
> When Tapestry instantiates a bean (such as a User, here) it always
> finds the constructor with the *most* parameters.  Here it is trying
> to instantiate a User instance by injecting a User instance (into your
> copy-constructor).
> 
> This has come up in other contexts.  What's needed in an annotation to
> tell Tapestry which constructor to use, when it has a choice.
> 
> In any case, you can handle this by contributing a
> ApplicationStateContribution for type User to the
> ApplicationStateManager service.
> 
> This contribution defines the strategy and creator for an Application
> State Object.  The only built in strategy is named "session", and the
> ApplicationStateCreator interface has a single method: create().
> Thus:
> 
> public void
> contributeApplicationStateManager(MappedConfiguration<Class,ApplicationStateContribution>
> configuration)
> {
>   ApplicationStateCreator creator = new ApplicatonStateCreator() {
> public Object create() { return new User(); } };
>   configuration.add(User.class, new
> ApplicationStateContribution("session", creator));
> }
> 
> On Wed, Mar 26, 2008 at 4:00 PM, petros <pe...@cypoz.com> wrote:
>>
>>  I have a LayoutCmpnt.java with the following annotation and everything
>> works
>>  fine
>>    @ApplicationState
>>    private User currentPrincipal;
>>
>>  When I add the method overrideMe(User user) to the User POJO I am
>> getting
>>  the following exception. Removing the overrideMe(User user) fixes the
>>  problem. Any ideas as to what I am doing wrong ?
>>
>>  Caused by: org.apache.tapestry.ioc.internal.util.TapestryException:
>> Error
>>  invoking constructor com.cypoz.ebooking.ui.model.user.User(User) (at
>>  User.java:34) (for service 'ApplicationStateManager'): No service
>> implements
>>  the interface com.cypoz.ebooking.ui.model.user.User. [at
>>  classpath:com/cypoz/ebooking/ui/components/LayoutCmpnt.tml, line 17,
>> column
>>  37]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  public class User implements org.acegisecurity.userdetails.UserDetails
>>  {
>>     private Long id = new Long(0);
>>     private String username = ""; // required
>>     private String firstName = ""; // required
>>     private String lastName = ""; // required
>>     private Set<Role> roles = new HashSet<Role>();
>>     private ContactDetails contactDetails = new ContactDetails();
>>     private Address address = new Address();
>>     private String password = "";
>>     private boolean enabled = true;
>>
>>    public User(){...}
>>    public User(User user){...}
>>    public void overrideMe(User user){...}
>>    public ContactDetails getContactDetails(){...}
>>    public void setContactDetails(ContactDetails contactDetails){...}
>>    public Address getAddress(){...}
>>    public void setAddress(Address addressDetails){...}
>>    public Long getId(){...}
>>    public Set<Role> getRoles(){...}
>>    public void addRole(Role role){...}
>>    public User(String username){...}
>>    public String getUsername(){...}
>>    public String getFirstName(){...}
>>    public String getLastName(){...}
>>    public String getFullName(){...}
>>    public void setId(Long id){...}
>>    public void setUsername(String username){...}
>>    public void setFirstName(String firstName){...}
>>    public void setLastName(String lastName){...}
>>    public void setRoles(Set<Role> roleDetails){...}
>>    public List<Role> getRolesAsList(){...}
>>    public void setRolesAsList(List<Role> rolesAsList){...}
>>    public boolean equals(Object o){...}
>>    public int hashCode(){...}
>>    public String toString(){...}
>>    public GrantedAuthority[] getAuthorities(){...}
>>    public List<String> getRoleNames(){...}
>>    public String getRoleNamesAsOneString(){...}
>>    public String getPassword(){...}
>>    public void setPassword(String password){...}
>>    public boolean isAccountNonExpired() {...}
>>    public boolean isAccountNonLocked() {...}
>>    public boolean isCredentialsNonExpired() {...}
>>    public boolean isEnabled() {...}
>>    public void setEnabled(boolean enabled){...}
>>  }
>>
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/ApplicationStateManager-exception-tp16318510p16318510.html
>>  Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>  For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ApplicationStateManager-exception-tp16318510p16319546.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: ApplicationStateManager exception

Posted by Howard Lewis Ship <hl...@gmail.com>.
Not sure why the presense of the overrideMe() method would change things.

When Tapestry instantiates a bean (such as a User, here) it always
finds the constructor with the *most* parameters.  Here it is trying
to instantiate a User instance by injecting a User instance (into your
copy-constructor).

This has come up in other contexts.  What's needed in an annotation to
tell Tapestry which constructor to use, when it has a choice.

In any case, you can handle this by contributing a
ApplicationStateContribution for type User to the
ApplicationStateManager service.

This contribution defines the strategy and creator for an Application
State Object.  The only built in strategy is named "session", and the
ApplicationStateCreator interface has a single method: create().
Thus:

public void contributeApplicationStateManager(MappedConfiguration<Class,ApplicationStateContribution>
configuration)
{
  ApplicationStateCreator creator = new ApplicatonStateCreator() {
public Object create() { return new User(); } };
  configuration.add(User.class, new
ApplicationStateContribution("session", creator));
}

On Wed, Mar 26, 2008 at 4:00 PM, petros <pe...@cypoz.com> wrote:
>
>  I have a LayoutCmpnt.java with the following annotation and everything works
>  fine
>    @ApplicationState
>    private User currentPrincipal;
>
>  When I add the method overrideMe(User user) to the User POJO I am getting
>  the following exception. Removing the overrideMe(User user) fixes the
>  problem. Any ideas as to what I am doing wrong ?
>
>  Caused by: org.apache.tapestry.ioc.internal.util.TapestryException: Error
>  invoking constructor com.cypoz.ebooking.ui.model.user.User(User) (at
>  User.java:34) (for service 'ApplicationStateManager'): No service implements
>  the interface com.cypoz.ebooking.ui.model.user.User. [at
>  classpath:com/cypoz/ebooking/ui/components/LayoutCmpnt.tml, line 17, column
>  37]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>  public class User implements org.acegisecurity.userdetails.UserDetails
>  {
>     private Long id = new Long(0);
>     private String username = ""; // required
>     private String firstName = ""; // required
>     private String lastName = ""; // required
>     private Set<Role> roles = new HashSet<Role>();
>     private ContactDetails contactDetails = new ContactDetails();
>     private Address address = new Address();
>     private String password = "";
>     private boolean enabled = true;
>
>    public User(){...}
>    public User(User user){...}
>    public void overrideMe(User user){...}
>    public ContactDetails getContactDetails(){...}
>    public void setContactDetails(ContactDetails contactDetails){...}
>    public Address getAddress(){...}
>    public void setAddress(Address addressDetails){...}
>    public Long getId(){...}
>    public Set<Role> getRoles(){...}
>    public void addRole(Role role){...}
>    public User(String username){...}
>    public String getUsername(){...}
>    public String getFirstName(){...}
>    public String getLastName(){...}
>    public String getFullName(){...}
>    public void setId(Long id){...}
>    public void setUsername(String username){...}
>    public void setFirstName(String firstName){...}
>    public void setLastName(String lastName){...}
>    public void setRoles(Set<Role> roleDetails){...}
>    public List<Role> getRolesAsList(){...}
>    public void setRolesAsList(List<Role> rolesAsList){...}
>    public boolean equals(Object o){...}
>    public int hashCode(){...}
>    public String toString(){...}
>    public GrantedAuthority[] getAuthorities(){...}
>    public List<String> getRoleNames(){...}
>    public String getRoleNamesAsOneString(){...}
>    public String getPassword(){...}
>    public void setPassword(String password){...}
>    public boolean isAccountNonExpired() {...}
>    public boolean isAccountNonLocked() {...}
>    public boolean isCredentialsNonExpired() {...}
>    public boolean isEnabled() {...}
>    public void setEnabled(boolean enabled){...}
>  }
>
>
>  --
>  View this message in context: http://www.nabble.com/ApplicationStateManager-exception-tp16318510p16318510.html
>  Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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