Thanks all for the responses. I have one more question though. I am working
with the wicket framework and i know it already has an internal guice
servlet module defined somewhere. (wicket-guice sub project) . I would like
to inject the Persist Filter . Is it possible to have more than one servlet
module so that i can later create my inject using something like
Guice.createInjector(new ServletModule1(), new ServletModule2, new
PersistenceModule()) e.t.c ..

Kind regards.

On Sat, Nov 13, 2010 at 4:32 AM, Stuart McCulloch <[email protected]> wrote:

> On 13 November 2010 10:29, Stuart McCulloch <[email protected]> wrote:
>
>> On 12 November 2010 09:30, Josh Kamau <[email protected]> wrote:
>>
>>> Hi there;
>>>
>>> Has anyone tried working with the wicket 1.5-m3 and the new guice/guice
>>> persist 3 snapshots?
>>>
>>> am getting the below error:
>>>
>>
>> Hi Josh,
>>
>> This stack suggests that Jetty is trying to create the Guice
>> PersistFilter, which will fail because it's expecting to be created and
>> injected by Guice (PersistFilter has no default constructor).
>>
>> You need to use the latest Guice servlet extension:
>>
>>   http://code.google.com/p/google-guice/wiki/Servlets
>>
>> which will automatically inject any filters and servlets that need
>> injection (as long as you setup the top-level filter and add a servlet
>> context listener to create the injector).
>>
>
> there's a short servlet + persist example at the end of the Guice JPA wiki
> page:
>
>    http://code.google.com/p/google-guice/wiki/JPA
>
> adding the PersistFilter via the servlet module (instead of in web.xml)
> enables the injection
>
>
>> --
>> Cheers, Stuart
>>
>>
>>> java.lang.
>>> InstantiationException: com.google.inject.persist.PersistFilter
>>>     at java.lang.Class.newInstance0(Class.java:340)
>>>     at java.lang.Class.newInstance(Class.java:308)
>>>     at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
>>>     at
>>> org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:92)
>>>     at
>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>>>     at
>>> org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
>>>     at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
>>>     at
>>> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
>>>     at
>>> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
>>>     at
>>> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
>>>     at
>>> org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
>>>     at
>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>>>     at
>>> org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
>>>     at
>>> org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
>>>     at
>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>>>     at
>>> org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
>>>     at
>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>>>     at
>>> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
>>>     at org.mortbay.jetty.Server.doStart(Server.java:224)
>>>     at
>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>>>     at
>>> org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
>>>     at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
>>>     at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
>>>     at
>>> org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
>>>     at
>>> org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
>>>     at
>>> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>>>     at
>>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>>>     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>>>     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>>>     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>>>     at
>>> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>     at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>     at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>>     at
>>> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>>>     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>>>     at
>>> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>>>     at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>>>
>>> Web.xml
>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>> <web-app xmlns="http://java.sun.com/xml/ns/j2ee";
>>>      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
>>>      version="2.4">
>>>
>>>     <display-name>issuetracker</display-name>
>>>
>>>     <filter>
>>>         <filter-name>wicket.issuetracker</filter-name>
>>>
>>> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>>>         <init-param>
>>>             <param-name>applicationClassName</param-name>
>>>
>>> <param-value>ke.co.at.issuetracker.WicketApplication</param-value>
>>>          </init-param>
>>>      </filter>
>>>
>>>      <filter>
>>>         <filter-name>persistFilter</filter-name>
>>>
>>> <filter-class>com.google.inject.persist.PersistFilter</filter-class>
>>>     </filter>
>>>
>>>  <filter-mapping>
>>>   <filter-name>wicket.issuetracker</filter-name>
>>>     <url-pattern>/*</url-pattern>
>>>  </filter-mapping>
>>>
>>>       <filter-mapping>
>>>         <filter-name>persistFilter</filter-name>
>>>         <url-pattern>/*</url-pattern>
>>>     </filter-mapping>
>>>
>>>
>>> </web-app>
>>>
>>> peristence.xml
>>>
>>> <persistence xmlns="http://java.sun.com/xml/ns/persistence";
>>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";
>>>     version="1.0">
>>>     <persistence-unit name="issuetrackerPU"
>>>         transaction-type="RESOURCE_LOCAL">
>>>         <properties>
>>>             <property name="hibernate.dialect"
>>>                 value="org.hibernate.dialect.PostgreSQLDialect" />
>>>             <property name="hibernate.connection.driver_class"
>>>                 value="org.postgresql.Driver" />
>>>             <property name="hibernate.connection.username"
>>> value="postgres" />
>>>             <property name="hibernate.connection.password"
>>> value="postgres" />
>>>             <property name="hibernate.connection.url"
>>>                 value="jdbc:postgresql://localhost:5432/issuetracker" />
>>>             <property name="hibernate.hbm2ddl.auto" value="update" />
>>>         </properties>
>>>     </persistence-unit>
>>>
>>>     <persistence-unit name="issuetrackerPUtest"
>>>         transaction-type="RESOURCE_LOCAL">
>>>         <properties>
>>>             <property name="hibernate.dialect"
>>>                 value="org.hibernate.dialect.HSQLDialect" />
>>>             <property name="hibernate.connection.driver_class"
>>>                 value="org.hsqldb.jdbcDriver" />
>>>             <property name="hibernate.connection.username" value="sa" />
>>>             <property name="hibernate.connection.password" value="" />
>>>             <property name="hibernate.connection.url"
>>>                 value="jdbc:hsqldb:mem:issuetracker" />
>>>             <property name="hibernate.hbm2ddl.auto" value="update" />
>>>         </properties>
>>>     </persistence-unit>
>>>
>>> </persistence>
>>>
>>>
>>> Guice Module
>>>
>>> package ke.co.at.issuetracker;
>>>
>>> import ke.co.at.issuetracker.services.LoginService;
>>> import ke.co.at.issuetracker.services.impl.LoginServiceImpl;
>>>
>>> import com.google.inject.AbstractModule;
>>>
>>> public class GuiceModule extends AbstractModule {
>>>
>>>     @Override
>>>     protected void configure() {
>>>         bind(LoginService.class).to(LoginServiceImpl.class);
>>>     }
>>>
>>> }
>>>
>>> Wicket application
>>>
>>> package ke.co.at.issuetracker;
>>>
>>> import ke.co.at.issuetracker.pages.AdminUserPage;
>>> import ke.co.at.issuetracker.pages.LoginPage;
>>>
>>> import org.apache.wicket.guice.GuiceComponentInjector;
>>> import org.apache.wicket.protocol.http.WebApplication;
>>>
>>> import com.google.inject.Guice;
>>> import com.google.inject.Injector;
>>> import com.google.inject.persist.jpa.JpaPersistModule;
>>>
>>> /**
>>>  * Application object for your web application. If you want to run this
>>>  * application without deploying, run the Start class.
>>>  *
>>>  * @see ke.co.at.issuetracker.Start#main(String[])
>>>  */
>>> public class WicketApplication extends WebApplication {
>>>     /**
>>>      * Constructor
>>>      */
>>>     public WicketApplication() {
>>>     }
>>>
>>>     /**
>>>      * @see org.apache.wicket.Application#getHomePage()
>>>      */
>>>     public Class<LoginPage> getHomePage() {
>>>         return LoginPage.class;
>>>     }
>>>
>>>     @Override
>>>     protected void init() {
>>>         super.init();
>>>         Injector injector = Guice.createInjector(new GuiceModule(), new
>>> JpaPersistModule("issuetrackerPU"));
>>>         getComponentInstantiationListeners().add(new
>>> GuiceComponentInjector(this, injector));
>>>
>>>         getMarkupSettings().setStripWicketTags(true);
>>>
>>>         mountPage("/login", LoginPage.class);
>>>         mountPage("/registeradmin", AdminUserPage.class);
>>>     }
>>>
>>> }
>>>
>>> kind regards.
>>> Josh
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "google-guice" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-guice%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-guice?hl=en.
>>>
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to