Discussion:
problems with spring integration
hrbaer
2011-03-29 22:40:54 UTC
Permalink
Hi all,

I did some research within the forum but I didn't find the answer yet :(

I tried to integrate Spring (using
https://cwiki.apache.org/WICKET/spring.html#Spring-ApplicationObjectApproach
Spring + WICKET ) but I still have an error.

I added the following lines to my web.xml:

wicket
org.apache.wicket.protocol.http.WicketServlet

applicationFactoryClassName
org.apache.wicket.spring.SpringWebApplicationFactory

1



contextConfigLocation
/WEB-INF/applicationContext.xml


org.springframework.web.context.ContextLoaderListener


Within my xxxApplication file I added:
public class HomeApplication extends AuthenticatedWebApplication {

private UserService userService;

public void setUserService( UserService userService ) {
this.userService = userService;
}
public UserService getUserService() {
return this.userService;
}

(...)

And within my java file there is:
public class Test extends WebPage {
private UserService getUserService() {
return ( (xxxApplication) getApplication()).getUserService();
}

(...)

}

So if I start the server I invoke the setter of the method setUserService of
my xxxApplication class.
But once I call getUserService() of my java file the return value is null!?

Any ideas?
Thanks in advance.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3416484.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Michael O'Cleirigh
2011-03-30 01:48:13 UTC
Permalink
When you use spring there needs to be a wicket application bean defined
in your applicationContext.xml, I believe the default name is
"wicketApplication".

So you can instruct it to be autowired by type and then use the
@Autowired annotation to get services injected into the application.

However for most cases this is not what you want. You need to consider
the serialization aspects of wicket. The primary danger is that your
service gets serialized with a Page or Panel and that the serialization
cascades and serializes the entire spring container and all other
beans. The page is serialized after each request including ajax requests.

The normal approach is to use the @SpringBean annotation within
Component inheriting classes (like Page and Panel) as this will wrap
your service class in a light weight proxy that can be serialized
quickly and still allow the bean lookup from the application context to
occur on deserialization.

The only trick is that the assignment occurs in the parent class so you
need to not initialize your services to anything (otherwise you
initialize the variable in the base class and it is then cleared in the
current class).

Do:

@SpringBean (name="service")
private Service service;

Don't do this:
@SpringBean (name="service")
private Service service = null;

Regards,

Mike
Post by hrbaer
Hi all,
I did some research within the forum but I didn't find the answer yet :(
I tried to integrate Spring (using
https://cwiki.apache.org/WICKET/spring.html#Spring-ApplicationObjectApproach
Spring + WICKET ) but I still have an error.
wicket
org.apache.wicket.protocol.http.WicketServlet
applicationFactoryClassName
org.apache.wicket.spring.SpringWebApplicationFactory
1
contextConfigLocation
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
public class HomeApplication extends AuthenticatedWebApplication {
private UserService userService;
public void setUserService( UserService userService ) {
this.userService = userService;
}
public UserService getUserService() {
return this.userService;
}
(...)
public class Test extends WebPage {
private UserService getUserService() {
return ( (xxxApplication) getApplication()).getUserService();
}
(...)
}
So if I start the server I invoke the setter of the method setUserService of
my xxxApplication class.
But once I call getUserService() of my java file the return value is null!?
Any ideas?
Thanks in advance.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3416484.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
hrbaer
2011-03-30 15:23:52 UTC
Permalink
I added wicket-spring-annot to my project, removed all of the previous spring
code and just added getComponentInstantiationListeners().add(new
SpringComponentInjector(this)); to the init method of my xxxApplication
class.

But now I'm getting an error:
The type org.apache.wicket.injection.ComponentInjector cannot be resolved.
It is indirectly referenced from required .class files

Any idea?
Thanks in advance.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418401.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
James Carman
2011-03-30 15:28:04 UTC
Permalink
Are you using maven? If so, you should have all the dependencies you
need. If not, you'll need wicket-ioc.jar
Post by hrbaer
I added wicket-spring-annot to my project, removed all of the previous spring
code and just added getComponentInstantiationListeners().add(new
SpringComponentInjector(this)); to the init method of my xxxApplication
class.
The type org.apache.wicket.injection.ComponentInjector cannot be resolved.
It is indirectly referenced from required .class files
Any idea?
Thanks in advance.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418401.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
hrbaer
2011-03-30 15:41:41 UTC
Permalink
No, I don't. So adding wicket-ioc.jar to my project solves this problem.

But because of the fact I don't have a default constructor I get an
exception.
My constructor looks like public Test( PageParameters params ){ ... }.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418449.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
hrbaer
2011-03-30 15:56:40 UTC
Permalink
Just to summarize my status:

I've added addComponentInstantiationListener( new
SpringComponentInjector(this) ); to the init method of my xxxApplication
file, I added to my applicationContext and withing my WebPage I have this
code:

public class Test extends WebPage {

@SpringBean
private UserService userService;

public Test( PageParameters params ) {

(...)

}

If I add



to the applicationContext I get the error "Could not instantiate bean class
[de.Test]: No default constructor found;"

If I don't add this line I get the error message "WicketMessage: Can't
instantiate page using constructor public
de.Test(org.apache.wicket.PageParameters) and argument
Root cause:
java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback (...)"

At the moment I'm at a loss. Every help would be appreciated.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418488.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
moèz ben rhouma
2011-03-30 16:02:51 UTC
Permalink
Hi,
For this error:
*java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback (...)*

you can add the cglib-nodep library .

I think, this link (
http://javajeedevelopment.blogspot.com/2011/03/integrating-spring-security-3-with.html)
can help you.

Thanks
Post by hrbaer
I've added addComponentInstantiationListener( new
SpringComponentInjector(this) ); to the init method of my xxxApplication
file, I added to my applicationContext and withing my WebPage I have this
public class Test extends WebPage {
@SpringBean
private UserService userService;
public Test( PageParameters params ) {
(...)
}
If I add
to the applicationContext I get the error "Could not instantiate bean class
[de.Test]: No default constructor found;"
If I don't add this line I get the error message "WicketMessage: Can't
instantiate page using constructor public
de.Test(org.apache.wicket.PageParameters) and argument
java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback (...)"
At the moment I'm at a loss. Every help would be appreciated.
--
http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418488.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
jcgarciam
2011-03-30 17:22:17 UTC
Permalink
Hi,

I believe the problem to your [Could not instantiate bean class [de.Test]:
No default constructor found;] is that your are setting up a Wicket Page
(without default constructor) as a managed bean in Spring, when what you
actually mean was to define your [UserService] as the Spring bean.

Spring doesn't to managed the Wicket pages specifically, just bind your
services and then use the @SpringBean annotation on it and you will be fine.


On Wed, Mar 30, 2011 at 12:56 PM, hrbaer [via Apache Wicket] <
I've added *addComponentInstantiationListener( new
SpringComponentInjector(this) );* to the init method of my xxxApplication
file, I added *<bean id="userService"
class="de.service.UserService"></bean>* to my applicationContext and
public class Test extends WebPage {
@SpringBean
private UserService userService;
public Test( PageParameters params ) {
(...)
}
If I add
<bean id="test" class="de.Test">
<property name="userService" ref="userService"/>
</bean>
to the applicationContext I get the error "Could not instantiate bean class
[de.Test]: No default constructor found;"
If I don't add this line I get the error message "*WicketMessage: Can't
instantiate page using constructor public
de.Test(org.apache.wicket.PageParameters) and argument
java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback (...)*"
At the moment I'm at a loss. Every help would be appreciated.
------------------------------
If you reply to this email, your message will be added to the discussion
http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418488.html
To start a new topic under Apache Wicket, email
To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
--
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
--Anyone who has never made a mistake has never tried anything new.--


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3418767.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
hrbaer
2011-04-01 22:05:32 UTC
Permalink
This works like a charm - thanks.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problems-with-spring-integration-tp3416484p3421269.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Loading...