Guice is not injecting my TypeConverter

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Guice is not injecting my TypeConverter

Dan Kaplan-2
I'm using this library: http://bgoodin.github.com/stripes-guice/howto.html

I've set it up somewhat correctly because my action beans seem to be injected with my DAOs.  But I have a TypeConverter  and I tried to @Inject it and it gets a null pointer exception when it uses the DAO.  Is this a known limitation?  

--
Thanks,
Dan

CONFIDENTIALITY NOTICE: The information contained in this electronic transmission may be confidential. If you are not an intended recipient, be aware that any disclosure, copying, distribution or use of the information contained in this transmission is prohibited and may be unlawful. If you have received this transmission in error, please notify us by email reply and then erase it from your computer system.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Guice is not injecting my TypeConverter

nmaves
This is a know limitation of the current framework.

Nathan

On Mon, Feb 25, 2013 at 10:30 AM, Dan Kaplan <[hidden email]> wrote:

> I'm using this library: http://bgoodin.github.com/stripes-guice/howto.html
>
> I've set it up somewhat correctly because my action beans seem to be
> injected with my DAOs.  But I have a TypeConverter  and I tried to @Inject
> it and it gets a null pointer exception when it uses the DAO.  Is this a
> known limitation?
>
> --
> Thanks,
> Dan
>
> CONFIDENTIALITY NOTICE: The information contained in this electronic
> transmission may be confidential. If you are not an intended recipient, be
> aware that any disclosure, copying, distribution or use of the information
> contained in this transmission is prohibited and may be unlawful. If you
> have received this transmission in error, please notify us by email reply
> and then erase it from your computer system.
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Guice is not injecting my TypeConverter

Dan Kaplan-2
OK, thanks for the info. Any workarounds?  Here's what I did:

    public DeployTypeConverter() {
        deployDao = new CustomInjectorFactory().getInjector(null).getInstance(DeployDao.class); //Stripes limitation: Guice doesn't manage the TypeConverters so I need to manually inject code
    }

That CustomInjectorFactory is described in on the Guice-stripes page.  Here's my implementation of it:

public class CustomInjectorFactory implements GuiceInjectorFactory {

    /**
     * I've made this static so that every class that refers to this directly gets the same injector instance.
     * Without this, I'd be worried that there could be two @Singletons in existence  
     */
    private final static Injector injector = Guice.createInjector(new DeployManagerModule());

    @Override
    public Injector getInjector(ServletContext servletContext) {
        return injector;
    }
}


On Sun, Mar 3, 2013 at 7:10 PM, Nathan Maves <[hidden email]> wrote:
This is a know limitation of the current framework.

Nathan

On Mon, Feb 25, 2013 at 10:30 AM, Dan Kaplan <[hidden email]> wrote:
> I'm using this library: http://bgoodin.github.com/stripes-guice/howto.html
>
> I've set it up somewhat correctly because my action beans seem to be
> injected with my DAOs.  But I have a TypeConverter  and I tried to @Inject
> it and it gets a null pointer exception when it uses the DAO.  Is this a
> known limitation?
>
> --
> Thanks,
> Dan
>
> CONFIDENTIALITY NOTICE: The information contained in this electronic
> transmission may be confidential. If you are not an intended recipient, be
> aware that any disclosure, copying, distribution or use of the information
> contained in this transmission is prohibited and may be unlawful. If you
> have received this transmission in error, please notify us by email reply
> and then erase it from your computer system.
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Thanks,
Dan

CONFIDENTIALITY NOTICE: The information contained in this electronic transmission may be confidential. If you are not an intended recipient, be aware that any disclosure, copying, distribution or use of the information contained in this transmission is prohibited and may be unlawful. If you have received this transmission in error, please notify us by email reply and then erase it from your computer system.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Guice is not injecting my TypeConverter

nmaves
Per Brandon,

