Re: Problem using @SpringBean with Wicket 1.3.5

2009-01-20 Thread Kent Larsson
Hi Phillip,

The help I got from Igor Vaynberg solved my problem. It was the security
manager which was restricting my application from using the Reflection API.

I wrote this in our internal documentation:

A change which is normally done in the conf file catalina.policy is needed.
Ubuntu prefers to split that file into different parts and merge it before
starting the service. If we would edit catalina.policy our changes would be
lost next time the server starts and would never come in effect as that's
when the file is read. Instead we edit
/etc/tomcat5.5/policy.d/04webapps.policy and add the following three lines
to it at the end (webcarrot is the web project directory name):

grant codeBase file:/var/lib/tomcat5.5/webapps/webcarrot/- {
permission java.lang.reflect.ReflectPermission suppressAccessChecks;
};

I comment your answer below:

On Tue, Jan 20, 2009 at 4:59 AM, Phillip Rhodes
spamsu...@rhoderunner.comwrote:

 Kent,  I am using 1.3.5 fine with springbean. some differences that I see
 between your/mine is that I have the protected modifier.
 Mine:
@SpringBean(name = eventService) protected EventService
 eventService;


It works using private too.

As far as the Reflection API is concerned It does not matter. You can read
and change private fields using Reflection as well. It could matter if the
wicket-spring-annot project had made some decision to only support protected
 public modified fields. But I think it's a long shot and the Wicket Wiki
example uses private too: http://cwiki.apache.org/WICKET/spring.html .


 another difference: Try adding a slash to the beginning of your spring path
 param-valueclasspath:/applicationContext.xml/param-value


They don't use any slash in the example in Wicket in Action. But maybe they
both work. At least not using one works.


 Do you have a bean by the name of userRegistrationService in your spring
 context? In your code, you are just requesting a bean of the type, not by
 id.


