Re: Wicket integration with Spring ldap
Hi, I removed the SpringContext filter but still got the same error . Then I changed the configuration based on the how to setup Wicket+Spring with annotation based (@Configuration) <https://github.com/jWeekend/LegUp/tree/master/wicket-spring-jpa> of yours. @Configuration @EnableTransactionManagement(proxyTargetClass = true) public class Config { @Bean public ILdapComposanteDao ldapComposanteDao() { ILdapComposanteDaoImpl iLdapComposanteDaoImpl = new ILdapComposanteDaoImpl(); iLdapComposanteDaoImpl.setLdapTemplate(ldapTemplate()); return iLdapComposanteDaoImpl; } @Bean public LdapTemplate ldapTemplate(){ return new LdapTemplate(contextSource()); } @Bean public DefaultDirContextValidator dirContextValidator (){ return new DefaultDirContextValidator(); } @Bean public PoolingContextSource contextSource(){ PoolingContextSource pc= new PoolingContextSource(); pc.setContextSource(contextSourceTarget()); pc.setDirContextValidator(dirContextValidator()); pc.setTestOnBorrow(true); pc.setTestWhileIdle(true); return pc; } @Bean public LdapContextSource contextSourceTarget(){ LdapContextSource ldapContextSource = new LdapContextSource(); ldapContextSource.setUrl("blablabla"); ldapContextSource.setBase("dc=xx,dc=xx,dc=fr"); ldapContextSource.setUserDn("cn=...,ou=,dc=...,dc=...,dc=fr"); ldapContextSource.setPassword("pwss"); return ldapContextSource; } } And I work as expected . Thanks you very much . -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-ldap-tp4662097p4662110.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket integration with Spring ldap
andler.doScope(SessionHandler.java:186) > at > > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965) > at > > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) > at > > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) > at > > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) > at > > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) > at org.eclipse.jetty.server.Server.handle(Server.java:348) > at > > org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452) > at > > org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884) > at > > org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938) > at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) > at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) > at > > org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) > at > > org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) > at > > org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) > at > > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) > at > > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) > at java.lang.Thread.run(Thread.java:662) > > > > > The > > org.univ.amemet.services.ldap.ILdapComposanteDaoImpl.getUFRs(ILdapComposanteDaoImpl.java:211) > show me that the bean* ldapTemplate is null.* > > > Any help will be appreciate. > > Thanks. > > > > > > > > > > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-ldap-tp4662097.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Wicket integration with Spring ldap
this.ldapComposanteDao = ldapComposanteDao; } } In the error messages, Last cause: null WicketMessage: Can't instantiate page using constructor 'public org.univ.amemet.pages.menu.ListeUfrsPage()'. An exception has been thrown during construction! Root cause: java.lang.NullPointerException at org.univ.amemet.services.ldap.ILdapComposanteDaoImpl.getUFRs(ILdapComposanteDaoImpl.java:211) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:435) at $Proxy48.getUFRs(Unknown Source) at org.univ.amemet.pages.menu.ListeUfrsPage.initListeUfrs(ListeUfrsPage.java:196) at org.univ.amemet.pages.menu.ListeUfrsPage.(ListeUfrsPage.java:96) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175) at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67) at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133) at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268) at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166) at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78) at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:269) at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165) at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861) at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289) at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1332) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:477) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:348) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) at java.lang.Thread.run(Thread.java:662) The org.univ.amemet.services.ldap.ILdapComposanteDaoImpl.getUFRs(ILdapComposanteDaoImpl.java:211) show me that the bean* ldapTemplate is null.* Any help will be appreciate. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-ldap-tp4662097.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket integration with Spring
With the 2nd approach you couple the application (in the role as service mother) to all your calling components. Coupling is a bad idea. It's hard to test in separation and almost always you end in a hell of small single methods. But if you inject your beans into the target component you can define your required dependeny there were you use them. Another cool approach in wicket is the event system in 1.5+. So you throw events in child components and provide the services in high ranking components (page, app ...) Just my 2 ct. Per Am 27.12.2012 11:11, schrieb Arun Chauhan: I am making an application in which I want to integrate Wicket + Spring. Application is a grocery store on which user comes and buy something. I know there are two ways to do this. 1. Using the *annotation *aprroach. Wicket-Spring integration shows various ways on how to inject Spring Beans into Wicket pages. public class FormPage extends WebPage { @SpringBean private IContact icontact; ... Form form = new Form("contactForm", new CompoundPropertyModel(contact)) { private static final long serialVersionUID = 1L; protected void onSubmit(Contact contact) { icontact.saveContact(contact); } }; 2. The @SpringBean is of course valid and considered a best practice by many. But there is also *another approach*, where your Wicket Application has the services you need. public class YourWicketApp extends WebApplication{ public static YourWicketApp get(){ return (YourWicketApp) Application.get(); } private ServiceA serviceA; // getter and setter for serviceA here } Now in your component, call YourWicketApp.get().getServiceA(); I want to know which is the best way to integrate spring with wicket. /However as far as I remember Wicket pages and components aren't managed by Spring container so you cannot use @Transactional annotation on them (which is a bad idea anyway - transactions belong to deeper levels)./ *Is this statement valid?* -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-tp4655077.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket integration with Spring
Hi, There is also https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/wicketstuff-springreference-parent / https://github.com/wicketstuff/core/wiki/SpringReference On Thu, Dec 27, 2012 at 12:11 PM, Arun Chauhan wrote: > I am making an application in which I want to integrate Wicket + Spring. > Application is a grocery store on which user comes and buy something. I > know > there are two ways to do this. > > 1. Using the *annotation *aprroach. Wicket-Spring integration shows various > ways on how to inject Spring Beans into Wicket pages. > > public class FormPage extends WebPage > { > @SpringBean > private IContact icontact; > ... > Form form = new Form("contactForm", > new CompoundPropertyModel(contact)) > { > private static final long serialVersionUID = 1L; > > protected void onSubmit(Contact contact) > { > icontact.saveContact(contact); > } > }; > > > 2. The @SpringBean is of course valid and considered a best practice by > many. But there is also *another approach*, where your Wicket Application > has the services you need. > > public class YourWicketApp extends WebApplication{ > public static YourWicketApp get(){ > return (YourWicketApp) Application.get(); > } > private ServiceA serviceA; > // getter and setter for serviceA here > } > > Now in your component, call > > YourWicketApp.get().getServiceA(); > > > > I want to know which is the best way to integrate spring with wicket. > I prefer @SpringBean because with approach 2) you tie every component with this specific implementation of WebApplication. So you cannot reuse this component in another application, and your WicketTester tests will need to setup the whole application to be able to run. With approach 1) you need just to make ServiceA available for the test of a given component. > > > /However as far as I remember Wicket pages and components aren't managed by > Spring container so you cannot use @Transactional annotation on them (which > is a bad idea anyway - transactions belong to deeper levels)./ *Is this > statement valid?* > Yes. Better create a Spring bean that cares about the transactions. Something like: WicketComponent uses ServiceBean delegatesTo RepositoryBean > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-tp4655077.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > 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 <http://jweekend.com/>
Wicket integration with Spring
I am making an application in which I want to integrate Wicket + Spring. Application is a grocery store on which user comes and buy something. I know there are two ways to do this. 1. Using the *annotation *aprroach. Wicket-Spring integration shows various ways on how to inject Spring Beans into Wicket pages. public class FormPage extends WebPage { @SpringBean private IContact icontact; ... Form form = new Form("contactForm", new CompoundPropertyModel(contact)) { private static final long serialVersionUID = 1L; protected void onSubmit(Contact contact) { icontact.saveContact(contact); } }; 2. The @SpringBean is of course valid and considered a best practice by many. But there is also *another approach*, where your Wicket Application has the services you need. public class YourWicketApp extends WebApplication{ public static YourWicketApp get(){ return (YourWicketApp) Application.get(); } private ServiceA serviceA; // getter and setter for serviceA here } Now in your component, call YourWicketApp.get().getServiceA(); I want to know which is the best way to integrate spring with wicket. /However as far as I remember Wicket pages and components aren't managed by Spring container so you cannot use @Transactional annotation on them (which is a bad idea anyway - transactions belong to deeper levels)./ *Is this statement valid?* -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-tp4655077.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org