I have deployed version 3.1 of stripes-guice. I have also updated the
documentation at http://bgoodin.github.com/stripes-guice/howto.html.
Version 3.1 should be available on maven by tomorrow morning.

I added an extension package and a GuiceTypeConverterFactory. If you
specify the extension directory it should add the support
automagically.

The important part to notice is the following little nugget to add to
your Stripes filter config:

<filter>
    <display-name>Stripes Filter</display-name>
    <filter-name>StripesFilter</filter-name>
    <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
...
    <init-param>
        <param-name>Extension.Packages</param-name>
        <param-value>com.silvermindsoftware.sg.extension</param-value>
    </init-param>
...
</filter>

After you add that you should be able to simply annotate your
TypeConverter with an @Inject on the constructor and have it work.

Brandon

On Mon, Mar 4, 2013 at 10:51 AM, Dan Kaplan <[hidden email]> wrote:

> OK, thanks for the info. Any workarounds?  Here's what I did:
>
>     public DeployTypeConverter() {
>         deployDao = new
> CustomInjectorFactory().getInjector(null).getInstance(DeployDao.class);
> //Stripes limitation: Guice doesn't manage the TypeConverters so I need to
> manually inject code
>     }
>
> That CustomInjectorFactory is described in on the Guice-stripes page.
> Here's my implementation of it:
>
> public class CustomInjectorFactory implements GuiceInjectorFactory {
>
>     /**
>      * I've made this static so that every class that refers to this
> directly gets the same injector instance.
>      * Without this, I'd be worried that there could be two @Singletons in
> existence
>      */
>     private final static Injector injector = Guice.createInjector(new
> DeployManagerModule());
>
>     @Override
>     public Injector getInjector(ServletContext servletContext) {
>         return injector;
>     }
> }
>
>
> On Sun, Mar 3, 2013 at 7:10 PM, Nathan Maves <[hidden email]> wrote:
>>
>> This is a know limitation of the current framework.
>>
>> Nathan
>>
>> On Mon, Feb 25, 2013 at 10:30 AM, Dan Kaplan <[hidden email]> wrote:
>> > I'm using this library:
>> > http://bgoodin.github.com/stripes-guice/howto.html
>> >
>> > I've set it up somewhat correctly because my action beans seem to be
>> > injected with my DAOs.  But I have a TypeConverter  and I tried to
>> > @Inject
>> > it and it gets a null pointer exception when it uses the DAO.  Is this a
>> > known limitation?
>> >
>> > --
>> > Thanks,
>> > Dan
>> >
>> > CONFIDENTIALITY NOTICE: The information contained in this electronic
>> > transmission may be confidential. If you are not an intended recipient,
>> > be
>> > aware that any disclosure, copying, distribution or use of the
>> > information
>> > contained in this transmission is prohibited and may be unlawful. If you
>> > have received this transmission in error, please notify us by email
>> > reply
>> > and then erase it from your computer system.
>> >
>> > ------------------------------------------------------------------------------
>> > Everyone hates slow websites. So do we.
>> > Make your web apps faster with AppDynamics
>> > Download AppDynamics Lite for free today:
>> > http://p.sf.net/sfu/appdyn_d2d_feb
>> > _______________________________________________
>> > Stripes-users mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Stripes-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
>
> --
> Thanks,
> Dan
>
> CONFIDENTIALITY NOTICE: The information contained in this electronic
> transmission may be confidential. If you are not an intended recipient, be
> aware that any disclosure, copying, distribution or use of the information
> contained in this transmission is prohibited and may be unlawful. If you
> have received this transmission in error, please notify us by email reply
> and then erase it from your computer system.
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Guice is not injecting my TypeConverter

Dan Kaplan-2
Thanks, that worked great


On Mon, Mar 4, 2013 at 8:03 PM, Nathan Maves <[hidden email]> wrote:
Per Brandon,

