Quantcast

Simple CDI example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Simple CDI example

Jim Muir
Hi,

I'm trying to get a basic POJO CDI injection example to work. I'm following
the steps here (http://openejb.apache.org/tomcat-cdi.html) -  I have a POJO
which I'm trying to inject into a simple servlet using @Inject. I have a
META-INF/beans.xml with just "<beans/>" as per the example.

Under both tomee WebProfile and Plus, I see the following exception:

SEVERE: Error in safeBind method
javax.naming.NameNotFoundException: Name [openejb] is not bound in this
Context. Unable to find [openejb].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at
org.apache.tomee.catalina.TomcatWebAppBuilder.safeBind(TomcatWebAppBuilder.java:1196)
    at
org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:776)
    at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:103)
    at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
...

Obviously I'm missing something - any help would be greatly appreciated!

Many thanks,
Jim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Simple CDI example

Romain Manni-Bucau
Hi,

For war beans.xml should be in web-inf, can you give it a try please?

- Romain
Le 27 mai 2012 18:59, "Jim Muir" <[hidden email]> a écrit :

> Hi,
>
> I'm trying to get a basic POJO CDI injection example to work. I'm following
> the steps here (http://openejb.apache.org/tomcat-cdi.html) -  I have a
> POJO
> which I'm trying to inject into a simple servlet using @Inject. I have a
> META-INF/beans.xml with just "<beans/>" as per the example.
>
> Under both tomee WebProfile and Plus, I see the following exception:
>
> SEVERE: Error in safeBind method
> javax.naming.NameNotFoundException: Name [openejb] is not bound in this
> Context. Unable to find [openejb].
>    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>    at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.safeBind(TomcatWebAppBuilder.java:1196)
>    at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:776)
>    at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:103)
>    at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> ...
>
> Obviously I'm missing something - any help would be greatly appreciated!
>
> Many thanks,
> Jim
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Simple CDI example

Jim Muir
Perfect, that works - thanks so much!

Jim

On Sun, May 27, 2012 at 1:18 PM, Romain Manni-Bucau
<[hidden email]>wrote:

> Hi,
>
> For war beans.xml should be in web-inf, can you give it a try please?
>
> - Romain
> Le 27 mai 2012 18:59, "Jim Muir" <[hidden email]> a écrit :
>
> > Hi,
> >
> > I'm trying to get a basic POJO CDI injection example to work. I'm
> following
> > the steps here (http://openejb.apache.org/tomcat-cdi.html) -  I have a
> > POJO
> > which I'm trying to inject into a simple servlet using @Inject. I have a
> > META-INF/beans.xml with just "<beans/>" as per the example.
> >
> > Under both tomee WebProfile and Plus, I see the following exception:
> >
> > SEVERE: Error in safeBind method
> > javax.naming.NameNotFoundException: Name [openejb] is not bound in this
> > Context. Unable to find [openejb].
> >    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> >    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >    at
> >
> >
> org.apache.tomee.catalina.TomcatWebAppBuilder.safeBind(TomcatWebAppBuilder.java:1196)
> >    at
> >
> >
> org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:776)
> >    at
> >
> >
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:103)
> >    at
> >
> >
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> > ...
> >
> > Obviously I'm missing something - any help would be greatly appreciated!
> >
> > Many thanks,
> > Jim
> >
>
Loading...