No I named it UserRegistrationService (with a capital U). Yes I am
requesting by type, so why would the name matter? (I don't think it does.)


 try doing a ctx.getBean(userRegistrationService) and make sure it's not
 null.


I can get the bean by name using @SpringBean too. I tried changing my bean
definition (so there would be no name-class relation) to:

bean id=getmebymyname
class=net.opentranslation.webcollab.service.UserRegistrationServiceImpl /

And then I used it using

@SpringBean(name=getmebymyname)
UserRegistrationService userRegistrationService;

And it worked well.

Thank you for trying to help me though!



 HTH, Phillip

 On Jan 19, 2009, at 3:30 PM, Kent Larsson wrote:

  Hi,

 I've tried to solve this for several hours now, without success, but then
 again I'm not that experienced. :-)

 I have an application with Spring beans which I want to use from Wicket,
 using @SpringBean. To see that Spring works fine I've tried using my bean
 without the @SpringBean annotation. By having

   @Override
   protected void init() {
   super.init();
   ctx = new ClassPathXmlApplicationContext(applicationContext.xml);
   }

   public UserRegistrationService getUserRegistrationService() {
   return (UserRegistrationService) BeanFactoryUtils.beanOfType(ctx,
 UserRegistrationService.class);
   }

 In my class which extends WebApplication (my Application class). It works
 fine that way! So it must have something to do with how I try to use the
 @SpringBean annotation.

 First I have

   @Override
   protected void init() {
   super.init();
   addComponentInstantiationListener(new
 SpringComponentInjector(this));
   }

 In my Application class and in my web.xml I have added

   context-param
   param-namecontextConfigLocation/param-name
   param-valueclasspath:applicationContext.xml/param-value
   /context-param

   listener


 listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
   /listener

 and in my Page where I try to use the UserRegistrationService I have

   @SpringBean
   UserRegistrationService userRegistrationService;

   /**
* Constructor...
*/
   public UserRegistrationPage(final PageParameters parameters) {
   add(new Label(message,
 userRegistrationService.takeSomeString(hello service) ));
   }

 But when I try this I get

  WicketMessage: Can't instantiate page using constructor public

 net.mycompany.webcarrot.presentation.pages.UserRegistrationPage(org.apache.wicket.PageParameters)
 and argument 

 I have a complete stack trace at pastebin (to not pollute the mail with
 it)
 http://pastebin.com/f7c12d56c

 I hope someone more experienced with Wicket than me knows what's going on
 here. I've tried to solve it for a couple of hours, but I can't find any
 faults in it (I'm trying to follow the instructions in Wicket in Action).

 Thank you for your time reading! Any help is HIGHLY appreciated! Have a
 nice
 day!

 Best regards, Kent





Re: Problem using @SpringBean with Wicket 1.3.5

2009-01-20 Thread Kent Larsson
Thanks Igor!

That helped me.

I wrote this in our internal documentation and I'm including it in case
someone searches for this problem:

A change which is normally done in the conf file catalina.policy is needed.
Ubuntu prefers to split that file into different parts and merge it before
starting the service. If we would edit catalina.policy our changes would be
lost next time the server starts and would never come in effect as that's
when the file is read. Instead we edit
/etc/tomcat5.5/policy.d/04webapps.policy and add the following three lines
to it at the end (webcarrot is the web project directory name):

grant codeBase file:/var/lib/tomcat5.5/webapps/webcarrot/- {
permission java.lang.reflect.ReflectPermission suppressAccessChecks;
};

On Mon, Jan 19, 2009 at 9:43 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 you have to disable the security manager that your servlet container
 is using because it is blocking wicket's reflection calls.

 -igor

 On Mon, Jan 19, 2009 at 12:30 PM, Kent Larsson 
 kent.lars...@gmail.comhttps://mail.google.com/mail?view=cmtf=0to=kent.lars...@gmail.com
 wrote:
  Hi,
 
  I've tried to solve this for several hours now, without success, but then
  again I'm not that experienced. :-)
 
  I have an application with Spring beans which I want to use from Wicket,
  using @SpringBean. To see that Spring works fine I've tried using my bean
  without the @SpringBean annotation. By having
 
 @Override
 protected void init() {
 super.init();
 ctx = new
 ClassPathXmlApplicationContext(applicationContext.xml);
 }
 
 public UserRegistrationService getUserRegistrationService() {
 return (UserRegistrationService) BeanFactoryUtils.beanOfType(ctx,
  UserRegistrationService.class);
 }
 
  In my class which extends WebApplication (my Application class). It works
  fine that way! So it must have something to do with how I try to use the
  @SpringBean annotation.
 
  First I have
 
 @Override
 protected void init() {
 super.init();
 addComponentInstantiationListener(new
  SpringComponentInjector(this));
 }
 
  In my Application class and in my web.xml I have added
 
 context-param
 param-namecontextConfigLocation/param-name
 param-valueclasspath:applicationContext.xml/param-value
 /context-param
 
 listener
 
 
 listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
 /listener
 
  and in my Page where I try to use the UserRegistrationService I have
 
 @SpringBean
 UserRegistrationService userRegistrationService;
 
 /**
  * Constructor...
  */
 public UserRegistrationPage(final PageParameters parameters) {
 add(new Label(message,
  userRegistrationService.takeSomeString(hello service) ));
 }
 
  But when I try this I get
 
   WicketMessage: Can't instantiate page using constructor public
 
 net.mycompany.webcarrot.presentation.pages.UserRegistrationPage(org.apache.wicket.PageParameters)
  and argument 
 
  I have a complete stack trace at pastebin (to not pollute the mail with
 it)
  http://pastebin.com/f7c12d56c
 
  I hope someone more experienced with Wicket than me knows what's going on
  here. I've tried to solve it for a couple of hours, but I can't find any
  faults in it (I'm trying to follow the instructions in Wicket in Action).
 
  Thank you for your time reading! Any help is HIGHLY appreciated! Have a
 nice
  day!
 
  Best regards, Kent
 

 -
 To unsubscribe, e-mail: 
 users-unsubscr...@wicket.apache.orghttps://mail.google.com/mail?view=cmtf=0to=users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: 
 users-h...@wicket.apache.orghttps://mail.google.com/mail?view=cmtf=0to=users-h...@wicket.apache.org




Problem using @SpringBean with Wicket 1.3.5

2009-01-19 Thread Kent Larsson
Hi,

I've tried to solve this for several hours now, without success, but then
again I'm not that experienced. :-)

I have an application with Spring beans which I want to use from Wicket,
using @SpringBean. To see that Spring works fine I've tried using my bean
without the @SpringBean annotation. By having

@Override
protected void init() {
super.init();
ctx = new ClassPathXmlApplicationContext(applicationContext.xml);
}

public UserRegistrationService getUserRegistrationService() {
return (UserRegistrationService) BeanFactoryUtils.beanOfType(ctx,
UserRegistrationService.class);
}

In my class which extends WebApplication (my Application class). It works
fine that way! So it must have something to do with how I try to use the
@SpringBean annotation.

First I have

@Override
protected void init() {
super.init();
addComponentInstantiationListener(new
SpringComponentInjector(this));
}

In my Application class and in my web.xml I have added

context-param
param-namecontextConfigLocation/param-name
param-valueclasspath:applicationContext.xml/param-value
/context-param

listener

listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
/listener

and in my Page where I try to use the UserRegistrationService I have

@SpringBean
UserRegistrationService userRegistrationService;

/**
 * Constructor...
 */
public UserRegistrationPage(final PageParameters parameters) {
add(new Label(message,
userRegistrationService.takeSomeString(hello service) ));
}

But when I try this I get

 WicketMessage: Can't instantiate page using constructor public
net.mycompany.webcarrot.presentation.pages.UserRegistrationPage(org.apache.wicket.PageParameters)
and argument 

I have a complete stack trace at pastebin (to not pollute the mail with it)
http://pastebin.com/f7c12d56c

I hope someone more experienced with Wicket than me knows what's going on
here. I've tried to solve it for a couple of hours, but I can't find any
faults in it (I'm trying to follow the instructions in Wicket in Action).

Thank you for your time reading! Any help is HIGHLY appreciated! Have a nice
day!

Best regards, Kent


Re: Problem using @SpringBean with Wicket 1.3.5

2009-01-19 Thread Igor Vaynberg
you have to disable the security manager that your servlet container
is using because it is blocking wicket's reflection calls.

-igor

On Mon, Jan 19, 2009 at 12:30 PM, Kent Larsson kent.lars...@gmail.com wrote:
 Hi,

 I've tried to solve this for several hours now, without success, but then
 again I'm not that experienced. :-)

 I have an application with Spring beans which I want to use from Wicket,
 using @SpringBean. To see that Spring works fine I've tried using my bean
 without the @SpringBean annotation. By having

@Override
protected void init() {
super.init();
ctx = new ClassPathXmlApplicationContext(applicationContext.xml);
}

public UserRegistrationService getUserRegistrationService() {
return (UserRegistrationService) BeanFactoryUtils.beanOfType(ctx,
 UserRegistrationService.class);
}

 In my class which extends WebApplication (my Application class). It works
 fine that way! So it must have something to do with how I try to use the
 @SpringBean annotation.

 First I have

@Override
protected void init() {
super.init();
addComponentInstantiationListener(new
 SpringComponentInjector(this));
}

 In my Application class and in my web.xml I have added

context-param
param-namecontextConfigLocation/param-name
param-valueclasspath:applicationContext.xml/param-value
/context-param

listener

 listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
/listener

 and in my Page where I try to use the UserRegistrationService I have

@SpringBean
UserRegistrationService userRegistrationService;

/**
 * Constructor...
 */
public UserRegistrationPage(final PageParameters parameters) {
add(new Label(message,
 userRegistrationService.takeSomeString(hello service) ));
}

 But when I try this I get

  WicketMessage: Can't instantiate page using constructor public
 net.mycompany.webcarrot.presentation.pages.UserRegistrationPage(org.apache.wicket.PageParameters)
 and argument 

 I have a complete stack trace at pastebin (to not pollute the mail with it)
 http://pastebin.com/f7c12d56c

 I hope someone more experienced with Wicket than me knows what's going on
 here. I've tried to solve it for a couple of hours, but I can't find any
 faults in it (I'm trying to follow the instructions in Wicket in Action).

 Thank you for your time reading! Any help is HIGHLY appreciated! Have a nice
 day!

 Best regards, Kent


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



Re: Problem using @SpringBean with Wicket 1.3.5

2009-01-19 Thread Phillip Rhodes

Kent,
I am using 1.3.5 fine with springbean.
some differences that I see between your/mine is that I have the  
protected modifier.



Mine:
@SpringBean(name = eventService)
protected EventService eventService;

another difference:
Try adding a slash to the beginning of your spring path

   param-valueclasspath:/applicationContext.xml/param-value





Do you have a bean by the name of userRegistrationService in your  
spring context?

In your code, you are just requesting a bean of the type, not by id.

try doing a ctx.getBean(userRegistrationService) and make sure it's  
not null.


HTH
Phillip


On Jan 19, 2009, at 3:30 PM, Kent Larsson wrote:


Hi,

I've tried to solve this for several hours now, without success, but  
then

again I'm not that experienced. :-)

I have an application with Spring beans which I want to use from  
Wicket,
using @SpringBean. To see that Spring works fine I've tried using my  
bean

without the @SpringBean annotation. By having

   @Override
   protected void init() {
   super.init();
   ctx = new  
ClassPathXmlApplicationContext(applicationContext.xml);

   }

   public UserRegistrationService getUserRegistrationService() {
   return (UserRegistrationService)  
BeanFactoryUtils.beanOfType(ctx,

UserRegistrationService.class);
   }

In my class which extends WebApplication (my Application class). It  
works
fine that way! So it must have something to do with how I try to use  
the

@SpringBean annotation.

First I have

   @Override
   protected void init() {
   super.init();
   addComponentInstantiationListener(new
SpringComponentInjector(this));
   }

In my Application class and in my web.xml I have added

   context-param
   param-namecontextConfigLocation/param-name
   param-valueclasspath:applicationContext.xml/param-value
   /context-param

   listener

listener- 
classorg.springframework.web.context.ContextLoaderListener/ 
listener-class

   /listener

and in my Page where I try to use the UserRegistrationService I have

   @SpringBean
   UserRegistrationService userRegistrationService;

   /**
* Constructor...
*/
   public UserRegistrationPage(final PageParameters parameters) {
   add(new Label(message,
userRegistrationService.takeSomeString(hello service) ));
   }

But when I try this I get

 WicketMessage: Can't instantiate page using constructor public
net 
.mycompany 
.webcarrot 
.presentation 
.pages.UserRegistrationPage(org.apache.wicket.PageParameters)

and argument 

I have a complete stack trace at pastebin (to not pollute the mail  
with it)

http://pastebin.com/f7c12d56c

I hope someone more experienced with Wicket than me knows what's  
going on
here. I've tried to solve it for a couple of hours, but I can't find  
any
faults in it (I'm trying to follow the instructions in Wicket in  
Action).


Thank you for your time reading! Any help is HIGHLY appreciated!  
Have a nice

day!

Best regards, Kent