I have deployed version 3.1 of stripes-guice. I have also updated the
documentation at http://bgoodin.github.com/stripes-guice/howto.html.
Version 3.1 should be available on maven by tomorrow morning.

I added an extension package and a GuiceTypeConverterFactory. If you
specify the extension directory it should add the support
automagically.

The important part to notice is the following little nugget to add to
your Stripes filter config:

<filter>
    <display-name>Stripes Filter</display-name>
    <filter-name>StripesFilter</filter-name>
    <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
...
    <init-param>
        <param-name>Extension.Packages</param-name>
        <param-value>com.silvermindsoftware.sg.extension</param-value>
    </init-param>
...
</filter>

After you add that you should be able to simply annotate your
TypeConverter with an @Inject on the constructor and have it work.

Brandon

On Mon, Mar 4, 2013 at 10:51 AM, Dan Kaplan <[hidden email]> wrote:
> OK, thanks for the info. Any workarounds?  Here's what I did:
>
>     public DeployTypeConverter() {
>         deployDao = new
> CustomInjectorFactory().getInjector(null).getInstance(DeployDao.class);
> //Stripes limitation: Guice doesn't manage the TypeConverters so I need to
> manually inject code
>     }
>
> That CustomInjectorFactory is described in on the Guice-stripes page.
> Here's my implementation of it:
>
> public class CustomInjectorFactory implements GuiceInjectorFactory {
>
>     /**
>      * I've made this static so that every class that refers to this
> directly gets the same injector instance.
>      * Without this, I'd be worried that there could be two @Singletons in
> existence
>      */
>     private final static Injector injector = Guice.createInjector(new
> DeployManagerModule());
>
>     @Override
>     public Injector getInjector(ServletContext servletContext) {
>         return injector;
>     }
> }
>
>
> On Sun, Mar 3, 2013 at 7:10 PM, Nathan Maves <[hidden email]> wrote:
>>
>> This is a know limitation of the current framework.
>>
>> Nathan
>>
>> On Mon, Feb 25, 2013 at 10:30 AM, Dan Kaplan <[hidden email]> wrote:
>> > I'm using this library:
>> > http://bgoodin.github.com/stripes-guice/howto.html
>> >
>> > I've set it up somewhat correctly because my action beans seem to be
>> > injected with my DAOs.  But I have a TypeConverter  and I tried to
>> > @Inject
>> > it and it gets a null pointer exception when it uses the DAO.  Is this a
>> > known limitation?
>> >
>> > --
>> > Thanks,
>> > Dan
>> >
>> > CONFIDENTIALITY NOTICE: The information contained in this electronic
>> > transmission may be confidential. If you are not an intended recipient,
>> > be
>> > aware that any disclosure, copying, distribution or use of the
>> > information
>> > contained in this transmission is prohibited and may be unlawful. If you
>> > have received this transmission in error, please notify us by email
>> > reply
>> > and then erase it from your computer system.
>> >
>> > ------------------------------------------------------------------------------
>> > Everyone hates slow websites. So do we.
>> > Make your web apps faster with AppDynamics
>> > Download AppDynamics Lite for free today:
>> > http://p.sf.net/sfu/appdyn_d2d_feb
>> > _______________________________________________
>> > Stripes-users mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Stripes-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
>
> --
> Thanks,
> Dan
>
> CONFIDENTIALITY NOTICE: The information contained in this electronic
> transmission may be confidential. If you are not an intended recipient, be
> aware that any disclosure, copying, distribution or use of the information
> contained in this transmission is prohibited and may be unlawful. If you
> have received this transmission in error, please notify us by email reply
> and then erase it from your computer system.
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Thanks,
Dan

CONFIDENTIALITY NOTICE: The information contained in this electronic transmission may be confidential. If you are not an intended recipient, be aware that any disclosure, copying, distribution or use of the information contained in this transmission is prohibited and may be unlawful. If you have received this transmission in error, please notify us by email reply and then erase it from your computer system.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users