You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Deven Phillips <de...@gmail.com> on 2014/11/17 04:27:10 UTC

Jetty/Jersey/Injection

Hi all,


    I'm trying really hard to figure out how to make DeltaSpike/Weld work
with Jetty and Jersey... I can get the Jersey servlet to load, but I cannot
get any of the dependencies to be injected... My goal is to replace
Google's Guice DI framework so that I can achieve better test coverage and
decoupling... I'm having a very hard time finding any documentation for
wiring this up..

Any help would be appreciated!

Deven

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
John,

    That is AWESOME.. I'll have a look after my morning meetings and give
it a shot...

Thanks much!!

Deven

On Mon, Nov 24, 2014 at 6:39 PM, John D. Ament <jo...@apache.org>
wrote:

> Haha! Looks to be a gradle issue actually, or at least the way gradle
> builds a classpath when trying to run an application.
>
> After digging through this a bit more, I noticed that I wasn't seeing
> any bean definitions for your classes.  I wasn't seeing the cdi
> injector being fired.  Note the following classpath entries:
>
>
> /Users/johnament/src/JettyJerseyWeldExample/build/classes/main:/Users/johnament/src/JettyJerseyWeldExample/build/resources/main
>
> Weld will interpret these as two different JARs - one that has a
> beans.xml and one that doesn't.
>
> I added the following to your build.gradle:
>
>
> sourceSets {
>     main {
>         //if you truly want to override the defaults:
>         output.resourcesDir = 'build/out'
>         output.classesDir   = 'build/out'
>     }
> }
>
>
> and finally when I ran, I got this log message:
>
> [DEBUG] 2014-11-24 18:35:28,552 [main]
> org.jboss.resteasy.cdi.ResteasyCdiExtension:68 - Discovered CDI bean
> which is a JAX-RS resource com.zanclus.example.api.GetServerTime.
>
> [DEBUG] 2014-11-24 18:35:28,552 [main]
> org.jboss.resteasy.cdi.ResteasyCdiExtension:68 - Bean class
> com.zanclus.example.api.GetServerTime has a scope defined.
>
> which made me smile (always glad to see my old code floating around).
> Now you can inject your rest dependencies.
>
> I've put out a gist with the final build.gradle that made this work:
>
> https://gist.github.com/johnament/444d430afff078de0cc6
>
> On Mon, Nov 24, 2014 at 1:11 PM, John D. Ament <jo...@gmail.com>
> wrote:
> > I think I figured out the "how to run" part.  I added an application
> > plugin to the build.gradle and it starts.
> >
> > It looks like your issue is much more of a resteasy problem rather
> > than a CDI problem.  Let me poke at it more, however you may want to
> > mail resteasy-users as well (I'm also on that list).
> >
> > John
> >
> > On Mon, Nov 24, 2014 at 10:38 AM, Deven Phillips
> > <de...@gmail.com> wrote:
> >> John,
> >>
> >>     I have been running it from either NetBeans or IntelliJ using their
> >> gradle plugins... You could potentially run from the CLI using a
> JavaExec
> >> task inside of Gradle. I will try to add one to the project today and
> get
> >> back with you on how to run it..
> >>
> >> Thanks,
> >>
> >> Deven
> >>
> >> On Sat, Nov 22, 2014 at 10:11 AM, John D. Ament <john.d.ament@gmail.com
> >
> >> wrote:
> >>
> >>> It's a bit hard to compile your code since you're using lombok and
> gradle,
> >>> any build instructions you might want to share?  How do I create a
> runnable
> >>> app with this?
> >>>
> >>> Looking at what you're building against, I wouldn't recommend including
> >>> both weld-se and weld-servlet in your bundle.
> >>> On Sat Nov 22 2014 at 6:19:28 AM Deven Phillips <
> deven.phillips@gmail.com>
> >>> wrote:
> >>>
> >>> > To answer:
> >>> >
> >>> > 1. JavaEE application servers are not on our approved software list
> and I
> >>> > was told that the would not likely be approved in the near future.
> >>> >
> >>> > 2. I don't see how starting with a WAR and using a
> WebApplicationContext
> >>> > would make any difference in whether injections work... Regardless,
> it
> >>> > would mean having to separate the application and the server again
> >>> (Create
> >>> > the WAR, deploy to Jetty) and we are trying to avoid that.
> >>> >
> >>> > Thanks in advance,
> >>> >
> >>> > Deven
> >>> >
> >>> > On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <
> lightguard.jp@gmail.com>
> >>> > wrote:
> >>> >
> >>> > > I have to say I'm not familiar at all with using Jetty this way. Is
> >>> > there a
> >>> > > reason for doing this instead of 1) starting the server and
> deploying a
> >>> > WAR
> >>> > > or 2) using a WebAppContext?
> >>> > >
> >>> > > On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <
> >>> > deven.phillips@gmail.com
> >>> > > >
> >>> > > wrote:
> >>> > >
> >>> > > > OK, I think that I have a project which can run, but I am still
> >>> getting
> >>> > > > NPEs for the injected resource.
> >>> > > >
> >>> > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> >>> > > deven.phillips@gmail.com>
> >>> > > > wrote:
> >>> > > >
> >>> > > > > And by working, I mean it compiles.. I do not mean that the
> >>> > Dependency
> >>> > > > > Injection is working.
> >>> > > > >
> >>> > > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> >>> > > > deven.phillips@gmail.com>
> >>> > > > > wrote:
> >>> > > > >
> >>> > > > >> OK, I created a branch called DeltaSpike which is now
> working...
> >>> > Sorry
> >>> > > > >> for wasting your time with a broken source tree!!
> >>> > > > >>
> >>> > > > >> Deven
> >>> > > > >>
> >>> > > > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
> >>> > > > deven.phillips@gmail.com
> >>> > > > >> > wrote:
> >>> > > > >>
> >>> > > > >>> I've never needed an "Application" class before while using
> Guice
> >>> > or
> >>> > > > >>> manually configuring JAX-RS with Jetty.. I will check to see
> if
> >>> > that
> >>> > > > makes
> >>> > > > >>> a difference...
> >>> > > > >>>
> >>> > > > >>> Deven
> >>> > > > >>>
> >>> > > > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
> >>> > > lightguard.jp@gmail.com
> >>> > > > >
> >>> > > > >>> wrote:
> >>> > > > >>>
> >>> > > > >>>> Maybe I missed something, but why are you going through all
> the
> >>> > > > trouble
> >>> > > > >>>> of
> >>> > > > >>>> starting the server and setting everything up manually? I
> still
> >>> > > don't
> >>> > > > >>>> see
> >>> > > > >>>> any JAX-RS config or JAX-RS Application class.
> >>> > > > >>>>
> >>> > > > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
> >>> > > > >>>> deven.phillips@gmail.com>
> >>> > > > >>>> wrote:
> >>> > > > >>>>
> >>> > > > >>>> > I see what happened... I meant to create a separate branch
> >>> for a
> >>> > > > >>>> WeldSE
> >>> > > > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
> >>> > > > >>>> >
> >>> > > > >>>> > Deven
> >>> > > > >>>> >
> >>> > > > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> >>> > > > >>>> deven.phillips@gmail.com>
> >>> > > > >>>> > wrote:
> >>> > > > >>>> >
> >>> > > > >>>> > > John,
> >>> > > > >>>> > >
> >>> > > > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
> >>> > > > >>>> > >
> >>> > > > >>>> > > Deven
> >>> > > > >>>> > >
> >>> > > > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> >>> > > > >>>> john.d.ament@gmail.com>
> >>> > > > >>>> > > wrote:
> >>> > > > >>>> > >
> >>> > > > >>>> > >> Deven,
> >>> > > > >>>> > >>
> >>> > > > >>>> > >> Looks like there's no JAX-RS resources in this
> project...
> >>> > > > >>>> > >>
> >>> > > > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> >>> > > > >>>> > >> deven.phillips@gmail.com>
> >>> > > > >>>> > >> wrote:
> >>> > > > >>>> > >>
> >>> > > > >>>> > >> > I finally got around to trying to put together an
> example
> >>> > > > project
> >>> > > > >>>> > which
> >>> > > > >>>> > >> I
> >>> > > > >>>> > >> > could share publicly...
> >>> > > > >>>> > >> >
> >>> > > > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> >>> > > > >>>> > >> >
> >>> > > > >>>> > >> > I'm hoping I can figure out how to get
> DeltaSpike/Weld to
> >>> > > work
> >>> > > > >>>> > injecting
> >>> > > > >>>> > >> > dependencies into my JAX-RS POJOs...
> >>> > > > >>>> > >> >
> >>> > > > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> >>> > > > >>>> > >> deven.phillips@gmail.com>
> >>> > > > >>>> > >> > wrote:
> >>> > > > >>>> > >> >
> >>> > > > >>>> > >> > > Creating the ServletContextHandler now looks like:
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > >         ServletContextHandler handler = new
> >>> > > > >>>> ServletContextHandler();
> >>> > > > >>>> > >> > >         handler.setContextPath("/");
> >>> > > > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class,
> "/*",
> >>> > > > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
> >>> > > > >>>> > >> > >         handler.addEventListener(new
> >>> > > > >>>> BeanManagerResourceBindingList
> >>> > > > >>>> > >> > ener());
> >>> > > > >>>> > >> > >         handler.addEventListener(new
> >>> > > > >>>> CdiServletRequestListener());
> >>> > > > >>>> > >> > >         handler.addServlet(new ServletHolder(new
> >>> > > > >>>> > ServletContainer(new
> >>> > > > >>>> > >> > > PackagesResourceConfig(config.restPackage()))),
> "/*");
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > > And the exception is an NPE in one of my JAX-RS
> POJOs
> >>> > where
> >>> > > > it
> >>> > > > >>>> tries
> >>> > > > >>>> > >> to
> >>> > > > >>>> > >> > > access a supposedly injected resource.
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > > DEven
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> >>> > > > >>>> > >> > deven.phillips@gmail.com>
> >>> > > > >>>> > >> > > wrote:
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> > >> OK, the @Target exception was a classpath problem
> and
> >>> I
> >>> > > have
> >>> > > > >>>> > resolved
> >>> > > > >>>> > >> > it,
> >>> > > > >>>> > >> > >> but I am still getting NullPointerExceptions
> because
> >>> > > nothing
> >>> > > > >>>> is
> >>> > > > >>>> > >> getting
> >>> > > > >>>> > >> > >> injected into my JAX-RS classes...
> >>> > > > >>>> > >> > >>
> >>> > > > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> >>> > > > >>>> > >> > deven.phillips@gmail.com
> >>> > > > >>>> > >> > >> > wrote:
> >>> > > > >>>> > >> > >>
> >>> > > > >>>> > >> > >>> So, I just tried this:
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>>     WebAppContext ctx = new
> >>> > > > >>>> WebAppContext("cc-backend-sungardas",
> >>> > > > >>>> > >> > "/");
> >>> > > > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> >>> > > > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
> >>> > > > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
> >>> > > > ServletContainer(new
> >>> > > > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))),
> >>> "/*");
> >>> > > > >>>> > >> > >>>     ctx.addEventListener(new
> >>> > > > >>>> > BeanManagerResourceBindingListener());
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>> and I got the following Exceptions:
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> >>> > > > >>>> > >> > org.jboss.weld.Reflection:82
> >>> > > > >>>> > >> > >>> - WELD-000620: interface
> javax.ws.rs.core.Context is
> >>> > not
> >>> > > > >>>> declared
> >>> > > > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld
> will
> >>> use
> >>> > > this
> >>> > > > >>>> > >> annotation,
> >>> > > > >>>> > >> > >>> however this may make the application unportable.
> >>> > > > >>>> > >> > >>>     Exception in thread "main"
> >>> > > > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException:
> >>> > Exception
> >>> > > > List
> >>> > > > >>>> > with 1
> >>> > > > >>>> > >> > >>> exceptions:
> >>> > > > >>>> > >> > >>>     Exception 0 :
> >>> > > > >>>> > >> > >>>     javax.enterprise.event.ObserverException
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> >
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >>> > > > >>>> > >> > >>> Method)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> >>> > > > >>>> > >> > NativeConstructorAccessorImpl.java:57)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> >>> > > > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >>
> java.lang.reflect.Constructor.newInstance(Constructor.java:
> >>> > 526)
> >>> > > > >>>> > >> > >>>     at
> java.lang.Class.newInstance(Class.java:379)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> >>> > > > >>>> > >> > NewInstanceAction.java:33)
> >>> > > > >>>> > >> > >>>     at
> java.security.AccessController.doPrivileged(
> >>> > Native
> >>> > > > >>>> Method)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.injection.Exceptions.rethrowException(
> >>> > > > >>>> > >> > Exceptions.java:40)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.injection.Exceptions.rethrowException(
> >>> > > > >>>> > >> > Exceptions.java:78)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >>> > > > >>>> > >> >
> >>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >>> > > > >>>> > >> > ObserverMethodImpl.java:271)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> >>> > > > >>>> > >> > ExtensionObserverMethodImpl.java:121)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >>> > > > >>>> > >> > ObserverMethodImpl.java:258)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> >>> > > > >>>> > >> > ObserverMethodImpl.java:237)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> >>> > > > >>>> > >> > ObserverNotifier.java:174)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> >>> > > > >>>> > >> > ObserverNotifier.java:133)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> >>> > > > >>>> > >> > ObserverNotifier.java:107)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> >>> > events.AbstractContainerEvent.
> >>> > > > >>>> > >> > fire(AbstractContainerEvent.java:54)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> >>> > events.AfterBeanDiscoveryImpl.
> >>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >>> > > > >>>> > >> > WeldBootstrap.java:83)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >>> > > > >>>> > >> > ForwardingBootstrap.java:63)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> >
> org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
> >>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> >>> > start(Main.java:171)
> >>> > > > >>>> > >> > >>>     at
> >>> com.sungardas.cc.edison.Main.main(Main.java:68)
> >>> > > > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.context.AbstractUnboundContext.<init>(
> >>> > Z)V
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> >>> > > > >>>> > >> > ThreadContext.java:40)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> >>> > > > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> >>> > > > >>>> > >> > >>>     at
> >>> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> >>> > > > >>>> Method)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> >>> > > > >>>> > >> > NativeMethodAccessorImpl.java:57)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> >>> > > > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
> >>> > > > >>>> > >> > >>>     at java.lang.reflect.Method.
> >>> > invoke(Method.java:606)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >>> > > > >>>> > >> >
> >>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> >>> > > > >>>> > >> > >>>     ... 17 more
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> >>> > events.AfterBeanDiscoveryImpl.
> >>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >>> > > > >>>> > >> > WeldBootstrap.java:83)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >>
> >>> > > > >>>>
> >>> > >
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >>> > > > >>>> > >> > ForwardingBootstrap.java:63)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> >
> org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>> > > > >>>> > >> > >>>     at
> >>> > > > >>>> > >> > >>>
> >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
> >>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> >>> > start(Main.java:171)
> >>> > > > >>>> > >> > >>>     at
> >>> com.sungardas.cc.edison.Main.main(Main.java:68)
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> >>> > > > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
> >>> > > 1.1.9.Final
> >>> > > > >>>> booted
> >>> > > > >>>> > >> using
> >>> > > > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked
> >>> document,
> >>> > > but
> >>> > > > I
> >>> > > > >>>> don't
> >>> > > > >>>> > >> see
> >>> > > > >>>> > >> > how
> >>> > > > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
> >>> > > > Normally, I
> >>> > > > >>>> > would
> >>> > > > >>>> > >> do
> >>> > > > >>>> > >> > >>>> something like:
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>>     ServletContextHandler ctx = new
> >>> > > > >>>> ServletContextHandler("/");
> >>> > > > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> >>> > > > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> >>> > > > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> >>> > > > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
> >>> > > > >>>> > >> > >>>>     ctx.addEventListener(new
> CdiRequestListener())
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>> Where in there would I put in the BeanManager
> and
> >>> the
> >>> > > > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the
> lines
> >>> > below
> >>> > > > >>>> that
> >>> > > > >>>> > where
> >>> > > > >>>> > >> > they
> >>> > > > >>>> > >> > >>>> talk about using a listener to automatically
> bind
> >>> the
> >>> > > > >>>> > BeanManager?
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>> Thanks in advance!!
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>> Deven
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> >>> > > > >>>> > >> > lightguard.jp@gmail.com
> >>> > > > >>>> > >> > >>>> > wrote:
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>>> Which version of weld?
> >>> > > > >>>> > >> > >>>>>
> >>> > > > >>>> > >> > >>>>>
> >>> > > https://docs.jboss.org/weld/reference/latest/en-US/html/
> >>> > > > >>>> > >> > environments.html#_jetty
> >>> > > > >>>> > >> > >>>>> should be all you need for weld in jetty.
> >>> > > > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> >>> > > > >>>> > >> > deven.phillips@gmail.com
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>> wrote:
> >>> > > > >>>> > >> > >>>>>
> >>> > > > >>>> > >> > >>>>> > Hi all,
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>> >     I'm trying really hard to figure out how
> to
> >>> > make
> >>> > > > >>>> > >> > DeltaSpike/Weld
> >>> > > > >>>> > >> > >>>>> work
> >>> > > > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey
> >>> > servlet
> >>> > > > to
> >>> > > > >>>> load,
> >>> > > > >>>> > >> but
> >>> > > > >>>> > >> > I
> >>> > > > >>>> > >> > >>>>> cannot
> >>> > > > >>>> > >> > >>>>> > get any of the dependencies to be
> injected... My
> >>> > goal
> >>> > > > is
> >>> > > > >>>> to
> >>> > > > >>>> > >> replace
> >>> > > > >>>> > >> > >>>>> > Google's Guice DI framework so that I can
> achieve
> >>> > > > better
> >>> > > > >>>> test
> >>> > > > >>>> > >> > >>>>> coverage and
> >>> > > > >>>> > >> > >>>>> > decoupling... I'm having a very hard time
> finding
> >>> > any
> >>> > > > >>>> > >> documentation
> >>> > > > >>>> > >> > >>>>> for
> >>> > > > >>>> > >> > >>>>> > wiring this up..
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>> > Any help would be appreciated!
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>> > Deven
> >>> > > > >>>> > >> > >>>>> >
> >>> > > > >>>> > >> > >>>>>
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>>
> >>> > > > >>>> > >> > >>>
> >>> > > > >>>> > >> > >>
> >>> > > > >>>> > >> > >
> >>> > > > >>>> > >> >
> >>> > > > >>>> > >>
> >>> > > > >>>> > >
> >>> > > > >>>> > >
> >>> > > > >>>> >
> >>> > > > >>>>
> >>> > > > >>>>
> >>> > > > >>>>
> >>> > > > >>>> --
> >>> > > > >>>> Jason Porter
> >>> > > > >>>> http://en.gravatar.com/lightguardjp
> >>> > > > >>>>
> >>> > > > >>>
> >>> > > > >>>
> >>> > > > >>
> >>> > > > >
> >>> > > >
> >>> > >
> >>> > >
> >>> > >
> >>> > > --
> >>> > > Jason Porter
> >>> > > http://en.gravatar.com/lightguardjp
> >>> > >
> >>> >
> >>>
>

Re: Jetty/Jersey/Injection

Posted by "John D. Ament" <jo...@apache.org>.
Haha! Looks to be a gradle issue actually, or at least the way gradle
builds a classpath when trying to run an application.

After digging through this a bit more, I noticed that I wasn't seeing
any bean definitions for your classes.  I wasn't seeing the cdi
injector being fired.  Note the following classpath entries:

/Users/johnament/src/JettyJerseyWeldExample/build/classes/main:/Users/johnament/src/JettyJerseyWeldExample/build/resources/main

Weld will interpret these as two different JARs - one that has a
beans.xml and one that doesn't.

I added the following to your build.gradle:


sourceSets {
    main {
        //if you truly want to override the defaults:
        output.resourcesDir = 'build/out'
        output.classesDir   = 'build/out'
    }
}


and finally when I ran, I got this log message:

[DEBUG] 2014-11-24 18:35:28,552 [main]
org.jboss.resteasy.cdi.ResteasyCdiExtension:68 - Discovered CDI bean
which is a JAX-RS resource com.zanclus.example.api.GetServerTime.

[DEBUG] 2014-11-24 18:35:28,552 [main]
org.jboss.resteasy.cdi.ResteasyCdiExtension:68 - Bean class
com.zanclus.example.api.GetServerTime has a scope defined.

which made me smile (always glad to see my old code floating around).
Now you can inject your rest dependencies.

I've put out a gist with the final build.gradle that made this work:

https://gist.github.com/johnament/444d430afff078de0cc6

On Mon, Nov 24, 2014 at 1:11 PM, John D. Ament <jo...@gmail.com> wrote:
> I think I figured out the "how to run" part.  I added an application
> plugin to the build.gradle and it starts.
>
> It looks like your issue is much more of a resteasy problem rather
> than a CDI problem.  Let me poke at it more, however you may want to
> mail resteasy-users as well (I'm also on that list).
>
> John
>
> On Mon, Nov 24, 2014 at 10:38 AM, Deven Phillips
> <de...@gmail.com> wrote:
>> John,
>>
>>     I have been running it from either NetBeans or IntelliJ using their
>> gradle plugins... You could potentially run from the CLI using a JavaExec
>> task inside of Gradle. I will try to add one to the project today and get
>> back with you on how to run it..
>>
>> Thanks,
>>
>> Deven
>>
>> On Sat, Nov 22, 2014 at 10:11 AM, John D. Ament <jo...@gmail.com>
>> wrote:
>>
>>> It's a bit hard to compile your code since you're using lombok and gradle,
>>> any build instructions you might want to share?  How do I create a runnable
>>> app with this?
>>>
>>> Looking at what you're building against, I wouldn't recommend including
>>> both weld-se and weld-servlet in your bundle.
>>> On Sat Nov 22 2014 at 6:19:28 AM Deven Phillips <de...@gmail.com>
>>> wrote:
>>>
>>> > To answer:
>>> >
>>> > 1. JavaEE application servers are not on our approved software list and I
>>> > was told that the would not likely be approved in the near future.
>>> >
>>> > 2. I don't see how starting with a WAR and using a WebApplicationContext
>>> > would make any difference in whether injections work... Regardless, it
>>> > would mean having to separate the application and the server again
>>> (Create
>>> > the WAR, deploy to Jetty) and we are trying to avoid that.
>>> >
>>> > Thanks in advance,
>>> >
>>> > Deven
>>> >
>>> > On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <li...@gmail.com>
>>> > wrote:
>>> >
>>> > > I have to say I'm not familiar at all with using Jetty this way. Is
>>> > there a
>>> > > reason for doing this instead of 1) starting the server and deploying a
>>> > WAR
>>> > > or 2) using a WebAppContext?
>>> > >
>>> > > On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <
>>> > deven.phillips@gmail.com
>>> > > >
>>> > > wrote:
>>> > >
>>> > > > OK, I think that I have a project which can run, but I am still
>>> getting
>>> > > > NPEs for the injected resource.
>>> > > >
>>> > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
>>> > > deven.phillips@gmail.com>
>>> > > > wrote:
>>> > > >
>>> > > > > And by working, I mean it compiles.. I do not mean that the
>>> > Dependency
>>> > > > > Injection is working.
>>> > > > >
>>> > > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
>>> > > > deven.phillips@gmail.com>
>>> > > > > wrote:
>>> > > > >
>>> > > > >> OK, I created a branch called DeltaSpike which is now working...
>>> > Sorry
>>> > > > >> for wasting your time with a broken source tree!!
>>> > > > >>
>>> > > > >> Deven
>>> > > > >>
>>> > > > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
>>> > > > deven.phillips@gmail.com
>>> > > > >> > wrote:
>>> > > > >>
>>> > > > >>> I've never needed an "Application" class before while using Guice
>>> > or
>>> > > > >>> manually configuring JAX-RS with Jetty.. I will check to see if
>>> > that
>>> > > > makes
>>> > > > >>> a difference...
>>> > > > >>>
>>> > > > >>> Deven
>>> > > > >>>
>>> > > > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
>>> > > lightguard.jp@gmail.com
>>> > > > >
>>> > > > >>> wrote:
>>> > > > >>>
>>> > > > >>>> Maybe I missed something, but why are you going through all the
>>> > > > trouble
>>> > > > >>>> of
>>> > > > >>>> starting the server and setting everything up manually? I still
>>> > > don't
>>> > > > >>>> see
>>> > > > >>>> any JAX-RS config or JAX-RS Application class.
>>> > > > >>>>
>>> > > > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>>> > > > >>>> deven.phillips@gmail.com>
>>> > > > >>>> wrote:
>>> > > > >>>>
>>> > > > >>>> > I see what happened... I meant to create a separate branch
>>> for a
>>> > > > >>>> WeldSE
>>> > > > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
>>> > > > >>>> >
>>> > > > >>>> > Deven
>>> > > > >>>> >
>>> > > > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>>> > > > >>>> deven.phillips@gmail.com>
>>> > > > >>>> > wrote:
>>> > > > >>>> >
>>> > > > >>>> > > John,
>>> > > > >>>> > >
>>> > > > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
>>> > > > >>>> > >
>>> > > > >>>> > > Deven
>>> > > > >>>> > >
>>> > > > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>>> > > > >>>> john.d.ament@gmail.com>
>>> > > > >>>> > > wrote:
>>> > > > >>>> > >
>>> > > > >>>> > >> Deven,
>>> > > > >>>> > >>
>>> > > > >>>> > >> Looks like there's no JAX-RS resources in this project...
>>> > > > >>>> > >>
>>> > > > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>>> > > > >>>> > >> deven.phillips@gmail.com>
>>> > > > >>>> > >> wrote:
>>> > > > >>>> > >>
>>> > > > >>>> > >> > I finally got around to trying to put together an example
>>> > > > project
>>> > > > >>>> > which
>>> > > > >>>> > >> I
>>> > > > >>>> > >> > could share publicly...
>>> > > > >>>> > >> >
>>> > > > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>>> > > > >>>> > >> >
>>> > > > >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to
>>> > > work
>>> > > > >>>> > injecting
>>> > > > >>>> > >> > dependencies into my JAX-RS POJOs...
>>> > > > >>>> > >> >
>>> > > > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>>> > > > >>>> > >> deven.phillips@gmail.com>
>>> > > > >>>> > >> > wrote:
>>> > > > >>>> > >> >
>>> > > > >>>> > >> > > Creating the ServletContextHandler now looks like:
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > >         ServletContextHandler handler = new
>>> > > > >>>> ServletContextHandler();
>>> > > > >>>> > >> > >         handler.setContextPath("/");
>>> > > > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>>> > > > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
>>> > > > >>>> > >> > >         handler.addEventListener(new
>>> > > > >>>> BeanManagerResourceBindingList
>>> > > > >>>> > >> > ener());
>>> > > > >>>> > >> > >         handler.addEventListener(new
>>> > > > >>>> CdiServletRequestListener());
>>> > > > >>>> > >> > >         handler.addServlet(new ServletHolder(new
>>> > > > >>>> > ServletContainer(new
>>> > > > >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs
>>> > where
>>> > > > it
>>> > > > >>>> tries
>>> > > > >>>> > >> to
>>> > > > >>>> > >> > > access a supposedly injected resource.
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > > DEven
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>>> > > > >>>> > >> > deven.phillips@gmail.com>
>>> > > > >>>> > >> > > wrote:
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> > >> OK, the @Target exception was a classpath problem and
>>> I
>>> > > have
>>> > > > >>>> > resolved
>>> > > > >>>> > >> > it,
>>> > > > >>>> > >> > >> but I am still getting NullPointerExceptions because
>>> > > nothing
>>> > > > >>>> is
>>> > > > >>>> > >> getting
>>> > > > >>>> > >> > >> injected into my JAX-RS classes...
>>> > > > >>>> > >> > >>
>>> > > > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>>> > > > >>>> > >> > deven.phillips@gmail.com
>>> > > > >>>> > >> > >> > wrote:
>>> > > > >>>> > >> > >>
>>> > > > >>>> > >> > >>> So, I just tried this:
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>>     WebAppContext ctx = new
>>> > > > >>>> WebAppContext("cc-backend-sungardas",
>>> > > > >>>> > >> > "/");
>>> > > > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>>> > > > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>>> > > > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
>>> > > > ServletContainer(new
>>> > > > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))),
>>> "/*");
>>> > > > >>>> > >> > >>>     ctx.addEventListener(new
>>> > > > >>>> > BeanManagerResourceBindingListener());
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>> and I got the following Exceptions:
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>>> > > > >>>> > >> > org.jboss.weld.Reflection:82
>>> > > > >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is
>>> > not
>>> > > > >>>> declared
>>> > > > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will
>>> use
>>> > > this
>>> > > > >>>> > >> annotation,
>>> > > > >>>> > >> > >>> however this may make the application unportable.
>>> > > > >>>> > >> > >>>     Exception in thread "main"
>>> > > > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException:
>>> > Exception
>>> > > > List
>>> > > > >>>> > with 1
>>> > > > >>>> > >> > >>> exceptions:
>>> > > > >>>> > >> > >>>     Exception 0 :
>>> > > > >>>> > >> > >>>     javax.enterprise.event.ObserverException
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> > > > >>>> > >> > >>> Method)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>>> > > > >>>> > >> > NativeConstructorAccessorImpl.java:57)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>>> > > > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:
>>> > 526)
>>> > > > >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>>> > > > >>>> > >> > NewInstanceAction.java:33)
>>> > > > >>>> > >> > >>>     at java.security.AccessController.doPrivileged(
>>> > Native
>>> > > > >>>> Method)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>> > > > >>>> > >> > Exceptions.java:40)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>> > > > >>>> > >> > Exceptions.java:78)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>> > > > >>>> > >> >
>>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>> > > > >>>> > >> > ObserverMethodImpl.java:271)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>>> > > > >>>> > >> > ExtensionObserverMethodImpl.java:121)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>> > > > >>>> > >> > ObserverMethodImpl.java:258)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>>> > > > >>>> > >> > ObserverMethodImpl.java:237)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>>> > > > >>>> > >> > ObserverNotifier.java:174)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>>> > > > >>>> > >> > ObserverNotifier.java:133)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>>> > > > >>>> > >> > ObserverNotifier.java:107)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>>> > events.AbstractContainerEvent.
>>> > > > >>>> > >> > fire(AbstractContainerEvent.java:54)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>>> > events.AfterBeanDiscoveryImpl.
>>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>> > > > >>>> > >> > WeldBootstrap.java:83)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>> > > > >>>> > >> > ForwardingBootstrap.java:63)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
>>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
>>> > start(Main.java:171)
>>> > > > >>>> > >> > >>>     at
>>> com.sungardas.cc.edison.Main.main(Main.java:68)
>>> > > > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>>> > > > >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(
>>> > Z)V
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>>> > > > >>>> > >> > ThreadContext.java:40)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>>> > > > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>>> > > > >>>> > >> > >>>     at
>>> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>> > > > >>>> Method)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>> > > > >>>> > >> > NativeMethodAccessorImpl.java:57)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>> > > > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
>>> > > > >>>> > >> > >>>     at java.lang.reflect.Method.
>>> > invoke(Method.java:606)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>> > > > >>>> > >> >
>>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>>> > > > >>>> > >> > >>>     ... 17 more
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>>> > events.AfterBeanDiscoveryImpl.
>>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>> > > > >>>> > >> > WeldBootstrap.java:83)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >>
>>> > > > >>>>
>>> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>> > > > >>>> > >> > ForwardingBootstrap.java:63)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>> > > > >>>> > >> > >>>     at
>>> > > > >>>> > >> > >>>
>>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
>>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
>>> > start(Main.java:171)
>>> > > > >>>> > >> > >>>     at
>>> com.sungardas.cc.edison.Main.main(Main.java:68)
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>>> > > > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
>>> > > 1.1.9.Final
>>> > > > >>>> booted
>>> > > > >>>> > >> using
>>> > > > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked
>>> document,
>>> > > but
>>> > > > I
>>> > > > >>>> don't
>>> > > > >>>> > >> see
>>> > > > >>>> > >> > how
>>> > > > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
>>> > > > Normally, I
>>> > > > >>>> > would
>>> > > > >>>> > >> do
>>> > > > >>>> > >> > >>>> something like:
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>>     ServletContextHandler ctx = new
>>> > > > >>>> ServletContextHandler("/");
>>> > > > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>>> > > > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>>> > > > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>>> > > > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
>>> > > > >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>> Where in there would I put in the BeanManager and
>>> the
>>> > > > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines
>>> > below
>>> > > > >>>> that
>>> > > > >>>> > where
>>> > > > >>>> > >> > they
>>> > > > >>>> > >> > >>>> talk about using a listener to automatically bind
>>> the
>>> > > > >>>> > BeanManager?
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>> Thanks in advance!!
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>> Deven
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>>> > > > >>>> > >> > lightguard.jp@gmail.com
>>> > > > >>>> > >> > >>>> > wrote:
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>>> Which version of weld?
>>> > > > >>>> > >> > >>>>>
>>> > > > >>>> > >> > >>>>>
>>> > > https://docs.jboss.org/weld/reference/latest/en-US/html/
>>> > > > >>>> > >> > environments.html#_jetty
>>> > > > >>>> > >> > >>>>> should be all you need for weld in jetty.
>>> > > > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>>> > > > >>>> > >> > deven.phillips@gmail.com
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>> wrote:
>>> > > > >>>> > >> > >>>>>
>>> > > > >>>> > >> > >>>>> > Hi all,
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>> >     I'm trying really hard to figure out how to
>>> > make
>>> > > > >>>> > >> > DeltaSpike/Weld
>>> > > > >>>> > >> > >>>>> work
>>> > > > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey
>>> > servlet
>>> > > > to
>>> > > > >>>> load,
>>> > > > >>>> > >> but
>>> > > > >>>> > >> > I
>>> > > > >>>> > >> > >>>>> cannot
>>> > > > >>>> > >> > >>>>> > get any of the dependencies to be injected... My
>>> > goal
>>> > > > is
>>> > > > >>>> to
>>> > > > >>>> > >> replace
>>> > > > >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
>>> > > > better
>>> > > > >>>> test
>>> > > > >>>> > >> > >>>>> coverage and
>>> > > > >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding
>>> > any
>>> > > > >>>> > >> documentation
>>> > > > >>>> > >> > >>>>> for
>>> > > > >>>> > >> > >>>>> > wiring this up..
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>> > Any help would be appreciated!
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>> > Deven
>>> > > > >>>> > >> > >>>>> >
>>> > > > >>>> > >> > >>>>>
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>>
>>> > > > >>>> > >> > >>>
>>> > > > >>>> > >> > >>
>>> > > > >>>> > >> > >
>>> > > > >>>> > >> >
>>> > > > >>>> > >>
>>> > > > >>>> > >
>>> > > > >>>> > >
>>> > > > >>>> >
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>> --
>>> > > > >>>> Jason Porter
>>> > > > >>>> http://en.gravatar.com/lightguardjp
>>> > > > >>>>
>>> > > > >>>
>>> > > > >>>
>>> > > > >>
>>> > > > >
>>> > > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > Jason Porter
>>> > > http://en.gravatar.com/lightguardjp
>>> > >
>>> >
>>>

Re: Jetty/Jersey/Injection

Posted by "John D. Ament" <jo...@gmail.com>.
I think I figured out the "how to run" part.  I added an application
plugin to the build.gradle and it starts.

It looks like your issue is much more of a resteasy problem rather
than a CDI problem.  Let me poke at it more, however you may want to
mail resteasy-users as well (I'm also on that list).

John

On Mon, Nov 24, 2014 at 10:38 AM, Deven Phillips
<de...@gmail.com> wrote:
> John,
>
>     I have been running it from either NetBeans or IntelliJ using their
> gradle plugins... You could potentially run from the CLI using a JavaExec
> task inside of Gradle. I will try to add one to the project today and get
> back with you on how to run it..
>
> Thanks,
>
> Deven
>
> On Sat, Nov 22, 2014 at 10:11 AM, John D. Ament <jo...@gmail.com>
> wrote:
>
>> It's a bit hard to compile your code since you're using lombok and gradle,
>> any build instructions you might want to share?  How do I create a runnable
>> app with this?
>>
>> Looking at what you're building against, I wouldn't recommend including
>> both weld-se and weld-servlet in your bundle.
>> On Sat Nov 22 2014 at 6:19:28 AM Deven Phillips <de...@gmail.com>
>> wrote:
>>
>> > To answer:
>> >
>> > 1. JavaEE application servers are not on our approved software list and I
>> > was told that the would not likely be approved in the near future.
>> >
>> > 2. I don't see how starting with a WAR and using a WebApplicationContext
>> > would make any difference in whether injections work... Regardless, it
>> > would mean having to separate the application and the server again
>> (Create
>> > the WAR, deploy to Jetty) and we are trying to avoid that.
>> >
>> > Thanks in advance,
>> >
>> > Deven
>> >
>> > On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <li...@gmail.com>
>> > wrote:
>> >
>> > > I have to say I'm not familiar at all with using Jetty this way. Is
>> > there a
>> > > reason for doing this instead of 1) starting the server and deploying a
>> > WAR
>> > > or 2) using a WebAppContext?
>> > >
>> > > On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <
>> > deven.phillips@gmail.com
>> > > >
>> > > wrote:
>> > >
>> > > > OK, I think that I have a project which can run, but I am still
>> getting
>> > > > NPEs for the injected resource.
>> > > >
>> > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
>> > > deven.phillips@gmail.com>
>> > > > wrote:
>> > > >
>> > > > > And by working, I mean it compiles.. I do not mean that the
>> > Dependency
>> > > > > Injection is working.
>> > > > >
>> > > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
>> > > > deven.phillips@gmail.com>
>> > > > > wrote:
>> > > > >
>> > > > >> OK, I created a branch called DeltaSpike which is now working...
>> > Sorry
>> > > > >> for wasting your time with a broken source tree!!
>> > > > >>
>> > > > >> Deven
>> > > > >>
>> > > > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
>> > > > deven.phillips@gmail.com
>> > > > >> > wrote:
>> > > > >>
>> > > > >>> I've never needed an "Application" class before while using Guice
>> > or
>> > > > >>> manually configuring JAX-RS with Jetty.. I will check to see if
>> > that
>> > > > makes
>> > > > >>> a difference...
>> > > > >>>
>> > > > >>> Deven
>> > > > >>>
>> > > > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
>> > > lightguard.jp@gmail.com
>> > > > >
>> > > > >>> wrote:
>> > > > >>>
>> > > > >>>> Maybe I missed something, but why are you going through all the
>> > > > trouble
>> > > > >>>> of
>> > > > >>>> starting the server and setting everything up manually? I still
>> > > don't
>> > > > >>>> see
>> > > > >>>> any JAX-RS config or JAX-RS Application class.
>> > > > >>>>
>> > > > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>> > > > >>>> deven.phillips@gmail.com>
>> > > > >>>> wrote:
>> > > > >>>>
>> > > > >>>> > I see what happened... I meant to create a separate branch
>> for a
>> > > > >>>> WeldSE
>> > > > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
>> > > > >>>> >
>> > > > >>>> > Deven
>> > > > >>>> >
>> > > > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>> > > > >>>> deven.phillips@gmail.com>
>> > > > >>>> > wrote:
>> > > > >>>> >
>> > > > >>>> > > John,
>> > > > >>>> > >
>> > > > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
>> > > > >>>> > >
>> > > > >>>> > > Deven
>> > > > >>>> > >
>> > > > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>> > > > >>>> john.d.ament@gmail.com>
>> > > > >>>> > > wrote:
>> > > > >>>> > >
>> > > > >>>> > >> Deven,
>> > > > >>>> > >>
>> > > > >>>> > >> Looks like there's no JAX-RS resources in this project...
>> > > > >>>> > >>
>> > > > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>> > > > >>>> > >> deven.phillips@gmail.com>
>> > > > >>>> > >> wrote:
>> > > > >>>> > >>
>> > > > >>>> > >> > I finally got around to trying to put together an example
>> > > > project
>> > > > >>>> > which
>> > > > >>>> > >> I
>> > > > >>>> > >> > could share publicly...
>> > > > >>>> > >> >
>> > > > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>> > > > >>>> > >> >
>> > > > >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to
>> > > work
>> > > > >>>> > injecting
>> > > > >>>> > >> > dependencies into my JAX-RS POJOs...
>> > > > >>>> > >> >
>> > > > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>> > > > >>>> > >> deven.phillips@gmail.com>
>> > > > >>>> > >> > wrote:
>> > > > >>>> > >> >
>> > > > >>>> > >> > > Creating the ServletContextHandler now looks like:
>> > > > >>>> > >> > >
>> > > > >>>> > >> > >         ServletContextHandler handler = new
>> > > > >>>> ServletContextHandler();
>> > > > >>>> > >> > >         handler.setContextPath("/");
>> > > > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>> > > > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
>> > > > >>>> > >> > >         handler.addEventListener(new
>> > > > >>>> BeanManagerResourceBindingList
>> > > > >>>> > >> > ener());
>> > > > >>>> > >> > >         handler.addEventListener(new
>> > > > >>>> CdiServletRequestListener());
>> > > > >>>> > >> > >         handler.addServlet(new ServletHolder(new
>> > > > >>>> > ServletContainer(new
>> > > > >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>> > > > >>>> > >> > >
>> > > > >>>> > >> > >
>> > > > >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs
>> > where
>> > > > it
>> > > > >>>> tries
>> > > > >>>> > >> to
>> > > > >>>> > >> > > access a supposedly injected resource.
>> > > > >>>> > >> > >
>> > > > >>>> > >> > > DEven
>> > > > >>>> > >> > >
>> > > > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>> > > > >>>> > >> > deven.phillips@gmail.com>
>> > > > >>>> > >> > > wrote:
>> > > > >>>> > >> > >
>> > > > >>>> > >> > >> OK, the @Target exception was a classpath problem and
>> I
>> > > have
>> > > > >>>> > resolved
>> > > > >>>> > >> > it,
>> > > > >>>> > >> > >> but I am still getting NullPointerExceptions because
>> > > nothing
>> > > > >>>> is
>> > > > >>>> > >> getting
>> > > > >>>> > >> > >> injected into my JAX-RS classes...
>> > > > >>>> > >> > >>
>> > > > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>> > > > >>>> > >> > deven.phillips@gmail.com
>> > > > >>>> > >> > >> > wrote:
>> > > > >>>> > >> > >>
>> > > > >>>> > >> > >>> So, I just tried this:
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>>     WebAppContext ctx = new
>> > > > >>>> WebAppContext("cc-backend-sungardas",
>> > > > >>>> > >> > "/");
>> > > > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>> > > > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>> > > > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
>> > > > ServletContainer(new
>> > > > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))),
>> "/*");
>> > > > >>>> > >> > >>>     ctx.addEventListener(new
>> > > > >>>> > BeanManagerResourceBindingListener());
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>> and I got the following Exceptions:
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>> > > > >>>> > >> > org.jboss.weld.Reflection:82
>> > > > >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is
>> > not
>> > > > >>>> declared
>> > > > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will
>> use
>> > > this
>> > > > >>>> > >> annotation,
>> > > > >>>> > >> > >>> however this may make the application unportable.
>> > > > >>>> > >> > >>>     Exception in thread "main"
>> > > > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException:
>> > Exception
>> > > > List
>> > > > >>>> > with 1
>> > > > >>>> > >> > >>> exceptions:
>> > > > >>>> > >> > >>>     Exception 0 :
>> > > > >>>> > >> > >>>     javax.enterprise.event.ObserverException
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> > > > >>>> > >> > >>> Method)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>> > > > >>>> > >> > NativeConstructorAccessorImpl.java:57)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>> > > > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:
>> > 526)
>> > > > >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>> > > > >>>> > >> > NewInstanceAction.java:33)
>> > > > >>>> > >> > >>>     at java.security.AccessController.doPrivileged(
>> > Native
>> > > > >>>> Method)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > > > >>>> > >> > Exceptions.java:40)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > > > >>>> > >> > Exceptions.java:78)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > > > >>>> > >> >
>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > > > >>>> > >> > ObserverMethodImpl.java:271)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>> > > > >>>> > >> > ExtensionObserverMethodImpl.java:121)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > > > >>>> > >> > ObserverMethodImpl.java:258)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>> > > > >>>> > >> > ObserverMethodImpl.java:237)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>> > > > >>>> > >> > ObserverNotifier.java:174)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>> > > > >>>> > >> > ObserverNotifier.java:133)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>> > > > >>>> > >> > ObserverNotifier.java:107)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>> > events.AbstractContainerEvent.
>> > > > >>>> > >> > fire(AbstractContainerEvent.java:54)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>> > events.AfterBeanDiscoveryImpl.
>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > > > >>>> > >> > WeldBootstrap.java:83)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > > > >>>> > >> > ForwardingBootstrap.java:63)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
>> > start(Main.java:171)
>> > > > >>>> > >> > >>>     at
>> com.sungardas.cc.edison.Main.main(Main.java:68)
>> > > > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>> > > > >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(
>> > Z)V
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>> > > > >>>> > >> > ThreadContext.java:40)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>> > > > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>> > > > >>>> > >> > >>>     at
>> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> > > > >>>> Method)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>> > > > >>>> > >> > NativeMethodAccessorImpl.java:57)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> > > > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
>> > > > >>>> > >> > >>>     at java.lang.reflect.Method.
>> > invoke(Method.java:606)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > > > >>>> > >> >
>> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>> > > > >>>> > >> > >>>     ... 17 more
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
>> > events.AfterBeanDiscoveryImpl.
>> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > > > >>>> > >> > WeldBootstrap.java:83)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> > > > >>>> > >>
>> > > > >>>>
>> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > > > >>>> > >> > ForwardingBootstrap.java:63)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > > > >>>> > >> > >>>     at
>> > > > >>>> > >> > >>>
>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > > > >>>> > >> > boot(WeldContainerControl.java:65)
>> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
>> > start(Main.java:171)
>> > > > >>>> > >> > >>>     at
>> com.sungardas.cc.edison.Main.main(Main.java:68)
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>> > > > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
>> > > 1.1.9.Final
>> > > > >>>> booted
>> > > > >>>> > >> using
>> > > > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked
>> document,
>> > > but
>> > > > I
>> > > > >>>> don't
>> > > > >>>> > >> see
>> > > > >>>> > >> > how
>> > > > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
>> > > > Normally, I
>> > > > >>>> > would
>> > > > >>>> > >> do
>> > > > >>>> > >> > >>>> something like:
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>>     ServletContextHandler ctx = new
>> > > > >>>> ServletContextHandler("/");
>> > > > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>> > > > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>> > > > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>> > > > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
>> > > > >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>> Where in there would I put in the BeanManager and
>> the
>> > > > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines
>> > below
>> > > > >>>> that
>> > > > >>>> > where
>> > > > >>>> > >> > they
>> > > > >>>> > >> > >>>> talk about using a listener to automatically bind
>> the
>> > > > >>>> > BeanManager?
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>> Thanks in advance!!
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>> Deven
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>> > > > >>>> > >> > lightguard.jp@gmail.com
>> > > > >>>> > >> > >>>> > wrote:
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>>> Which version of weld?
>> > > > >>>> > >> > >>>>>
>> > > > >>>> > >> > >>>>>
>> > > https://docs.jboss.org/weld/reference/latest/en-US/html/
>> > > > >>>> > >> > environments.html#_jetty
>> > > > >>>> > >> > >>>>> should be all you need for weld in jetty.
>> > > > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>> > > > >>>> > >> > deven.phillips@gmail.com
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>> wrote:
>> > > > >>>> > >> > >>>>>
>> > > > >>>> > >> > >>>>> > Hi all,
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>> >     I'm trying really hard to figure out how to
>> > make
>> > > > >>>> > >> > DeltaSpike/Weld
>> > > > >>>> > >> > >>>>> work
>> > > > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey
>> > servlet
>> > > > to
>> > > > >>>> load,
>> > > > >>>> > >> but
>> > > > >>>> > >> > I
>> > > > >>>> > >> > >>>>> cannot
>> > > > >>>> > >> > >>>>> > get any of the dependencies to be injected... My
>> > goal
>> > > > is
>> > > > >>>> to
>> > > > >>>> > >> replace
>> > > > >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
>> > > > better
>> > > > >>>> test
>> > > > >>>> > >> > >>>>> coverage and
>> > > > >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding
>> > any
>> > > > >>>> > >> documentation
>> > > > >>>> > >> > >>>>> for
>> > > > >>>> > >> > >>>>> > wiring this up..
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>> > Any help would be appreciated!
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>> > Deven
>> > > > >>>> > >> > >>>>> >
>> > > > >>>> > >> > >>>>>
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>>
>> > > > >>>> > >> > >>>
>> > > > >>>> > >> > >>
>> > > > >>>> > >> > >
>> > > > >>>> > >> >
>> > > > >>>> > >>
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>> >
>> > > > >>>>
>> > > > >>>>
>> > > > >>>>
>> > > > >>>> --
>> > > > >>>> Jason Porter
>> > > > >>>> http://en.gravatar.com/lightguardjp
>> > > > >>>>
>> > > > >>>
>> > > > >>>
>> > > > >>
>> > > > >
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Jason Porter
>> > > http://en.gravatar.com/lightguardjp
>> > >
>> >
>>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
John,

    I have been running it from either NetBeans or IntelliJ using their
gradle plugins... You could potentially run from the CLI using a JavaExec
task inside of Gradle. I will try to add one to the project today and get
back with you on how to run it..

Thanks,

Deven

On Sat, Nov 22, 2014 at 10:11 AM, John D. Ament <jo...@gmail.com>
wrote:

> It's a bit hard to compile your code since you're using lombok and gradle,
> any build instructions you might want to share?  How do I create a runnable
> app with this?
>
> Looking at what you're building against, I wouldn't recommend including
> both weld-se and weld-servlet in your bundle.
> On Sat Nov 22 2014 at 6:19:28 AM Deven Phillips <de...@gmail.com>
> wrote:
>
> > To answer:
> >
> > 1. JavaEE application servers are not on our approved software list and I
> > was told that the would not likely be approved in the near future.
> >
> > 2. I don't see how starting with a WAR and using a WebApplicationContext
> > would make any difference in whether injections work... Regardless, it
> > would mean having to separate the application and the server again
> (Create
> > the WAR, deploy to Jetty) and we are trying to avoid that.
> >
> > Thanks in advance,
> >
> > Deven
> >
> > On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <li...@gmail.com>
> > wrote:
> >
> > > I have to say I'm not familiar at all with using Jetty this way. Is
> > there a
> > > reason for doing this instead of 1) starting the server and deploying a
> > WAR
> > > or 2) using a WebAppContext?
> > >
> > > On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <
> > deven.phillips@gmail.com
> > > >
> > > wrote:
> > >
> > > > OK, I think that I have a project which can run, but I am still
> getting
> > > > NPEs for the injected resource.
> > > >
> > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> > > deven.phillips@gmail.com>
> > > > wrote:
> > > >
> > > > > And by working, I mean it compiles.. I do not mean that the
> > Dependency
> > > > > Injection is working.
> > > > >
> > > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> > > > deven.phillips@gmail.com>
> > > > > wrote:
> > > > >
> > > > >> OK, I created a branch called DeltaSpike which is now working...
> > Sorry
> > > > >> for wasting your time with a broken source tree!!
> > > > >>
> > > > >> Deven
> > > > >>
> > > > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
> > > > deven.phillips@gmail.com
> > > > >> > wrote:
> > > > >>
> > > > >>> I've never needed an "Application" class before while using Guice
> > or
> > > > >>> manually configuring JAX-RS with Jetty.. I will check to see if
> > that
> > > > makes
> > > > >>> a difference...
> > > > >>>
> > > > >>> Deven
> > > > >>>
> > > > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
> > > lightguard.jp@gmail.com
> > > > >
> > > > >>> wrote:
> > > > >>>
> > > > >>>> Maybe I missed something, but why are you going through all the
> > > > trouble
> > > > >>>> of
> > > > >>>> starting the server and setting everything up manually? I still
> > > don't
> > > > >>>> see
> > > > >>>> any JAX-RS config or JAX-RS Application class.
> > > > >>>>
> > > > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
> > > > >>>> deven.phillips@gmail.com>
> > > > >>>> wrote:
> > > > >>>>
> > > > >>>> > I see what happened... I meant to create a separate branch
> for a
> > > > >>>> WeldSE
> > > > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
> > > > >>>> >
> > > > >>>> > Deven
> > > > >>>> >
> > > > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> > > > >>>> deven.phillips@gmail.com>
> > > > >>>> > wrote:
> > > > >>>> >
> > > > >>>> > > John,
> > > > >>>> > >
> > > > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
> > > > >>>> > >
> > > > >>>> > > Deven
> > > > >>>> > >
> > > > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> > > > >>>> john.d.ament@gmail.com>
> > > > >>>> > > wrote:
> > > > >>>> > >
> > > > >>>> > >> Deven,
> > > > >>>> > >>
> > > > >>>> > >> Looks like there's no JAX-RS resources in this project...
> > > > >>>> > >>
> > > > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> > > > >>>> > >> deven.phillips@gmail.com>
> > > > >>>> > >> wrote:
> > > > >>>> > >>
> > > > >>>> > >> > I finally got around to trying to put together an example
> > > > project
> > > > >>>> > which
> > > > >>>> > >> I
> > > > >>>> > >> > could share publicly...
> > > > >>>> > >> >
> > > > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> > > > >>>> > >> >
> > > > >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to
> > > work
> > > > >>>> > injecting
> > > > >>>> > >> > dependencies into my JAX-RS POJOs...
> > > > >>>> > >> >
> > > > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> > > > >>>> > >> deven.phillips@gmail.com>
> > > > >>>> > >> > wrote:
> > > > >>>> > >> >
> > > > >>>> > >> > > Creating the ServletContextHandler now looks like:
> > > > >>>> > >> > >
> > > > >>>> > >> > >         ServletContextHandler handler = new
> > > > >>>> ServletContextHandler();
> > > > >>>> > >> > >         handler.setContextPath("/");
> > > > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > > > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
> > > > >>>> > >> > >         handler.addEventListener(new
> > > > >>>> BeanManagerResourceBindingList
> > > > >>>> > >> > ener());
> > > > >>>> > >> > >         handler.addEventListener(new
> > > > >>>> CdiServletRequestListener());
> > > > >>>> > >> > >         handler.addServlet(new ServletHolder(new
> > > > >>>> > ServletContainer(new
> > > > >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> > > > >>>> > >> > >
> > > > >>>> > >> > >
> > > > >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs
> > where
> > > > it
> > > > >>>> tries
> > > > >>>> > >> to
> > > > >>>> > >> > > access a supposedly injected resource.
> > > > >>>> > >> > >
> > > > >>>> > >> > > DEven
> > > > >>>> > >> > >
> > > > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> > > > >>>> > >> > deven.phillips@gmail.com>
> > > > >>>> > >> > > wrote:
> > > > >>>> > >> > >
> > > > >>>> > >> > >> OK, the @Target exception was a classpath problem and
> I
> > > have
> > > > >>>> > resolved
> > > > >>>> > >> > it,
> > > > >>>> > >> > >> but I am still getting NullPointerExceptions because
> > > nothing
> > > > >>>> is
> > > > >>>> > >> getting
> > > > >>>> > >> > >> injected into my JAX-RS classes...
> > > > >>>> > >> > >>
> > > > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> > > > >>>> > >> > deven.phillips@gmail.com
> > > > >>>> > >> > >> > wrote:
> > > > >>>> > >> > >>
> > > > >>>> > >> > >>> So, I just tried this:
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>>     WebAppContext ctx = new
> > > > >>>> WebAppContext("cc-backend-sungardas",
> > > > >>>> > >> > "/");
> > > > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> > > > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
> > > > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
> > > > ServletContainer(new
> > > > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))),
> "/*");
> > > > >>>> > >> > >>>     ctx.addEventListener(new
> > > > >>>> > BeanManagerResourceBindingListener());
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>> and I got the following Exceptions:
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> > > > >>>> > >> > org.jboss.weld.Reflection:82
> > > > >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is
> > not
> > > > >>>> declared
> > > > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will
> use
> > > this
> > > > >>>> > >> annotation,
> > > > >>>> > >> > >>> however this may make the application unportable.
> > > > >>>> > >> > >>>     Exception in thread "main"
> > > > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException:
> > Exception
> > > > List
> > > > >>>> > with 1
> > > > >>>> > >> > >>> exceptions:
> > > > >>>> > >> > >>>     Exception 0 :
> > > > >>>> > >> > >>>     javax.enterprise.event.ObserverException
> > > > >>>> > >> > >>>     at
> > > > >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > > >>>> > >> > >>> Method)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > > > >>>> > >> > NativeConstructorAccessorImpl.java:57)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > > > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:
> > 526)
> > > > >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> > > > >>>> > >> > NewInstanceAction.java:33)
> > > > >>>> > >> > >>>     at java.security.AccessController.doPrivileged(
> > Native
> > > > >>>> Method)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > > > >>>> > >> > Exceptions.java:40)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > > > >>>> > >> > Exceptions.java:78)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > > > >>>> > >> >
> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > > > >>>> > >> > ObserverMethodImpl.java:271)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> > > > >>>> > >> > ExtensionObserverMethodImpl.java:121)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > > > >>>> > >> > ObserverMethodImpl.java:258)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> > > > >>>> > >> > ObserverMethodImpl.java:237)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> > > > >>>> > >> > ObserverNotifier.java:174)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> > > > >>>> > >> > ObserverNotifier.java:133)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> > > > >>>> > >> > ObserverNotifier.java:107)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> > events.AbstractContainerEvent.
> > > > >>>> > >> > fire(AbstractContainerEvent.java:54)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> > events.AfterBeanDiscoveryImpl.
> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > > > >>>> > >> > WeldBootstrap.java:83)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > > > >>>> > >> > ForwardingBootstrap.java:63)
> > > > >>>> > >> > >>>     at
> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > > > >>>> > >> > boot(WeldContainerControl.java:65)
> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> > start(Main.java:171)
> > > > >>>> > >> > >>>     at
> com.sungardas.cc.edison.Main.main(Main.java:68)
> > > > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> > > > >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(
> > Z)V
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> > > > >>>> > >> > ThreadContext.java:40)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> > > > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> > > > >>>> > >> > >>>     at
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > > >>>> Method)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > >>>> > >> > NativeMethodAccessorImpl.java:57)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
> > > > >>>> > >> > >>>     at java.lang.reflect.Method.
> > invoke(Method.java:606)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > > > >>>> > >> >
> > > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> > > > >>>> > >> > >>>     ... 17 more
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > > > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> > events.AfterBeanDiscoveryImpl.
> > > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > > > >>>> > >> > WeldBootstrap.java:83)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> > > > >>>> > >>
> > > > >>>>
> > > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > > > >>>> > >> > ForwardingBootstrap.java:63)
> > > > >>>> > >> > >>>     at
> > > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > > > >>>> > >> > >>>     at
> > > > >>>> > >> > >>>
> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > > > >>>> > >> > boot(WeldContainerControl.java:65)
> > > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> > start(Main.java:171)
> > > > >>>> > >> > >>>     at
> com.sungardas.cc.edison.Main.main(Main.java:68)
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> > > > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
> > > 1.1.9.Final
> > > > >>>> booted
> > > > >>>> > >> using
> > > > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked
> document,
> > > but
> > > > I
> > > > >>>> don't
> > > > >>>> > >> see
> > > > >>>> > >> > how
> > > > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
> > > > Normally, I
> > > > >>>> > would
> > > > >>>> > >> do
> > > > >>>> > >> > >>>> something like:
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>>     ServletContextHandler ctx = new
> > > > >>>> ServletContextHandler("/");
> > > > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> > > > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> > > > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> > > > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
> > > > >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>> Where in there would I put in the BeanManager and
> the
> > > > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines
> > below
> > > > >>>> that
> > > > >>>> > where
> > > > >>>> > >> > they
> > > > >>>> > >> > >>>> talk about using a listener to automatically bind
> the
> > > > >>>> > BeanManager?
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>> Thanks in advance!!
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>> Deven
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> > > > >>>> > >> > lightguard.jp@gmail.com
> > > > >>>> > >> > >>>> > wrote:
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>>> Which version of weld?
> > > > >>>> > >> > >>>>>
> > > > >>>> > >> > >>>>>
> > > https://docs.jboss.org/weld/reference/latest/en-US/html/
> > > > >>>> > >> > environments.html#_jetty
> > > > >>>> > >> > >>>>> should be all you need for weld in jetty.
> > > > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> > > > >>>> > >> > deven.phillips@gmail.com
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>> wrote:
> > > > >>>> > >> > >>>>>
> > > > >>>> > >> > >>>>> > Hi all,
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>> >     I'm trying really hard to figure out how to
> > make
> > > > >>>> > >> > DeltaSpike/Weld
> > > > >>>> > >> > >>>>> work
> > > > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey
> > servlet
> > > > to
> > > > >>>> load,
> > > > >>>> > >> but
> > > > >>>> > >> > I
> > > > >>>> > >> > >>>>> cannot
> > > > >>>> > >> > >>>>> > get any of the dependencies to be injected... My
> > goal
> > > > is
> > > > >>>> to
> > > > >>>> > >> replace
> > > > >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
> > > > better
> > > > >>>> test
> > > > >>>> > >> > >>>>> coverage and
> > > > >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding
> > any
> > > > >>>> > >> documentation
> > > > >>>> > >> > >>>>> for
> > > > >>>> > >> > >>>>> > wiring this up..
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>> > Any help would be appreciated!
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>> > Deven
> > > > >>>> > >> > >>>>> >
> > > > >>>> > >> > >>>>>
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>>
> > > > >>>> > >> > >>>
> > > > >>>> > >> > >>
> > > > >>>> > >> > >
> > > > >>>> > >> >
> > > > >>>> > >>
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>> >
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > > >>>> --
> > > > >>>> Jason Porter
> > > > >>>> http://en.gravatar.com/lightguardjp
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Jason Porter
> > > http://en.gravatar.com/lightguardjp
> > >
> >
>

Re: Jetty/Jersey/Injection

Posted by "John D. Ament" <jo...@gmail.com>.
It's a bit hard to compile your code since you're using lombok and gradle,
any build instructions you might want to share?  How do I create a runnable
app with this?

Looking at what you're building against, I wouldn't recommend including
both weld-se and weld-servlet in your bundle.
On Sat Nov 22 2014 at 6:19:28 AM Deven Phillips <de...@gmail.com>
wrote:

> To answer:
>
> 1. JavaEE application servers are not on our approved software list and I
> was told that the would not likely be approved in the near future.
>
> 2. I don't see how starting with a WAR and using a WebApplicationContext
> would make any difference in whether injections work... Regardless, it
> would mean having to separate the application and the server again (Create
> the WAR, deploy to Jetty) and we are trying to avoid that.
>
> Thanks in advance,
>
> Deven
>
> On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <li...@gmail.com>
> wrote:
>
> > I have to say I'm not familiar at all with using Jetty this way. Is
> there a
> > reason for doing this instead of 1) starting the server and deploying a
> WAR
> > or 2) using a WebAppContext?
> >
> > On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <
> deven.phillips@gmail.com
> > >
> > wrote:
> >
> > > OK, I think that I have a project which can run, but I am still getting
> > > NPEs for the injected resource.
> > >
> > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> > deven.phillips@gmail.com>
> > > wrote:
> > >
> > > > And by working, I mean it compiles.. I do not mean that the
> Dependency
> > > > Injection is working.
> > > >
> > > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> > > deven.phillips@gmail.com>
> > > > wrote:
> > > >
> > > >> OK, I created a branch called DeltaSpike which is now working...
> Sorry
> > > >> for wasting your time with a broken source tree!!
> > > >>
> > > >> Deven
> > > >>
> > > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
> > > deven.phillips@gmail.com
> > > >> > wrote:
> > > >>
> > > >>> I've never needed an "Application" class before while using Guice
> or
> > > >>> manually configuring JAX-RS with Jetty.. I will check to see if
> that
> > > makes
> > > >>> a difference...
> > > >>>
> > > >>> Deven
> > > >>>
> > > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
> > lightguard.jp@gmail.com
> > > >
> > > >>> wrote:
> > > >>>
> > > >>>> Maybe I missed something, but why are you going through all the
> > > trouble
> > > >>>> of
> > > >>>> starting the server and setting everything up manually? I still
> > don't
> > > >>>> see
> > > >>>> any JAX-RS config or JAX-RS Application class.
> > > >>>>
> > > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
> > > >>>> deven.phillips@gmail.com>
> > > >>>> wrote:
> > > >>>>
> > > >>>> > I see what happened... I meant to create a separate branch for a
> > > >>>> WeldSE
> > > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
> > > >>>> >
> > > >>>> > Deven
> > > >>>> >
> > > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> > > >>>> deven.phillips@gmail.com>
> > > >>>> > wrote:
> > > >>>> >
> > > >>>> > > John,
> > > >>>> > >
> > > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
> > > >>>> > >
> > > >>>> > > Deven
> > > >>>> > >
> > > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> > > >>>> john.d.ament@gmail.com>
> > > >>>> > > wrote:
> > > >>>> > >
> > > >>>> > >> Deven,
> > > >>>> > >>
> > > >>>> > >> Looks like there's no JAX-RS resources in this project...
> > > >>>> > >>
> > > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> > > >>>> > >> deven.phillips@gmail.com>
> > > >>>> > >> wrote:
> > > >>>> > >>
> > > >>>> > >> > I finally got around to trying to put together an example
> > > project
> > > >>>> > which
> > > >>>> > >> I
> > > >>>> > >> > could share publicly...
> > > >>>> > >> >
> > > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> > > >>>> > >> >
> > > >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to
> > work
> > > >>>> > injecting
> > > >>>> > >> > dependencies into my JAX-RS POJOs...
> > > >>>> > >> >
> > > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> > > >>>> > >> deven.phillips@gmail.com>
> > > >>>> > >> > wrote:
> > > >>>> > >> >
> > > >>>> > >> > > Creating the ServletContextHandler now looks like:
> > > >>>> > >> > >
> > > >>>> > >> > >         ServletContextHandler handler = new
> > > >>>> ServletContextHandler();
> > > >>>> > >> > >         handler.setContextPath("/");
> > > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
> > > >>>> > >> > >         handler.addEventListener(new
> > > >>>> BeanManagerResourceBindingList
> > > >>>> > >> > ener());
> > > >>>> > >> > >         handler.addEventListener(new
> > > >>>> CdiServletRequestListener());
> > > >>>> > >> > >         handler.addServlet(new ServletHolder(new
> > > >>>> > ServletContainer(new
> > > >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> > > >>>> > >> > >
> > > >>>> > >> > >
> > > >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs
> where
> > > it
> > > >>>> tries
> > > >>>> > >> to
> > > >>>> > >> > > access a supposedly injected resource.
> > > >>>> > >> > >
> > > >>>> > >> > > DEven
> > > >>>> > >> > >
> > > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> > > >>>> > >> > deven.phillips@gmail.com>
> > > >>>> > >> > > wrote:
> > > >>>> > >> > >
> > > >>>> > >> > >> OK, the @Target exception was a classpath problem and I
> > have
> > > >>>> > resolved
> > > >>>> > >> > it,
> > > >>>> > >> > >> but I am still getting NullPointerExceptions because
> > nothing
> > > >>>> is
> > > >>>> > >> getting
> > > >>>> > >> > >> injected into my JAX-RS classes...
> > > >>>> > >> > >>
> > > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> > > >>>> > >> > deven.phillips@gmail.com
> > > >>>> > >> > >> > wrote:
> > > >>>> > >> > >>
> > > >>>> > >> > >>> So, I just tried this:
> > > >>>> > >> > >>>
> > > >>>> > >> > >>>     WebAppContext ctx = new
> > > >>>> WebAppContext("cc-backend-sungardas",
> > > >>>> > >> > "/");
> > > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> > > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
> > > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
> > > ServletContainer(new
> > > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> > > >>>> > >> > >>>     ctx.addEventListener(new
> > > >>>> > BeanManagerResourceBindingListener());
> > > >>>> > >> > >>>
> > > >>>> > >> > >>> and I got the following Exceptions:
> > > >>>> > >> > >>>
> > > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> > > >>>> > >> > org.jboss.weld.Reflection:82
> > > >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is
> not
> > > >>>> declared
> > > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use
> > this
> > > >>>> > >> annotation,
> > > >>>> > >> > >>> however this may make the application unportable.
> > > >>>> > >> > >>>     Exception in thread "main"
> > > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException:
> Exception
> > > List
> > > >>>> > with 1
> > > >>>> > >> > >>> exceptions:
> > > >>>> > >> > >>>     Exception 0 :
> > > >>>> > >> > >>>     javax.enterprise.event.ObserverException
> > > >>>> > >> > >>>     at
> > > >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > >>>> > >> > >>> Method)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > > >>>> > >> > NativeConstructorAccessorImpl.java:57)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
> > > >>>> > >> > >>>     at
> > > >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:
> 526)
> > > >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> > > >>>> > >> > NewInstanceAction.java:33)
> > > >>>> > >> > >>>     at java.security.AccessController.doPrivileged(
> Native
> > > >>>> Method)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > > >>>> > >> > Exceptions.java:40)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > > >>>> > >> > Exceptions.java:78)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > > >>>> > >> >
> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > > >>>> > >> > ObserverMethodImpl.java:271)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> > > >>>> > >> > ExtensionObserverMethodImpl.java:121)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > > >>>> > >> > ObserverMethodImpl.java:258)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> > > >>>> > >> > ObserverMethodImpl.java:237)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> > > >>>> > >> > ObserverNotifier.java:174)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> > > >>>> > >> > ObserverNotifier.java:133)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> > > >>>> > >> > ObserverNotifier.java:107)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> events.AbstractContainerEvent.
> > > >>>> > >> > fire(AbstractContainerEvent.java:54)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> events.AfterBeanDiscoveryImpl.
> > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > > >>>> > >> > WeldBootstrap.java:83)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > > >>>> > >> > ForwardingBootstrap.java:63)
> > > >>>> > >> > >>>     at
> > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > > >>>> > >> > boot(WeldContainerControl.java:65)
> > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> start(Main.java:171)
> > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> > > >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(
> Z)V
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> > > >>>> > >> > ThreadContext.java:40)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> > > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> > > >>>> > >> > >>>     at
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > >>>> Method)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> > > >>>> > >> > NativeMethodAccessorImpl.java:57)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
> > > >>>> > >> > >>>     at java.lang.reflect.Method.
> invoke(Method.java:606)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > > >>>> > >> >
> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> > > >>>> > >> > >>>     ... 17 more
> > > >>>> > >> > >>>
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.bootstrap.
> events.AfterBeanDiscoveryImpl.
> > > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > > >>>> > >> > WeldBootstrap.java:83)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>>
> > > >>>> > >>
> > > >>>>
> > org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > > >>>> > >> > ForwardingBootstrap.java:63)
> > > >>>> > >> > >>>     at
> > > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > > >>>> > >> > >>>     at
> > > >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > > >>>> > >> > boot(WeldContainerControl.java:65)
> > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.
> start(Main.java:171)
> > > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > > >>>> > >> > >>>
> > > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> > > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
> > > >>>> > >> > >>>
> > > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
> > 1.1.9.Final
> > > >>>> booted
> > > >>>> > >> using
> > > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document,
> > but
> > > I
> > > >>>> don't
> > > >>>> > >> see
> > > >>>> > >> > how
> > > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
> > > Normally, I
> > > >>>> > would
> > > >>>> > >> do
> > > >>>> > >> > >>>> something like:
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>>     ServletContextHandler ctx = new
> > > >>>> ServletContextHandler("/");
> > > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> > > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> > > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> > > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
> > > >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>> Where in there would I put in the BeanManager and the
> > > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines
> below
> > > >>>> that
> > > >>>> > where
> > > >>>> > >> > they
> > > >>>> > >> > >>>> talk about using a listener to automatically bind the
> > > >>>> > BeanManager?
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>> Thanks in advance!!
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>> Deven
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> > > >>>> > >> > lightguard.jp@gmail.com
> > > >>>> > >> > >>>> > wrote:
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>>> Which version of weld?
> > > >>>> > >> > >>>>>
> > > >>>> > >> > >>>>>
> > https://docs.jboss.org/weld/reference/latest/en-US/html/
> > > >>>> > >> > environments.html#_jetty
> > > >>>> > >> > >>>>> should be all you need for weld in jetty.
> > > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> > > >>>> > >> > deven.phillips@gmail.com
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>> wrote:
> > > >>>> > >> > >>>>>
> > > >>>> > >> > >>>>> > Hi all,
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>> >     I'm trying really hard to figure out how to
> make
> > > >>>> > >> > DeltaSpike/Weld
> > > >>>> > >> > >>>>> work
> > > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey
> servlet
> > > to
> > > >>>> load,
> > > >>>> > >> but
> > > >>>> > >> > I
> > > >>>> > >> > >>>>> cannot
> > > >>>> > >> > >>>>> > get any of the dependencies to be injected... My
> goal
> > > is
> > > >>>> to
> > > >>>> > >> replace
> > > >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
> > > better
> > > >>>> test
> > > >>>> > >> > >>>>> coverage and
> > > >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding
> any
> > > >>>> > >> documentation
> > > >>>> > >> > >>>>> for
> > > >>>> > >> > >>>>> > wiring this up..
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>> > Any help would be appreciated!
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>> > Deven
> > > >>>> > >> > >>>>> >
> > > >>>> > >> > >>>>>
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>>
> > > >>>> > >> > >>>
> > > >>>> > >> > >>
> > > >>>> > >> > >
> > > >>>> > >> >
> > > >>>> > >>
> > > >>>> > >
> > > >>>> > >
> > > >>>> >
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>> --
> > > >>>> Jason Porter
> > > >>>> http://en.gravatar.com/lightguardjp
> > > >>>>
> > > >>>
> > > >>>
> > > >>
> > > >
> > >
> >
> >
> >
> > --
> > Jason Porter
> > http://en.gravatar.com/lightguardjp
> >
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
To answer:

1. JavaEE application servers are not on our approved software list and I
was told that the would not likely be approved in the near future.

2. I don't see how starting with a WAR and using a WebApplicationContext
would make any difference in whether injections work... Regardless, it
would mean having to separate the application and the server again (Create
the WAR, deploy to Jetty) and we are trying to avoid that.

Thanks in advance,

Deven

On Fri, Nov 21, 2014 at 4:22 PM, Jason Porter <li...@gmail.com>
wrote:

> I have to say I'm not familiar at all with using Jetty this way. Is there a
> reason for doing this instead of 1) starting the server and deploying a WAR
> or 2) using a WebAppContext?
>
> On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <deven.phillips@gmail.com
> >
> wrote:
>
> > OK, I think that I have a project which can run, but I am still getting
> > NPEs for the injected resource.
> >
> > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> deven.phillips@gmail.com>
> > wrote:
> >
> > > And by working, I mean it compiles.. I do not mean that the Dependency
> > > Injection is working.
> > >
> > > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> > deven.phillips@gmail.com>
> > > wrote:
> > >
> > >> OK, I created a branch called DeltaSpike which is now working... Sorry
> > >> for wasting your time with a broken source tree!!
> > >>
> > >> Deven
> > >>
> > >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
> > deven.phillips@gmail.com
> > >> > wrote:
> > >>
> > >>> I've never needed an "Application" class before while using Guice or
> > >>> manually configuring JAX-RS with Jetty.. I will check to see if that
> > makes
> > >>> a difference...
> > >>>
> > >>> Deven
> > >>>
> > >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <
> lightguard.jp@gmail.com
> > >
> > >>> wrote:
> > >>>
> > >>>> Maybe I missed something, but why are you going through all the
> > trouble
> > >>>> of
> > >>>> starting the server and setting everything up manually? I still
> don't
> > >>>> see
> > >>>> any JAX-RS config or JAX-RS Application class.
> > >>>>
> > >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
> > >>>> deven.phillips@gmail.com>
> > >>>> wrote:
> > >>>>
> > >>>> > I see what happened... I meant to create a separate branch for a
> > >>>> WeldSE
> > >>>> > implementation and failed.. Checkout the tag 'deltaspike'
> > >>>> >
> > >>>> > Deven
> > >>>> >
> > >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> > >>>> deven.phillips@gmail.com>
> > >>>> > wrote:
> > >>>> >
> > >>>> > > John,
> > >>>> > >
> > >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
> > >>>> > >
> > >>>> > > Deven
> > >>>> > >
> > >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> > >>>> john.d.ament@gmail.com>
> > >>>> > > wrote:
> > >>>> > >
> > >>>> > >> Deven,
> > >>>> > >>
> > >>>> > >> Looks like there's no JAX-RS resources in this project...
> > >>>> > >>
> > >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> > >>>> > >> deven.phillips@gmail.com>
> > >>>> > >> wrote:
> > >>>> > >>
> > >>>> > >> > I finally got around to trying to put together an example
> > project
> > >>>> > which
> > >>>> > >> I
> > >>>> > >> > could share publicly...
> > >>>> > >> >
> > >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> > >>>> > >> >
> > >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to
> work
> > >>>> > injecting
> > >>>> > >> > dependencies into my JAX-RS POJOs...
> > >>>> > >> >
> > >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> > >>>> > >> deven.phillips@gmail.com>
> > >>>> > >> > wrote:
> > >>>> > >> >
> > >>>> > >> > > Creating the ServletContextHandler now looks like:
> > >>>> > >> > >
> > >>>> > >> > >         ServletContextHandler handler = new
> > >>>> ServletContextHandler();
> > >>>> > >> > >         handler.setContextPath("/");
> > >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > >>>> > >> > > EnumSet.allOf(DispatcherType.class));
> > >>>> > >> > >         handler.addEventListener(new
> > >>>> BeanManagerResourceBindingList
> > >>>> > >> > ener());
> > >>>> > >> > >         handler.addEventListener(new
> > >>>> CdiServletRequestListener());
> > >>>> > >> > >         handler.addServlet(new ServletHolder(new
> > >>>> > ServletContainer(new
> > >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> > >>>> > >> > >
> > >>>> > >> > >
> > >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where
> > it
> > >>>> tries
> > >>>> > >> to
> > >>>> > >> > > access a supposedly injected resource.
> > >>>> > >> > >
> > >>>> > >> > > DEven
> > >>>> > >> > >
> > >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> > >>>> > >> > deven.phillips@gmail.com>
> > >>>> > >> > > wrote:
> > >>>> > >> > >
> > >>>> > >> > >> OK, the @Target exception was a classpath problem and I
> have
> > >>>> > resolved
> > >>>> > >> > it,
> > >>>> > >> > >> but I am still getting NullPointerExceptions because
> nothing
> > >>>> is
> > >>>> > >> getting
> > >>>> > >> > >> injected into my JAX-RS classes...
> > >>>> > >> > >>
> > >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> > >>>> > >> > deven.phillips@gmail.com
> > >>>> > >> > >> > wrote:
> > >>>> > >> > >>
> > >>>> > >> > >>> So, I just tried this:
> > >>>> > >> > >>>
> > >>>> > >> > >>>     WebAppContext ctx = new
> > >>>> WebAppContext("cc-backend-sungardas",
> > >>>> > >> > "/");
> > >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> > >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
> > >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
> > ServletContainer(new
> > >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> > >>>> > >> > >>>     ctx.addEventListener(new
> > >>>> > BeanManagerResourceBindingListener());
> > >>>> > >> > >>>
> > >>>> > >> > >>> and I got the following Exceptions:
> > >>>> > >> > >>>
> > >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> > >>>> > >> > org.jboss.weld.Reflection:82
> > >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
> > >>>> declared
> > >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use
> this
> > >>>> > >> annotation,
> > >>>> > >> > >>> however this may make the application unportable.
> > >>>> > >> > >>>     Exception in thread "main"
> > >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception
> > List
> > >>>> > with 1
> > >>>> > >> > >>> exceptions:
> > >>>> > >> > >>>     Exception 0 :
> > >>>> > >> > >>>     javax.enterprise.event.ObserverException
> > >>>> > >> > >>>     at
> > >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > >>>> > >> > >>> Method)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > >>>> > >> > NativeConstructorAccessorImpl.java:57)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
> > >>>> > >> > >>>     at
> > >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> > >>>> > >> > NewInstanceAction.java:33)
> > >>>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
> > >>>> Method)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > >>>> > >> > Exceptions.java:40)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > >>>> > >> > Exceptions.java:78)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > >>>> > >> >
> invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > >>>> > >> > ObserverMethodImpl.java:271)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> > >>>> > >> > ExtensionObserverMethodImpl.java:121)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > >>>> > >> > ObserverMethodImpl.java:258)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> > >>>> > >> > ObserverMethodImpl.java:237)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> > >>>> > >> > ObserverNotifier.java:174)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> > >>>> > >> > ObserverNotifier.java:133)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> > >>>> > >> > ObserverNotifier.java:107)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> > >>>> > >> > fire(AbstractContainerEvent.java:54)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > >>>> > >> > AbstractDefinitionContainerEvent.java:42)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > >>>> > >> > WeldBootstrap.java:83)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > >>>> > >> > ForwardingBootstrap.java:63)
> > >>>> > >> > >>>     at
> > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > >>>> > >> > boot(WeldContainerControl.java:65)
> > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> > >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> > >>>> > >> > ThreadContext.java:40)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> > >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> > >>>> > >> > >>>     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > >>>> Method)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> > >>>> > >> > NativeMethodAccessorImpl.java:57)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > >>>> > >> > DelegatingMethodAccessorImpl.java:43)
> > >>>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > >>>> > >> >
> invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> > >>>> > >> > >>>     ... 17 more
> > >>>> > >> > >>>
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > >>>> > >> > AbstractDefinitionContainerEvent.java:44)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > >>>> > >> > WeldBootstrap.java:83)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>>
> > >>>> > >>
> > >>>>
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > >>>> > >> > ForwardingBootstrap.java:63)
> > >>>> > >> > >>>     at
> > >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >>>> > >> > >>>     at
> > >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > >>>> > >> > boot(WeldContainerControl.java:65)
> > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >>>> > >> > >>>
> > >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> > >>>> > >> > >>> deven.phillips@gmail.com> wrote:
> > >>>> > >> > >>>
> > >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version
> 1.1.9.Final
> > >>>> booted
> > >>>> > >> using
> > >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document,
> but
> > I
> > >>>> don't
> > >>>> > >> see
> > >>>> > >> > how
> > >>>> > >> > >>>> to translate that to embedded Jetty's startup...
> > Normally, I
> > >>>> > would
> > >>>> > >> do
> > >>>> > >> > >>>> something like:
> > >>>> > >> > >>>>
> > >>>> > >> > >>>>     ServletContextHandler ctx = new
> > >>>> ServletContextHandler("/");
> > >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> > >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> > >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> > >>>> > >> > >>>> PackagesResourceConfig(restPackage));
> > >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> > >>>> > >> > >>>>
> > >>>> > >> > >>>> Where in there would I put in the BeanManager and the
> > >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below
> > >>>> that
> > >>>> > where
> > >>>> > >> > they
> > >>>> > >> > >>>> talk about using a listener to automatically bind the
> > >>>> > BeanManager?
> > >>>> > >> > >>>>
> > >>>> > >> > >>>> Thanks in advance!!
> > >>>> > >> > >>>>
> > >>>> > >> > >>>> Deven
> > >>>> > >> > >>>>
> > >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> > >>>> > >> > lightguard.jp@gmail.com
> > >>>> > >> > >>>> > wrote:
> > >>>> > >> > >>>>
> > >>>> > >> > >>>>> Which version of weld?
> > >>>> > >> > >>>>>
> > >>>> > >> > >>>>>
> https://docs.jboss.org/weld/reference/latest/en-US/html/
> > >>>> > >> > environments.html#_jetty
> > >>>> > >> > >>>>> should be all you need for weld in jetty.
> > >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> > >>>> > >> > deven.phillips@gmail.com
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>> wrote:
> > >>>> > >> > >>>>>
> > >>>> > >> > >>>>> > Hi all,
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>> >     I'm trying really hard to figure out how to make
> > >>>> > >> > DeltaSpike/Weld
> > >>>> > >> > >>>>> work
> > >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet
> > to
> > >>>> load,
> > >>>> > >> but
> > >>>> > >> > I
> > >>>> > >> > >>>>> cannot
> > >>>> > >> > >>>>> > get any of the dependencies to be injected... My goal
> > is
> > >>>> to
> > >>>> > >> replace
> > >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
> > better
> > >>>> test
> > >>>> > >> > >>>>> coverage and
> > >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
> > >>>> > >> documentation
> > >>>> > >> > >>>>> for
> > >>>> > >> > >>>>> > wiring this up..
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>> > Any help would be appreciated!
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>> > Deven
> > >>>> > >> > >>>>> >
> > >>>> > >> > >>>>>
> > >>>> > >> > >>>>
> > >>>> > >> > >>>>
> > >>>> > >> > >>>
> > >>>> > >> > >>
> > >>>> > >> > >
> > >>>> > >> >
> > >>>> > >>
> > >>>> > >
> > >>>> > >
> > >>>> >
> > >>>>
> > >>>>
> > >>>>
> > >>>> --
> > >>>> Jason Porter
> > >>>> http://en.gravatar.com/lightguardjp
> > >>>>
> > >>>
> > >>>
> > >>
> > >
> >
>
>
>
> --
> Jason Porter
> http://en.gravatar.com/lightguardjp
>

Re: Jetty/Jersey/Injection

Posted by Ioan Eugen Stan <st...@gmail.com>.
Hello,

I think you can find some insight here [1]. You will need to bridge
cdi and hk2 injecction frameworks.

[1] http://stackoverflow.com/questions/21295589/cdi-interceptor-injected-into-a-jersey-rs-serviceresource-not-working

2014-11-21 23:22 GMT+02:00 Jason Porter <li...@gmail.com>:
> I have to say I'm not familiar at all with using Jetty this way. Is there a
> reason for doing this instead of 1) starting the server and deploying a WAR
> or 2) using a WebAppContext?
>
> On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> OK, I think that I have a project which can run, but I am still getting
>> NPEs for the injected resource.
>>
>> On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <de...@gmail.com>
>> wrote:
>>
>> > And by working, I mean it compiles.. I do not mean that the Dependency
>> > Injection is working.
>> >
>> > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
>> deven.phillips@gmail.com>
>> > wrote:
>> >
>> >> OK, I created a branch called DeltaSpike which is now working... Sorry
>> >> for wasting your time with a broken source tree!!
>> >>
>> >> Deven
>> >>
>> >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
>> deven.phillips@gmail.com
>> >> > wrote:
>> >>
>> >>> I've never needed an "Application" class before while using Guice or
>> >>> manually configuring JAX-RS with Jetty.. I will check to see if that
>> makes
>> >>> a difference...
>> >>>
>> >>> Deven
>> >>>
>> >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <lightguard.jp@gmail.com
>> >
>> >>> wrote:
>> >>>
>> >>>> Maybe I missed something, but why are you going through all the
>> trouble
>> >>>> of
>> >>>> starting the server and setting everything up manually? I still don't
>> >>>> see
>> >>>> any JAX-RS config or JAX-RS Application class.
>> >>>>
>> >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>> >>>> deven.phillips@gmail.com>
>> >>>> wrote:
>> >>>>
>> >>>> > I see what happened... I meant to create a separate branch for a
>> >>>> WeldSE
>> >>>> > implementation and failed.. Checkout the tag 'deltaspike'
>> >>>> >
>> >>>> > Deven
>> >>>> >
>> >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>> >>>> deven.phillips@gmail.com>
>> >>>> > wrote:
>> >>>> >
>> >>>> > > John,
>> >>>> > >
>> >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
>> >>>> > >
>> >>>> > > Deven
>> >>>> > >
>> >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>> >>>> john.d.ament@gmail.com>
>> >>>> > > wrote:
>> >>>> > >
>> >>>> > >> Deven,
>> >>>> > >>
>> >>>> > >> Looks like there's no JAX-RS resources in this project...
>> >>>> > >>
>> >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>> >>>> > >> deven.phillips@gmail.com>
>> >>>> > >> wrote:
>> >>>> > >>
>> >>>> > >> > I finally got around to trying to put together an example
>> project
>> >>>> > which
>> >>>> > >> I
>> >>>> > >> > could share publicly...
>> >>>> > >> >
>> >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>> >>>> > >> >
>> >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
>> >>>> > injecting
>> >>>> > >> > dependencies into my JAX-RS POJOs...
>> >>>> > >> >
>> >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>> >>>> > >> deven.phillips@gmail.com>
>> >>>> > >> > wrote:
>> >>>> > >> >
>> >>>> > >> > > Creating the ServletContextHandler now looks like:
>> >>>> > >> > >
>> >>>> > >> > >         ServletContextHandler handler = new
>> >>>> ServletContextHandler();
>> >>>> > >> > >         handler.setContextPath("/");
>> >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>> >>>> > >> > > EnumSet.allOf(DispatcherType.class));
>> >>>> > >> > >         handler.addEventListener(new
>> >>>> BeanManagerResourceBindingList
>> >>>> > >> > ener());
>> >>>> > >> > >         handler.addEventListener(new
>> >>>> CdiServletRequestListener());
>> >>>> > >> > >         handler.addServlet(new ServletHolder(new
>> >>>> > ServletContainer(new
>> >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>> >>>> > >> > >
>> >>>> > >> > >
>> >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where
>> it
>> >>>> tries
>> >>>> > >> to
>> >>>> > >> > > access a supposedly injected resource.
>> >>>> > >> > >
>> >>>> > >> > > DEven
>> >>>> > >> > >
>> >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>> >>>> > >> > deven.phillips@gmail.com>
>> >>>> > >> > > wrote:
>> >>>> > >> > >
>> >>>> > >> > >> OK, the @Target exception was a classpath problem and I have
>> >>>> > resolved
>> >>>> > >> > it,
>> >>>> > >> > >> but I am still getting NullPointerExceptions because nothing
>> >>>> is
>> >>>> > >> getting
>> >>>> > >> > >> injected into my JAX-RS classes...
>> >>>> > >> > >>
>> >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>> >>>> > >> > deven.phillips@gmail.com
>> >>>> > >> > >> > wrote:
>> >>>> > >> > >>
>> >>>> > >> > >>> So, I just tried this:
>> >>>> > >> > >>>
>> >>>> > >> > >>>     WebAppContext ctx = new
>> >>>> WebAppContext("cc-backend-sungardas",
>> >>>> > >> > "/");
>> >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>> >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>> >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
>> ServletContainer(new
>> >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
>> >>>> > >> > >>>     ctx.addEventListener(new
>> >>>> > BeanManagerResourceBindingListener());
>> >>>> > >> > >>>
>> >>>> > >> > >>> and I got the following Exceptions:
>> >>>> > >> > >>>
>> >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>> >>>> > >> > org.jboss.weld.Reflection:82
>> >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
>> >>>> declared
>> >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
>> >>>> > >> annotation,
>> >>>> > >> > >>> however this may make the application unportable.
>> >>>> > >> > >>>     Exception in thread "main"
>> >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception
>> List
>> >>>> > with 1
>> >>>> > >> > >>> exceptions:
>> >>>> > >> > >>>     Exception 0 :
>> >>>> > >> > >>>     javax.enterprise.event.ObserverException
>> >>>> > >> > >>>     at
>> >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> >>>> > >> > >>> Method)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>> >>>> > >> > NativeConstructorAccessorImpl.java:57)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>> >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
>> >>>> > >> > >>>     at
>> >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>> >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>> >>>> > >> > NewInstanceAction.java:33)
>> >>>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
>> >>>> Method)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> >>>> > >> > Exceptions.java:40)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> >>>> > >> > Exceptions.java:78)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> >>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> >>>> > >> > ObserverMethodImpl.java:271)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>> >>>> > >> > ExtensionObserverMethodImpl.java:121)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> >>>> > >> > ObserverMethodImpl.java:258)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>> >>>> > >> > ObserverMethodImpl.java:237)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>> >>>> > >> > ObserverNotifier.java:174)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>> >>>> > >> > ObserverNotifier.java:133)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>> >>>> > >> > ObserverNotifier.java:107)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
>> >>>> > >> > fire(AbstractContainerEvent.java:54)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> >>>> > >> > AbstractDefinitionContainerEvent.java:42)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> >>>> > >> > WeldBootstrap.java:83)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> >>>> > >> > ForwardingBootstrap.java:63)
>> >>>> > >> > >>>     at
>> >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> >>>> > >> > boot(WeldContainerControl.java:65)
>> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>> >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>> >>>> > >> > ThreadContext.java:40)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>> >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>> >>>> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> >>>> Method)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>> >>>> > >> > NativeMethodAccessorImpl.java:57)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> >>>> > >> > DelegatingMethodAccessorImpl.java:43)
>> >>>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> >>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>> >>>> > >> > >>>     ... 17 more
>> >>>> > >> > >>>
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> >>>> > >> > AbstractDefinitionContainerEvent.java:44)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> >>>> > >> > WeldBootstrap.java:83)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>>
>> >>>> > >>
>> >>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> >>>> > >> > ForwardingBootstrap.java:63)
>> >>>> > >> > >>>     at
>> >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> >>>> > >> > >>>     at
>> >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> >>>> > >> > boot(WeldContainerControl.java:65)
>> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> >>>> > >> > >>>
>> >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>> >>>> > >> > >>> deven.phillips@gmail.com> wrote:
>> >>>> > >> > >>>
>> >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
>> >>>> booted
>> >>>> > >> using
>> >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but
>> I
>> >>>> don't
>> >>>> > >> see
>> >>>> > >> > how
>> >>>> > >> > >>>> to translate that to embedded Jetty's startup...
>> Normally, I
>> >>>> > would
>> >>>> > >> do
>> >>>> > >> > >>>> something like:
>> >>>> > >> > >>>>
>> >>>> > >> > >>>>     ServletContextHandler ctx = new
>> >>>> ServletContextHandler("/");
>> >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>> >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>> >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>> >>>> > >> > >>>> PackagesResourceConfig(restPackage));
>> >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>> >>>> > >> > >>>>
>> >>>> > >> > >>>> Where in there would I put in the BeanManager and the
>> >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below
>> >>>> that
>> >>>> > where
>> >>>> > >> > they
>> >>>> > >> > >>>> talk about using a listener to automatically bind the
>> >>>> > BeanManager?
>> >>>> > >> > >>>>
>> >>>> > >> > >>>> Thanks in advance!!
>> >>>> > >> > >>>>
>> >>>> > >> > >>>> Deven
>> >>>> > >> > >>>>
>> >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>> >>>> > >> > lightguard.jp@gmail.com
>> >>>> > >> > >>>> > wrote:
>> >>>> > >> > >>>>
>> >>>> > >> > >>>>> Which version of weld?
>> >>>> > >> > >>>>>
>> >>>> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
>> >>>> > >> > environments.html#_jetty
>> >>>> > >> > >>>>> should be all you need for weld in jetty.
>> >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>> >>>> > >> > deven.phillips@gmail.com
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>> wrote:
>> >>>> > >> > >>>>>
>> >>>> > >> > >>>>> > Hi all,
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>> >     I'm trying really hard to figure out how to make
>> >>>> > >> > DeltaSpike/Weld
>> >>>> > >> > >>>>> work
>> >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet
>> to
>> >>>> load,
>> >>>> > >> but
>> >>>> > >> > I
>> >>>> > >> > >>>>> cannot
>> >>>> > >> > >>>>> > get any of the dependencies to be injected... My goal
>> is
>> >>>> to
>> >>>> > >> replace
>> >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
>> better
>> >>>> test
>> >>>> > >> > >>>>> coverage and
>> >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
>> >>>> > >> documentation
>> >>>> > >> > >>>>> for
>> >>>> > >> > >>>>> > wiring this up..
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>> > Any help would be appreciated!
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>> > Deven
>> >>>> > >> > >>>>> >
>> >>>> > >> > >>>>>
>> >>>> > >> > >>>>
>> >>>> > >> > >>>>
>> >>>> > >> > >>>
>> >>>> > >> > >>
>> >>>> > >> > >
>> >>>> > >> >
>> >>>> > >>
>> >>>> > >
>> >>>> > >
>> >>>> >
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Jason Porter
>> >>>> http://en.gravatar.com/lightguardjp
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>>
>
>
>
> --
> Jason Porter
> http://en.gravatar.com/lightguardjp



-- 
Ioan Eugen Stan
0720 898 747

Re: Jetty/Jersey/Injection

Posted by Jason Porter <li...@gmail.com>.
I have to say I'm not familiar at all with using Jetty this way. Is there a
reason for doing this instead of 1) starting the server and deploying a WAR
or 2) using a WebAppContext?

On Fri, Nov 21, 2014 at 12:42 PM, Deven Phillips <de...@gmail.com>
wrote:

> OK, I think that I have a project which can run, but I am still getting
> NPEs for the injected resource.
>
> On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <de...@gmail.com>
> wrote:
>
> > And by working, I mean it compiles.. I do not mean that the Dependency
> > Injection is working.
> >
> > On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <
> deven.phillips@gmail.com>
> > wrote:
> >
> >> OK, I created a branch called DeltaSpike which is now working... Sorry
> >> for wasting your time with a broken source tree!!
> >>
> >> Deven
> >>
> >> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <
> deven.phillips@gmail.com
> >> > wrote:
> >>
> >>> I've never needed an "Application" class before while using Guice or
> >>> manually configuring JAX-RS with Jetty.. I will check to see if that
> makes
> >>> a difference...
> >>>
> >>> Deven
> >>>
> >>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <lightguard.jp@gmail.com
> >
> >>> wrote:
> >>>
> >>>> Maybe I missed something, but why are you going through all the
> trouble
> >>>> of
> >>>> starting the server and setting everything up manually? I still don't
> >>>> see
> >>>> any JAX-RS config or JAX-RS Application class.
> >>>>
> >>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
> >>>> deven.phillips@gmail.com>
> >>>> wrote:
> >>>>
> >>>> > I see what happened... I meant to create a separate branch for a
> >>>> WeldSE
> >>>> > implementation and failed.. Checkout the tag 'deltaspike'
> >>>> >
> >>>> > Deven
> >>>> >
> >>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> >>>> deven.phillips@gmail.com>
> >>>> > wrote:
> >>>> >
> >>>> > > John,
> >>>> > >
> >>>> > >     Have a look at com.zanclus.example.api.GetServerTime
> >>>> > >
> >>>> > > Deven
> >>>> > >
> >>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> >>>> john.d.ament@gmail.com>
> >>>> > > wrote:
> >>>> > >
> >>>> > >> Deven,
> >>>> > >>
> >>>> > >> Looks like there's no JAX-RS resources in this project...
> >>>> > >>
> >>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> >>>> > >> deven.phillips@gmail.com>
> >>>> > >> wrote:
> >>>> > >>
> >>>> > >> > I finally got around to trying to put together an example
> project
> >>>> > which
> >>>> > >> I
> >>>> > >> > could share publicly...
> >>>> > >> >
> >>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> >>>> > >> >
> >>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
> >>>> > injecting
> >>>> > >> > dependencies into my JAX-RS POJOs...
> >>>> > >> >
> >>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> >>>> > >> deven.phillips@gmail.com>
> >>>> > >> > wrote:
> >>>> > >> >
> >>>> > >> > > Creating the ServletContextHandler now looks like:
> >>>> > >> > >
> >>>> > >> > >         ServletContextHandler handler = new
> >>>> ServletContextHandler();
> >>>> > >> > >         handler.setContextPath("/");
> >>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> >>>> > >> > > EnumSet.allOf(DispatcherType.class));
> >>>> > >> > >         handler.addEventListener(new
> >>>> BeanManagerResourceBindingList
> >>>> > >> > ener());
> >>>> > >> > >         handler.addEventListener(new
> >>>> CdiServletRequestListener());
> >>>> > >> > >         handler.addServlet(new ServletHolder(new
> >>>> > ServletContainer(new
> >>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> >>>> > >> > >
> >>>> > >> > >
> >>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where
> it
> >>>> tries
> >>>> > >> to
> >>>> > >> > > access a supposedly injected resource.
> >>>> > >> > >
> >>>> > >> > > DEven
> >>>> > >> > >
> >>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> >>>> > >> > deven.phillips@gmail.com>
> >>>> > >> > > wrote:
> >>>> > >> > >
> >>>> > >> > >> OK, the @Target exception was a classpath problem and I have
> >>>> > resolved
> >>>> > >> > it,
> >>>> > >> > >> but I am still getting NullPointerExceptions because nothing
> >>>> is
> >>>> > >> getting
> >>>> > >> > >> injected into my JAX-RS classes...
> >>>> > >> > >>
> >>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> >>>> > >> > deven.phillips@gmail.com
> >>>> > >> > >> > wrote:
> >>>> > >> > >>
> >>>> > >> > >>> So, I just tried this:
> >>>> > >> > >>>
> >>>> > >> > >>>     WebAppContext ctx = new
> >>>> WebAppContext("cc-backend-sungardas",
> >>>> > >> > "/");
> >>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> >>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
> >>>> > >> > >>>     ctx.addServlet(new ServletHolder(new
> ServletContainer(new
> >>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> >>>> > >> > >>>     ctx.addEventListener(new
> >>>> > BeanManagerResourceBindingListener());
> >>>> > >> > >>>
> >>>> > >> > >>> and I got the following Exceptions:
> >>>> > >> > >>>
> >>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> >>>> > >> > org.jboss.weld.Reflection:82
> >>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
> >>>> declared
> >>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
> >>>> > >> annotation,
> >>>> > >> > >>> however this may make the application unportable.
> >>>> > >> > >>>     Exception in thread "main"
> >>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception
> List
> >>>> > with 1
> >>>> > >> > >>> exceptions:
> >>>> > >> > >>>     Exception 0 :
> >>>> > >> > >>>     javax.enterprise.event.ObserverException
> >>>> > >> > >>>     at
> >>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >>>> > >> > >>> Method)
> >>>> > >> > >>>     at
> >>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> >>>> > >> > NativeConstructorAccessorImpl.java:57)
> >>>> > >> > >>>     at
> >>>> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> >>>> > >> > DelegatingConstructorAccessorImpl.java:45)
> >>>> > >> > >>>     at
> >>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> >>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> >>>> > >> > NewInstanceAction.java:33)
> >>>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
> >>>> Method)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> >>>> > >> > Exceptions.java:40)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> >>>> > >> > Exceptions.java:78)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >>>> > >> > ObserverMethodImpl.java:271)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> >>>> > >> > ExtensionObserverMethodImpl.java:121)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >>>> > >> > ObserverMethodImpl.java:258)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> >>>> > >> > ObserverMethodImpl.java:237)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> >>>> > >> > ObserverNotifier.java:174)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> >>>> > >> > ObserverNotifier.java:133)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> >>>> > >> > ObserverNotifier.java:107)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> >>>> > >> > fire(AbstractContainerEvent.java:54)
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >>>> > >> > AbstractDefinitionContainerEvent.java:42)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >>>> > >> > WeldBootstrap.java:83)
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >>>> > >> > ForwardingBootstrap.java:63)
> >>>> > >> > >>>     at
> >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >>>> > >> > boot(WeldContainerControl.java:65)
> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> >>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> >>>> > >> > ThreadContext.java:40)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> >>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> >>>> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> >>>> Method)
> >>>> > >> > >>>     at
> >>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> >>>> > >> > NativeMethodAccessorImpl.java:57)
> >>>> > >> > >>>     at
> >>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> >>>> > >> > DelegatingMethodAccessorImpl.java:43)
> >>>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> >>>> > >> > >>>     ... 17 more
> >>>> > >> > >>>
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >>>> > >> > AbstractDefinitionContainerEvent.java:44)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> >>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >>>> > >> > WeldBootstrap.java:83)
> >>>> > >> > >>>     at
> >>>> > >> > >>>
> >>>> > >>
> >>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >>>> > >> > ForwardingBootstrap.java:63)
> >>>> > >> > >>>     at
> >>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>>> > >> > >>>     at
> >>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >>>> > >> > boot(WeldContainerControl.java:65)
> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >>>> > >> > >>>
> >>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> >>>> > >> > >>> deven.phillips@gmail.com> wrote:
> >>>> > >> > >>>
> >>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
> >>>> booted
> >>>> > >> using
> >>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but
> I
> >>>> don't
> >>>> > >> see
> >>>> > >> > how
> >>>> > >> > >>>> to translate that to embedded Jetty's startup...
> Normally, I
> >>>> > would
> >>>> > >> do
> >>>> > >> > >>>> something like:
> >>>> > >> > >>>>
> >>>> > >> > >>>>     ServletContextHandler ctx = new
> >>>> ServletContextHandler("/");
> >>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> >>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> >>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> >>>> > >> > >>>> PackagesResourceConfig(restPackage));
> >>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> >>>> > >> > >>>>
> >>>> > >> > >>>> Where in there would I put in the BeanManager and the
> >>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below
> >>>> that
> >>>> > where
> >>>> > >> > they
> >>>> > >> > >>>> talk about using a listener to automatically bind the
> >>>> > BeanManager?
> >>>> > >> > >>>>
> >>>> > >> > >>>> Thanks in advance!!
> >>>> > >> > >>>>
> >>>> > >> > >>>> Deven
> >>>> > >> > >>>>
> >>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> >>>> > >> > lightguard.jp@gmail.com
> >>>> > >> > >>>> > wrote:
> >>>> > >> > >>>>
> >>>> > >> > >>>>> Which version of weld?
> >>>> > >> > >>>>>
> >>>> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
> >>>> > >> > environments.html#_jetty
> >>>> > >> > >>>>> should be all you need for weld in jetty.
> >>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> >>>> > >> > deven.phillips@gmail.com
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>> wrote:
> >>>> > >> > >>>>>
> >>>> > >> > >>>>> > Hi all,
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>> >     I'm trying really hard to figure out how to make
> >>>> > >> > DeltaSpike/Weld
> >>>> > >> > >>>>> work
> >>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet
> to
> >>>> load,
> >>>> > >> but
> >>>> > >> > I
> >>>> > >> > >>>>> cannot
> >>>> > >> > >>>>> > get any of the dependencies to be injected... My goal
> is
> >>>> to
> >>>> > >> replace
> >>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve
> better
> >>>> test
> >>>> > >> > >>>>> coverage and
> >>>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
> >>>> > >> documentation
> >>>> > >> > >>>>> for
> >>>> > >> > >>>>> > wiring this up..
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>> > Any help would be appreciated!
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>> > Deven
> >>>> > >> > >>>>> >
> >>>> > >> > >>>>>
> >>>> > >> > >>>>
> >>>> > >> > >>>>
> >>>> > >> > >>>
> >>>> > >> > >>
> >>>> > >> > >
> >>>> > >> >
> >>>> > >>
> >>>> > >
> >>>> > >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Jason Porter
> >>>> http://en.gravatar.com/lightguardjp
> >>>>
> >>>
> >>>
> >>
> >
>



-- 
Jason Porter
http://en.gravatar.com/lightguardjp

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
OK, I think that I have a project which can run, but I am still getting
NPEs for the injected resource.

On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <de...@gmail.com>
wrote:

> And by working, I mean it compiles.. I do not mean that the Dependency
> Injection is working.
>
> On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> OK, I created a branch called DeltaSpike which is now working... Sorry
>> for wasting your time with a broken source tree!!
>>
>> Deven
>>
>> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <deven.phillips@gmail.com
>> > wrote:
>>
>>> I've never needed an "Application" class before while using Guice or
>>> manually configuring JAX-RS with Jetty.. I will check to see if that makes
>>> a difference...
>>>
>>> Deven
>>>
>>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <li...@gmail.com>
>>> wrote:
>>>
>>>> Maybe I missed something, but why are you going through all the trouble
>>>> of
>>>> starting the server and setting everything up manually? I still don't
>>>> see
>>>> any JAX-RS config or JAX-RS Application class.
>>>>
>>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>>>> deven.phillips@gmail.com>
>>>> wrote:
>>>>
>>>> > I see what happened... I meant to create a separate branch for a
>>>> WeldSE
>>>> > implementation and failed.. Checkout the tag 'deltaspike'
>>>> >
>>>> > Deven
>>>> >
>>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>>>> deven.phillips@gmail.com>
>>>> > wrote:
>>>> >
>>>> > > John,
>>>> > >
>>>> > >     Have a look at com.zanclus.example.api.GetServerTime
>>>> > >
>>>> > > Deven
>>>> > >
>>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>>>> john.d.ament@gmail.com>
>>>> > > wrote:
>>>> > >
>>>> > >> Deven,
>>>> > >>
>>>> > >> Looks like there's no JAX-RS resources in this project...
>>>> > >>
>>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>>>> > >> deven.phillips@gmail.com>
>>>> > >> wrote:
>>>> > >>
>>>> > >> > I finally got around to trying to put together an example project
>>>> > which
>>>> > >> I
>>>> > >> > could share publicly...
>>>> > >> >
>>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>>>> > >> >
>>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
>>>> > injecting
>>>> > >> > dependencies into my JAX-RS POJOs...
>>>> > >> >
>>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>>>> > >> deven.phillips@gmail.com>
>>>> > >> > wrote:
>>>> > >> >
>>>> > >> > > Creating the ServletContextHandler now looks like:
>>>> > >> > >
>>>> > >> > >         ServletContextHandler handler = new
>>>> ServletContextHandler();
>>>> > >> > >         handler.setContextPath("/");
>>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>>>> > >> > > EnumSet.allOf(DispatcherType.class));
>>>> > >> > >         handler.addEventListener(new
>>>> BeanManagerResourceBindingList
>>>> > >> > ener());
>>>> > >> > >         handler.addEventListener(new
>>>> CdiServletRequestListener());
>>>> > >> > >         handler.addServlet(new ServletHolder(new
>>>> > ServletContainer(new
>>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>>>> > >> > >
>>>> > >> > >
>>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where it
>>>> tries
>>>> > >> to
>>>> > >> > > access a supposedly injected resource.
>>>> > >> > >
>>>> > >> > > DEven
>>>> > >> > >
>>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>>>> > >> > deven.phillips@gmail.com>
>>>> > >> > > wrote:
>>>> > >> > >
>>>> > >> > >> OK, the @Target exception was a classpath problem and I have
>>>> > resolved
>>>> > >> > it,
>>>> > >> > >> but I am still getting NullPointerExceptions because nothing
>>>> is
>>>> > >> getting
>>>> > >> > >> injected into my JAX-RS classes...
>>>> > >> > >>
>>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>>>> > >> > deven.phillips@gmail.com
>>>> > >> > >> > wrote:
>>>> > >> > >>
>>>> > >> > >>> So, I just tried this:
>>>> > >> > >>>
>>>> > >> > >>>     WebAppContext ctx = new
>>>> WebAppContext("cc-backend-sungardas",
>>>> > >> > "/");
>>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>>>> > >> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
>>>> > >> > >>>     ctx.addEventListener(new
>>>> > BeanManagerResourceBindingListener());
>>>> > >> > >>>
>>>> > >> > >>> and I got the following Exceptions:
>>>> > >> > >>>
>>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>>>> > >> > org.jboss.weld.Reflection:82
>>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
>>>> declared
>>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
>>>> > >> annotation,
>>>> > >> > >>> however this may make the application unportable.
>>>> > >> > >>>     Exception in thread "main"
>>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List
>>>> > with 1
>>>> > >> > >>> exceptions:
>>>> > >> > >>>     Exception 0 :
>>>> > >> > >>>     javax.enterprise.event.ObserverException
>>>> > >> > >>>     at
>>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>>> > >> > >>> Method)
>>>> > >> > >>>     at
>>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>>>> > >> > NativeConstructorAccessorImpl.java:57)
>>>> > >> > >>>     at
>>>> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>>>> > >> > DelegatingConstructorAccessorImpl.java:45)
>>>> > >> > >>>     at
>>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>>>> > >> > NewInstanceAction.java:33)
>>>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
>>>> Method)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>>> > >> > Exceptions.java:40)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>>> > >> > Exceptions.java:78)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>>> > >> > ObserverMethodImpl.java:271)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>>>> > >> > ExtensionObserverMethodImpl.java:121)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>>> > >> > ObserverMethodImpl.java:258)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>>>> > >> > ObserverMethodImpl.java:237)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>>>> > >> > ObserverNotifier.java:174)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>>>> > >> > ObserverNotifier.java:133)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>>>> > >> > ObserverNotifier.java:107)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
>>>> > >> > fire(AbstractContainerEvent.java:54)
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>>> > >> > AbstractDefinitionContainerEvent.java:42)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>>> > >> > WeldBootstrap.java:83)
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>>> > >> > ForwardingBootstrap.java:63)
>>>> > >> > >>>     at
>>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>>> > >> > >>>     at
>>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>>> > >> > boot(WeldContainerControl.java:65)
>>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>>>> > >> > ThreadContext.java:40)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>>>> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>> Method)
>>>> > >> > >>>     at
>>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>> > >> > NativeMethodAccessorImpl.java:57)
>>>> > >> > >>>     at
>>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>> > >> > DelegatingMethodAccessorImpl.java:43)
>>>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>>>> > >> > >>>     ... 17 more
>>>> > >> > >>>
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>>> > >> > AbstractDefinitionContainerEvent.java:44)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>>> > >> > >>>     at
>>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>>> > >> > WeldBootstrap.java:83)
>>>> > >> > >>>     at
>>>> > >> > >>>
>>>> > >>
>>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>>> > >> > ForwardingBootstrap.java:63)
>>>> > >> > >>>     at
>>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>>> > >> > >>>     at
>>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>>> > >> > boot(WeldContainerControl.java:65)
>>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>>> > >> > >>>
>>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>>>> > >> > >>> deven.phillips@gmail.com> wrote:
>>>> > >> > >>>
>>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
>>>> booted
>>>> > >> using
>>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I
>>>> don't
>>>> > >> see
>>>> > >> > how
>>>> > >> > >>>> to translate that to embedded Jetty's startup... Normally, I
>>>> > would
>>>> > >> do
>>>> > >> > >>>> something like:
>>>> > >> > >>>>
>>>> > >> > >>>>     ServletContextHandler ctx = new
>>>> ServletContextHandler("/");
>>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>>>> > >> > >>>> PackagesResourceConfig(restPackage));
>>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>>>> > >> > >>>>
>>>> > >> > >>>> Where in there would I put in the BeanManager and the
>>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below
>>>> that
>>>> > where
>>>> > >> > they
>>>> > >> > >>>> talk about using a listener to automatically bind the
>>>> > BeanManager?
>>>> > >> > >>>>
>>>> > >> > >>>> Thanks in advance!!
>>>> > >> > >>>>
>>>> > >> > >>>> Deven
>>>> > >> > >>>>
>>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>>>> > >> > lightguard.jp@gmail.com
>>>> > >> > >>>> > wrote:
>>>> > >> > >>>>
>>>> > >> > >>>>> Which version of weld?
>>>> > >> > >>>>>
>>>> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
>>>> > >> > environments.html#_jetty
>>>> > >> > >>>>> should be all you need for weld in jetty.
>>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>>>> > >> > deven.phillips@gmail.com
>>>> > >> > >>>>> >
>>>> > >> > >>>>> wrote:
>>>> > >> > >>>>>
>>>> > >> > >>>>> > Hi all,
>>>> > >> > >>>>> >
>>>> > >> > >>>>> >
>>>> > >> > >>>>> >     I'm trying really hard to figure out how to make
>>>> > >> > DeltaSpike/Weld
>>>> > >> > >>>>> work
>>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to
>>>> load,
>>>> > >> but
>>>> > >> > I
>>>> > >> > >>>>> cannot
>>>> > >> > >>>>> > get any of the dependencies to be injected... My goal is
>>>> to
>>>> > >> replace
>>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve better
>>>> test
>>>> > >> > >>>>> coverage and
>>>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
>>>> > >> documentation
>>>> > >> > >>>>> for
>>>> > >> > >>>>> > wiring this up..
>>>> > >> > >>>>> >
>>>> > >> > >>>>> > Any help would be appreciated!
>>>> > >> > >>>>> >
>>>> > >> > >>>>> > Deven
>>>> > >> > >>>>> >
>>>> > >> > >>>>>
>>>> > >> > >>>>
>>>> > >> > >>>>
>>>> > >> > >>>
>>>> > >> > >>
>>>> > >> > >
>>>> > >> >
>>>> > >>
>>>> > >
>>>> > >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Jason Porter
>>>> http://en.gravatar.com/lightguardjp
>>>>
>>>
>>>
>>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
And by working, I mean it compiles.. I do not mean that the Dependency
Injection is working.

On Fri, Nov 21, 2014 at 2:13 PM, Deven Phillips <de...@gmail.com>
wrote:

> OK, I created a branch called DeltaSpike which is now working... Sorry for
> wasting your time with a broken source tree!!
>
> Deven
>
> On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> I've never needed an "Application" class before while using Guice or
>> manually configuring JAX-RS with Jetty.. I will check to see if that makes
>> a difference...
>>
>> Deven
>>
>> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <li...@gmail.com>
>> wrote:
>>
>>> Maybe I missed something, but why are you going through all the trouble
>>> of
>>> starting the server and setting everything up manually? I still don't see
>>> any JAX-RS config or JAX-RS Application class.
>>>
>>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>>> deven.phillips@gmail.com>
>>> wrote:
>>>
>>> > I see what happened... I meant to create a separate branch for a WeldSE
>>> > implementation and failed.. Checkout the tag 'deltaspike'
>>> >
>>> > Deven
>>> >
>>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>>> deven.phillips@gmail.com>
>>> > wrote:
>>> >
>>> > > John,
>>> > >
>>> > >     Have a look at com.zanclus.example.api.GetServerTime
>>> > >
>>> > > Deven
>>> > >
>>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>>> john.d.ament@gmail.com>
>>> > > wrote:
>>> > >
>>> > >> Deven,
>>> > >>
>>> > >> Looks like there's no JAX-RS resources in this project...
>>> > >>
>>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>>> > >> deven.phillips@gmail.com>
>>> > >> wrote:
>>> > >>
>>> > >> > I finally got around to trying to put together an example project
>>> > which
>>> > >> I
>>> > >> > could share publicly...
>>> > >> >
>>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>>> > >> >
>>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
>>> > injecting
>>> > >> > dependencies into my JAX-RS POJOs...
>>> > >> >
>>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>>> > >> deven.phillips@gmail.com>
>>> > >> > wrote:
>>> > >> >
>>> > >> > > Creating the ServletContextHandler now looks like:
>>> > >> > >
>>> > >> > >         ServletContextHandler handler = new
>>> ServletContextHandler();
>>> > >> > >         handler.setContextPath("/");
>>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>>> > >> > > EnumSet.allOf(DispatcherType.class));
>>> > >> > >         handler.addEventListener(new
>>> BeanManagerResourceBindingList
>>> > >> > ener());
>>> > >> > >         handler.addEventListener(new
>>> CdiServletRequestListener());
>>> > >> > >         handler.addServlet(new ServletHolder(new
>>> > ServletContainer(new
>>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>>> > >> > >
>>> > >> > >
>>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where it
>>> tries
>>> > >> to
>>> > >> > > access a supposedly injected resource.
>>> > >> > >
>>> > >> > > DEven
>>> > >> > >
>>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>>> > >> > deven.phillips@gmail.com>
>>> > >> > > wrote:
>>> > >> > >
>>> > >> > >> OK, the @Target exception was a classpath problem and I have
>>> > resolved
>>> > >> > it,
>>> > >> > >> but I am still getting NullPointerExceptions because nothing is
>>> > >> getting
>>> > >> > >> injected into my JAX-RS classes...
>>> > >> > >>
>>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>>> > >> > deven.phillips@gmail.com
>>> > >> > >> > wrote:
>>> > >> > >>
>>> > >> > >>> So, I just tried this:
>>> > >> > >>>
>>> > >> > >>>     WebAppContext ctx = new
>>> WebAppContext("cc-backend-sungardas",
>>> > >> > "/");
>>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>>> > >> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
>>> > >> > >>>     ctx.addEventListener(new
>>> > BeanManagerResourceBindingListener());
>>> > >> > >>>
>>> > >> > >>> and I got the following Exceptions:
>>> > >> > >>>
>>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>>> > >> > org.jboss.weld.Reflection:82
>>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
>>> declared
>>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
>>> > >> annotation,
>>> > >> > >>> however this may make the application unportable.
>>> > >> > >>>     Exception in thread "main"
>>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List
>>> > with 1
>>> > >> > >>> exceptions:
>>> > >> > >>>     Exception 0 :
>>> > >> > >>>     javax.enterprise.event.ObserverException
>>> > >> > >>>     at
>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> > >> > >>> Method)
>>> > >> > >>>     at
>>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>>> > >> > NativeConstructorAccessorImpl.java:57)
>>> > >> > >>>     at
>>> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>>> > >> > DelegatingConstructorAccessorImpl.java:45)
>>> > >> > >>>     at
>>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>>> > >> > NewInstanceAction.java:33)
>>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
>>> Method)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>> > >> > Exceptions.java:40)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>>> > >> > Exceptions.java:78)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>> > >> > ObserverMethodImpl.java:271)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>>> > >> > ExtensionObserverMethodImpl.java:121)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>>> > >> > ObserverMethodImpl.java:258)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>>> > >> > ObserverMethodImpl.java:237)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>>> > >> > ObserverNotifier.java:174)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>>> > >> > ObserverNotifier.java:133)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>>> > >> > ObserverNotifier.java:107)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
>>> > >> > fire(AbstractContainerEvent.java:54)
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>> > >> > AbstractDefinitionContainerEvent.java:42)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>> > >> > WeldBootstrap.java:83)
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>> > >> > ForwardingBootstrap.java:63)
>>> > >> > >>>     at
>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>> > >> > >>>     at
>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>> > >> > boot(WeldContainerControl.java:65)
>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>>> > >> > ThreadContext.java:40)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>>> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>> Method)
>>> > >> > >>>     at
>>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>> > >> > NativeMethodAccessorImpl.java:57)
>>> > >> > >>>     at
>>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>> > >> > DelegatingMethodAccessorImpl.java:43)
>>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>>> > >> > >>>     ... 17 more
>>> > >> > >>>
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>>> > >> > AbstractDefinitionContainerEvent.java:44)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>> > >> > >>>     at
>>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>>> > >> > WeldBootstrap.java:83)
>>> > >> > >>>     at
>>> > >> > >>>
>>> > >>
>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>>> > >> > ForwardingBootstrap.java:63)
>>> > >> > >>>     at
>>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>> > >> > >>>     at
>>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>>> > >> > boot(WeldContainerControl.java:65)
>>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>> > >> > >>>
>>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>>> > >> > >>> deven.phillips@gmail.com> wrote:
>>> > >> > >>>
>>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
>>> booted
>>> > >> using
>>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I
>>> don't
>>> > >> see
>>> > >> > how
>>> > >> > >>>> to translate that to embedded Jetty's startup... Normally, I
>>> > would
>>> > >> do
>>> > >> > >>>> something like:
>>> > >> > >>>>
>>> > >> > >>>>     ServletContextHandler ctx = new
>>> ServletContextHandler("/");
>>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>>> > >> > >>>> PackagesResourceConfig(restPackage));
>>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>>> > >> > >>>>
>>> > >> > >>>> Where in there would I put in the BeanManager and the
>>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below that
>>> > where
>>> > >> > they
>>> > >> > >>>> talk about using a listener to automatically bind the
>>> > BeanManager?
>>> > >> > >>>>
>>> > >> > >>>> Thanks in advance!!
>>> > >> > >>>>
>>> > >> > >>>> Deven
>>> > >> > >>>>
>>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>>> > >> > lightguard.jp@gmail.com
>>> > >> > >>>> > wrote:
>>> > >> > >>>>
>>> > >> > >>>>> Which version of weld?
>>> > >> > >>>>>
>>> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
>>> > >> > environments.html#_jetty
>>> > >> > >>>>> should be all you need for weld in jetty.
>>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>>> > >> > deven.phillips@gmail.com
>>> > >> > >>>>> >
>>> > >> > >>>>> wrote:
>>> > >> > >>>>>
>>> > >> > >>>>> > Hi all,
>>> > >> > >>>>> >
>>> > >> > >>>>> >
>>> > >> > >>>>> >     I'm trying really hard to figure out how to make
>>> > >> > DeltaSpike/Weld
>>> > >> > >>>>> work
>>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to
>>> load,
>>> > >> but
>>> > >> > I
>>> > >> > >>>>> cannot
>>> > >> > >>>>> > get any of the dependencies to be injected... My goal is
>>> to
>>> > >> replace
>>> > >> > >>>>> > Google's Guice DI framework so that I can achieve better
>>> test
>>> > >> > >>>>> coverage and
>>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
>>> > >> documentation
>>> > >> > >>>>> for
>>> > >> > >>>>> > wiring this up..
>>> > >> > >>>>> >
>>> > >> > >>>>> > Any help would be appreciated!
>>> > >> > >>>>> >
>>> > >> > >>>>> > Deven
>>> > >> > >>>>> >
>>> > >> > >>>>>
>>> > >> > >>>>
>>> > >> > >>>>
>>> > >> > >>>
>>> > >> > >>
>>> > >> > >
>>> > >> >
>>> > >>
>>> > >
>>> > >
>>> >
>>>
>>>
>>>
>>> --
>>> Jason Porter
>>> http://en.gravatar.com/lightguardjp
>>>
>>
>>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
OK, I created a branch called DeltaSpike which is now working... Sorry for
wasting your time with a broken source tree!!

Deven

On Fri, Nov 21, 2014 at 2:04 PM, Deven Phillips <de...@gmail.com>
wrote:

> I've never needed an "Application" class before while using Guice or
> manually configuring JAX-RS with Jetty.. I will check to see if that makes
> a difference...
>
> Deven
>
> On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <li...@gmail.com>
> wrote:
>
>> Maybe I missed something, but why are you going through all the trouble of
>> starting the server and setting everything up manually? I still don't see
>> any JAX-RS config or JAX-RS Application class.
>>
>> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <
>> deven.phillips@gmail.com>
>> wrote:
>>
>> > I see what happened... I meant to create a separate branch for a WeldSE
>> > implementation and failed.. Checkout the tag 'deltaspike'
>> >
>> > Deven
>> >
>> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
>> deven.phillips@gmail.com>
>> > wrote:
>> >
>> > > John,
>> > >
>> > >     Have a look at com.zanclus.example.api.GetServerTime
>> > >
>> > > Deven
>> > >
>> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
>> john.d.ament@gmail.com>
>> > > wrote:
>> > >
>> > >> Deven,
>> > >>
>> > >> Looks like there's no JAX-RS resources in this project...
>> > >>
>> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>> > >> deven.phillips@gmail.com>
>> > >> wrote:
>> > >>
>> > >> > I finally got around to trying to put together an example project
>> > which
>> > >> I
>> > >> > could share publicly...
>> > >> >
>> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
>> > >> >
>> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
>> > injecting
>> > >> > dependencies into my JAX-RS POJOs...
>> > >> >
>> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>> > >> deven.phillips@gmail.com>
>> > >> > wrote:
>> > >> >
>> > >> > > Creating the ServletContextHandler now looks like:
>> > >> > >
>> > >> > >         ServletContextHandler handler = new
>> ServletContextHandler();
>> > >> > >         handler.setContextPath("/");
>> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>> > >> > > EnumSet.allOf(DispatcherType.class));
>> > >> > >         handler.addEventListener(new
>> BeanManagerResourceBindingList
>> > >> > ener());
>> > >> > >         handler.addEventListener(new
>> CdiServletRequestListener());
>> > >> > >         handler.addServlet(new ServletHolder(new
>> > ServletContainer(new
>> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
>> > >> > >
>> > >> > >
>> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where it
>> tries
>> > >> to
>> > >> > > access a supposedly injected resource.
>> > >> > >
>> > >> > > DEven
>> > >> > >
>> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>> > >> > deven.phillips@gmail.com>
>> > >> > > wrote:
>> > >> > >
>> > >> > >> OK, the @Target exception was a classpath problem and I have
>> > resolved
>> > >> > it,
>> > >> > >> but I am still getting NullPointerExceptions because nothing is
>> > >> getting
>> > >> > >> injected into my JAX-RS classes...
>> > >> > >>
>> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>> > >> > deven.phillips@gmail.com
>> > >> > >> > wrote:
>> > >> > >>
>> > >> > >>> So, I just tried this:
>> > >> > >>>
>> > >> > >>>     WebAppContext ctx = new
>> WebAppContext("cc-backend-sungardas",
>> > >> > "/");
>> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>> > >> > >>> EnumSet.allOf(DispatcherType.class));
>> > >> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
>> > >> > >>>     ctx.addEventListener(new
>> > BeanManagerResourceBindingListener());
>> > >> > >>>
>> > >> > >>> and I got the following Exceptions:
>> > >> > >>>
>> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>> > >> > org.jboss.weld.Reflection:82
>> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
>> declared
>> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
>> > >> annotation,
>> > >> > >>> however this may make the application unportable.
>> > >> > >>>     Exception in thread "main"
>> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List
>> > with 1
>> > >> > >>> exceptions:
>> > >> > >>>     Exception 0 :
>> > >> > >>>     javax.enterprise.event.ObserverException
>> > >> > >>>     at
>> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> > >> > >>> Method)
>> > >> > >>>     at
>> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>> > >> > NativeConstructorAccessorImpl.java:57)
>> > >> > >>>     at
>> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>> > >> > DelegatingConstructorAccessorImpl.java:45)
>> > >> > >>>     at
>> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
>> > >> > NewInstanceAction.java:33)
>> > >> > >>>     at java.security.AccessController.doPrivileged(Native
>> Method)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > >> > Exceptions.java:40)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > >> > Exceptions.java:78)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > >> > ObserverMethodImpl.java:271)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>> > >> > ExtensionObserverMethodImpl.java:121)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > >> > ObserverMethodImpl.java:258)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>> > >> > ObserverMethodImpl.java:237)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>> > >> > ObserverNotifier.java:174)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>> > >> > ObserverNotifier.java:133)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>> > >> > ObserverNotifier.java:107)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
>> > >> > fire(AbstractContainerEvent.java:54)
>> > >> > >>>     at
>> > >> > >>>
>> > >>
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > >> > AbstractDefinitionContainerEvent.java:42)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> > >> > >>>     at
>> > >> > >>>
>> > >>
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > >> > WeldBootstrap.java:83)
>> > >> > >>>     at
>> > >> > >>>
>> > >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > >> > ForwardingBootstrap.java:63)
>> > >> > >>>     at
>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > >> > >>>     at
>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > >> > boot(WeldContainerControl.java:65)
>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
>> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>> > >> > ThreadContext.java:40)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> Method)
>> > >> > >>>     at
>> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>> > >> > NativeMethodAccessorImpl.java:57)
>> > >> > >>>     at
>> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> > >> > DelegatingMethodAccessorImpl.java:43)
>> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>> > >> > >>>     ... 17 more
>> > >> > >>>
>> > >> > >>>     at
>> > >> > >>>
>> > >>
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > >> > AbstractDefinitionContainerEvent.java:44)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> > >> > fire(AfterBeanDiscoveryImpl.java:59)
>> > >> > >>>     at
>> > >> > >>>
>> > >>
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > >> > >>>     at
>> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > >> > WeldBootstrap.java:83)
>> > >> > >>>     at
>> > >> > >>>
>> > >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > >> > ForwardingBootstrap.java:63)
>> > >> > >>>     at
>> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > >> > >>>     at
>> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > >> > boot(WeldContainerControl.java:65)
>> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> > >> > >>>
>> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>> > >> > >>> deven.phillips@gmail.com> wrote:
>> > >> > >>>
>> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
>> booted
>> > >> using
>> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I
>> don't
>> > >> see
>> > >> > how
>> > >> > >>>> to translate that to embedded Jetty's startup... Normally, I
>> > would
>> > >> do
>> > >> > >>>> something like:
>> > >> > >>>>
>> > >> > >>>>     ServletContextHandler ctx = new
>> ServletContextHandler("/");
>> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>> > >> > >>>> EnumSet.allOf(DispatcherType.class)
>> > >> > >>>>     ctx.addServlet(new ServletContainer(new
>> > >> > >>>> PackagesResourceConfig(restPackage));
>> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
>> > >> > >>>>
>> > >> > >>>> Where in there would I put in the BeanManager and the
>> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below that
>> > where
>> > >> > they
>> > >> > >>>> talk about using a listener to automatically bind the
>> > BeanManager?
>> > >> > >>>>
>> > >> > >>>> Thanks in advance!!
>> > >> > >>>>
>> > >> > >>>> Deven
>> > >> > >>>>
>> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>> > >> > lightguard.jp@gmail.com
>> > >> > >>>> > wrote:
>> > >> > >>>>
>> > >> > >>>>> Which version of weld?
>> > >> > >>>>>
>> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
>> > >> > environments.html#_jetty
>> > >> > >>>>> should be all you need for weld in jetty.
>> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>> > >> > deven.phillips@gmail.com
>> > >> > >>>>> >
>> > >> > >>>>> wrote:
>> > >> > >>>>>
>> > >> > >>>>> > Hi all,
>> > >> > >>>>> >
>> > >> > >>>>> >
>> > >> > >>>>> >     I'm trying really hard to figure out how to make
>> > >> > DeltaSpike/Weld
>> > >> > >>>>> work
>> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to
>> load,
>> > >> but
>> > >> > I
>> > >> > >>>>> cannot
>> > >> > >>>>> > get any of the dependencies to be injected... My goal is to
>> > >> replace
>> > >> > >>>>> > Google's Guice DI framework so that I can achieve better
>> test
>> > >> > >>>>> coverage and
>> > >> > >>>>> > decoupling... I'm having a very hard time finding any
>> > >> documentation
>> > >> > >>>>> for
>> > >> > >>>>> > wiring this up..
>> > >> > >>>>> >
>> > >> > >>>>> > Any help would be appreciated!
>> > >> > >>>>> >
>> > >> > >>>>> > Deven
>> > >> > >>>>> >
>> > >> > >>>>>
>> > >> > >>>>
>> > >> > >>>>
>> > >> > >>>
>> > >> > >>
>> > >> > >
>> > >> >
>> > >>
>> > >
>> > >
>> >
>>
>>
>>
>> --
>> Jason Porter
>> http://en.gravatar.com/lightguardjp
>>
>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
I've never needed an "Application" class before while using Guice or
manually configuring JAX-RS with Jetty.. I will check to see if that makes
a difference...

Deven

On Fri, Nov 21, 2014 at 1:37 PM, Jason Porter <li...@gmail.com>
wrote:

> Maybe I missed something, but why are you going through all the trouble of
> starting the server and setting everything up manually? I still don't see
> any JAX-RS config or JAX-RS Application class.
>
> On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <deven.phillips@gmail.com
> >
> wrote:
>
> > I see what happened... I meant to create a separate branch for a WeldSE
> > implementation and failed.. Checkout the tag 'deltaspike'
> >
> > Deven
> >
> > On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <
> deven.phillips@gmail.com>
> > wrote:
> >
> > > John,
> > >
> > >     Have a look at com.zanclus.example.api.GetServerTime
> > >
> > > Deven
> > >
> > > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <
> john.d.ament@gmail.com>
> > > wrote:
> > >
> > >> Deven,
> > >>
> > >> Looks like there's no JAX-RS resources in this project...
> > >>
> > >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> > >> deven.phillips@gmail.com>
> > >> wrote:
> > >>
> > >> > I finally got around to trying to put together an example project
> > which
> > >> I
> > >> > could share publicly...
> > >> >
> > >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> > >> >
> > >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
> > injecting
> > >> > dependencies into my JAX-RS POJOs...
> > >> >
> > >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> > >> deven.phillips@gmail.com>
> > >> > wrote:
> > >> >
> > >> > > Creating the ServletContextHandler now looks like:
> > >> > >
> > >> > >         ServletContextHandler handler = new
> ServletContextHandler();
> > >> > >         handler.setContextPath("/");
> > >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > >> > > EnumSet.allOf(DispatcherType.class));
> > >> > >         handler.addEventListener(new
> BeanManagerResourceBindingList
> > >> > ener());
> > >> > >         handler.addEventListener(new CdiServletRequestListener());
> > >> > >         handler.addServlet(new ServletHolder(new
> > ServletContainer(new
> > >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> > >> > >
> > >> > >
> > >> > > And the exception is an NPE in one of my JAX-RS POJOs where it
> tries
> > >> to
> > >> > > access a supposedly injected resource.
> > >> > >
> > >> > > DEven
> > >> > >
> > >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> > >> > deven.phillips@gmail.com>
> > >> > > wrote:
> > >> > >
> > >> > >> OK, the @Target exception was a classpath problem and I have
> > resolved
> > >> > it,
> > >> > >> but I am still getting NullPointerExceptions because nothing is
> > >> getting
> > >> > >> injected into my JAX-RS classes...
> > >> > >>
> > >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> > >> > deven.phillips@gmail.com
> > >> > >> > wrote:
> > >> > >>
> > >> > >>> So, I just tried this:
> > >> > >>>
> > >> > >>>     WebAppContext ctx = new
> WebAppContext("cc-backend-sungardas",
> > >> > "/");
> > >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> > >> > >>> EnumSet.allOf(DispatcherType.class));
> > >> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
> > >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> > >> > >>>     ctx.addEventListener(new
> > BeanManagerResourceBindingListener());
> > >> > >>>
> > >> > >>> and I got the following Exceptions:
> > >> > >>>
> > >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> > >> > org.jboss.weld.Reflection:82
> > >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not
> declared
> > >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
> > >> annotation,
> > >> > >>> however this may make the application unportable.
> > >> > >>>     Exception in thread "main"
> > >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List
> > with 1
> > >> > >>> exceptions:
> > >> > >>>     Exception 0 :
> > >> > >>>     javax.enterprise.event.ObserverException
> > >> > >>>     at
> > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > >> > >>> Method)
> > >> > >>>     at
> > >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > >> > NativeConstructorAccessorImpl.java:57)
> > >> > >>>     at
> > >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > >> > DelegatingConstructorAccessorImpl.java:45)
> > >> > >>>     at
> > >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> > >> > NewInstanceAction.java:33)
> > >> > >>>     at java.security.AccessController.doPrivileged(Native
> Method)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > >> > Exceptions.java:40)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > >> > Exceptions.java:78)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > >> > ObserverMethodImpl.java:271)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> > >> > ExtensionObserverMethodImpl.java:121)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > >> > ObserverMethodImpl.java:258)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> > >> > ObserverMethodImpl.java:237)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> > >> > ObserverNotifier.java:174)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> > >> > ObserverNotifier.java:133)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> > >> > ObserverNotifier.java:107)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> > >> > fire(AbstractContainerEvent.java:54)
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > >> > AbstractDefinitionContainerEvent.java:42)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > >> > WeldBootstrap.java:83)
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > >> > ForwardingBootstrap.java:63)
> > >> > >>>     at
> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >> > >>>     at
> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > >> > boot(WeldContainerControl.java:65)
> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >> > >>>     Caused by: java.lang.NoSuchMethodError:
> > >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> > >> > >>>     at
> > >> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> > >> > ThreadContext.java:40)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> > >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> > >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> > >> > >>>     at
> > >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> > >> > NativeMethodAccessorImpl.java:57)
> > >> > >>>     at
> > >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > >> > DelegatingMethodAccessorImpl.java:43)
> > >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> > >> > >>>     ... 17 more
> > >> > >>>
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > >> > AbstractDefinitionContainerEvent.java:44)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > >> > fire(AfterBeanDiscoveryImpl.java:59)
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >> > >>>     at
> > >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > >> > WeldBootstrap.java:83)
> > >> > >>>     at
> > >> > >>>
> > >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > >> > ForwardingBootstrap.java:63)
> > >> > >>>     at
> > org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >> > >>>     at
> > >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > >> > boot(WeldContainerControl.java:65)
> > >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >> > >>>
> > >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> > >> > >>> deven.phillips@gmail.com> wrote:
> > >> > >>>
> > >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final
> booted
> > >> using
> > >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I
> don't
> > >> see
> > >> > how
> > >> > >>>> to translate that to embedded Jetty's startup... Normally, I
> > would
> > >> do
> > >> > >>>> something like:
> > >> > >>>>
> > >> > >>>>     ServletContextHandler ctx = new ServletContextHandler("/");
> > >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> > >> > >>>> EnumSet.allOf(DispatcherType.class)
> > >> > >>>>     ctx.addServlet(new ServletContainer(new
> > >> > >>>> PackagesResourceConfig(restPackage));
> > >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> > >> > >>>>
> > >> > >>>> Where in there would I put in the BeanManager and the
> > >> > >>>> ManagerObjectFactory? Or should I follow the lines below that
> > where
> > >> > they
> > >> > >>>> talk about using a listener to automatically bind the
> > BeanManager?
> > >> > >>>>
> > >> > >>>> Thanks in advance!!
> > >> > >>>>
> > >> > >>>> Deven
> > >> > >>>>
> > >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> > >> > lightguard.jp@gmail.com
> > >> > >>>> > wrote:
> > >> > >>>>
> > >> > >>>>> Which version of weld?
> > >> > >>>>>
> > >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
> > >> > environments.html#_jetty
> > >> > >>>>> should be all you need for weld in jetty.
> > >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> > >> > deven.phillips@gmail.com
> > >> > >>>>> >
> > >> > >>>>> wrote:
> > >> > >>>>>
> > >> > >>>>> > Hi all,
> > >> > >>>>> >
> > >> > >>>>> >
> > >> > >>>>> >     I'm trying really hard to figure out how to make
> > >> > DeltaSpike/Weld
> > >> > >>>>> work
> > >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to
> load,
> > >> but
> > >> > I
> > >> > >>>>> cannot
> > >> > >>>>> > get any of the dependencies to be injected... My goal is to
> > >> replace
> > >> > >>>>> > Google's Guice DI framework so that I can achieve better
> test
> > >> > >>>>> coverage and
> > >> > >>>>> > decoupling... I'm having a very hard time finding any
> > >> documentation
> > >> > >>>>> for
> > >> > >>>>> > wiring this up..
> > >> > >>>>> >
> > >> > >>>>> > Any help would be appreciated!
> > >> > >>>>> >
> > >> > >>>>> > Deven
> > >> > >>>>> >
> > >> > >>>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >>>
> > >> > >>
> > >> > >
> > >> >
> > >>
> > >
> > >
> >
>
>
>
> --
> Jason Porter
> http://en.gravatar.com/lightguardjp
>

Re: Jetty/Jersey/Injection

Posted by Jason Porter <li...@gmail.com>.
Maybe I missed something, but why are you going through all the trouble of
starting the server and setting everything up manually? I still don't see
any JAX-RS config or JAX-RS Application class.

On Fri, Nov 21, 2014 at 11:30 AM, Deven Phillips <de...@gmail.com>
wrote:

> I see what happened... I meant to create a separate branch for a WeldSE
> implementation and failed.. Checkout the tag 'deltaspike'
>
> Deven
>
> On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <de...@gmail.com>
> wrote:
>
> > John,
> >
> >     Have a look at com.zanclus.example.api.GetServerTime
> >
> > Deven
> >
> > On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <jo...@gmail.com>
> > wrote:
> >
> >> Deven,
> >>
> >> Looks like there's no JAX-RS resources in this project...
> >>
> >> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
> >> deven.phillips@gmail.com>
> >> wrote:
> >>
> >> > I finally got around to trying to put together an example project
> which
> >> I
> >> > could share publicly...
> >> >
> >> > https://github.com/InfoSec812/JettyJerseyWeldExample
> >> >
> >> > I'm hoping I can figure out how to get DeltaSpike/Weld to work
> injecting
> >> > dependencies into my JAX-RS POJOs...
> >> >
> >> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> >> deven.phillips@gmail.com>
> >> > wrote:
> >> >
> >> > > Creating the ServletContextHandler now looks like:
> >> > >
> >> > >         ServletContextHandler handler = new ServletContextHandler();
> >> > >         handler.setContextPath("/");
> >> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> >> > > EnumSet.allOf(DispatcherType.class));
> >> > >         handler.addEventListener(new BeanManagerResourceBindingList
> >> > ener());
> >> > >         handler.addEventListener(new CdiServletRequestListener());
> >> > >         handler.addServlet(new ServletHolder(new
> ServletContainer(new
> >> > > PackagesResourceConfig(config.restPackage()))), "/*");
> >> > >
> >> > >
> >> > > And the exception is an NPE in one of my JAX-RS POJOs where it tries
> >> to
> >> > > access a supposedly injected resource.
> >> > >
> >> > > DEven
> >> > >
> >> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> >> > deven.phillips@gmail.com>
> >> > > wrote:
> >> > >
> >> > >> OK, the @Target exception was a classpath problem and I have
> resolved
> >> > it,
> >> > >> but I am still getting NullPointerExceptions because nothing is
> >> getting
> >> > >> injected into my JAX-RS classes...
> >> > >>
> >> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> >> > deven.phillips@gmail.com
> >> > >> > wrote:
> >> > >>
> >> > >>> So, I just tried this:
> >> > >>>
> >> > >>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas",
> >> > "/");
> >> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> >> > >>> EnumSet.allOf(DispatcherType.class));
> >> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
> >> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> >> > >>>     ctx.addEventListener(new
> BeanManagerResourceBindingListener());
> >> > >>>
> >> > >>> and I got the following Exceptions:
> >> > >>>
> >> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> >> > org.jboss.weld.Reflection:82
> >> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
> >> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
> >> annotation,
> >> > >>> however this may make the application unportable.
> >> > >>>     Exception in thread "main"
> >> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List
> with 1
> >> > >>> exceptions:
> >> > >>>     Exception 0 :
> >> > >>>     javax.enterprise.event.ObserverException
> >> > >>>     at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >> > >>> Method)
> >> > >>>     at
> >> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> >> > NativeConstructorAccessorImpl.java:57)
> >> > >>>     at
> >> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> >> > DelegatingConstructorAccessorImpl.java:45)
> >> > >>>     at
> >> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> >> > >>>     at java.lang.Class.newInstance(Class.java:379)
> >> > >>>     at
> >> > >>> org.jboss.weld.security.NewInstanceAction.run(
> >> > NewInstanceAction.java:33)
> >> > >>>     at java.security.AccessController.doPrivileged(Native Method)
> >> > >>>     at
> >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> >> > Exceptions.java:40)
> >> > >>>     at
> >> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> >> > Exceptions.java:78)
> >> > >>>     at
> >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >> > ObserverMethodImpl.java:271)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> >> > ExtensionObserverMethodImpl.java:121)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> >> > ObserverMethodImpl.java:258)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> >> > ObserverMethodImpl.java:237)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> >> > ObserverNotifier.java:174)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> >> > ObserverNotifier.java:133)
> >> > >>>     at
> >> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> >> > ObserverNotifier.java:107)
> >> > >>>     at
> >> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> >> > fire(AbstractContainerEvent.java:54)
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >> > AbstractDefinitionContainerEvent.java:42)
> >> > >>>     at
> >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> >> > fire(AfterBeanDiscoveryImpl.java:59)
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >> > >>>     at
> >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >> > WeldBootstrap.java:83)
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >> > ForwardingBootstrap.java:63)
> >> > >>>     at
> org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >> > >>>     at
> >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >> > boot(WeldContainerControl.java:65)
> >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >> > >>>     Caused by: java.lang.NoSuchMethodError:
> >> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> >> > >>>     at
> >> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> >> > ThreadContext.java:40)
> >> > >>>     at
> >> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> >> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> >> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> > >>>     at
> >> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> >> > NativeMethodAccessorImpl.java:57)
> >> > >>>     at
> >> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> >> > DelegatingMethodAccessorImpl.java:43)
> >> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> >> > >>>     at
> >> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> >> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> >> > >>>     ... 17 more
> >> > >>>
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> >> > AbstractDefinitionContainerEvent.java:44)
> >> > >>>     at
> >> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> >> > fire(AfterBeanDiscoveryImpl.java:59)
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >> > >>>     at
> >> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> >> > WeldBootstrap.java:83)
> >> > >>>     at
> >> > >>>
> >> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> >> > ForwardingBootstrap.java:63)
> >> > >>>     at
> org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >> > >>>     at
> >> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> >> > boot(WeldContainerControl.java:65)
> >> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >> > >>>
> >> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> >> > >>> deven.phillips@gmail.com> wrote:
> >> > >>>
> >> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted
> >> using
> >> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't
> >> see
> >> > how
> >> > >>>> to translate that to embedded Jetty's startup... Normally, I
> would
> >> do
> >> > >>>> something like:
> >> > >>>>
> >> > >>>>     ServletContextHandler ctx = new ServletContextHandler("/");
> >> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> >> > >>>> EnumSet.allOf(DispatcherType.class)
> >> > >>>>     ctx.addServlet(new ServletContainer(new
> >> > >>>> PackagesResourceConfig(restPackage));
> >> > >>>>     ctx.addEventListener(new CdiRequestListener())
> >> > >>>>
> >> > >>>> Where in there would I put in the BeanManager and the
> >> > >>>> ManagerObjectFactory? Or should I follow the lines below that
> where
> >> > they
> >> > >>>> talk about using a listener to automatically bind the
> BeanManager?
> >> > >>>>
> >> > >>>> Thanks in advance!!
> >> > >>>>
> >> > >>>> Deven
> >> > >>>>
> >> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> >> > lightguard.jp@gmail.com
> >> > >>>> > wrote:
> >> > >>>>
> >> > >>>>> Which version of weld?
> >> > >>>>>
> >> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
> >> > environments.html#_jetty
> >> > >>>>> should be all you need for weld in jetty.
> >> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> >> > deven.phillips@gmail.com
> >> > >>>>> >
> >> > >>>>> wrote:
> >> > >>>>>
> >> > >>>>> > Hi all,
> >> > >>>>> >
> >> > >>>>> >
> >> > >>>>> >     I'm trying really hard to figure out how to make
> >> > DeltaSpike/Weld
> >> > >>>>> work
> >> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to load,
> >> but
> >> > I
> >> > >>>>> cannot
> >> > >>>>> > get any of the dependencies to be injected... My goal is to
> >> replace
> >> > >>>>> > Google's Guice DI framework so that I can achieve better test
> >> > >>>>> coverage and
> >> > >>>>> > decoupling... I'm having a very hard time finding any
> >> documentation
> >> > >>>>> for
> >> > >>>>> > wiring this up..
> >> > >>>>> >
> >> > >>>>> > Any help would be appreciated!
> >> > >>>>> >
> >> > >>>>> > Deven
> >> > >>>>> >
> >> > >>>>>
> >> > >>>>
> >> > >>>>
> >> > >>>
> >> > >>
> >> > >
> >> >
> >>
> >
> >
>



-- 
Jason Porter
http://en.gravatar.com/lightguardjp

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
I see what happened... I meant to create a separate branch for a WeldSE
implementation and failed.. Checkout the tag 'deltaspike'

Deven

On Fri, Nov 21, 2014 at 1:27 PM, Deven Phillips <de...@gmail.com>
wrote:

> John,
>
>     Have a look at com.zanclus.example.api.GetServerTime
>
> Deven
>
> On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <jo...@gmail.com>
> wrote:
>
>> Deven,
>>
>> Looks like there's no JAX-RS resources in this project...
>>
>> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <
>> deven.phillips@gmail.com>
>> wrote:
>>
>> > I finally got around to trying to put together an example project which
>> I
>> > could share publicly...
>> >
>> > https://github.com/InfoSec812/JettyJerseyWeldExample
>> >
>> > I'm hoping I can figure out how to get DeltaSpike/Weld to work injecting
>> > dependencies into my JAX-RS POJOs...
>> >
>> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
>> deven.phillips@gmail.com>
>> > wrote:
>> >
>> > > Creating the ServletContextHandler now looks like:
>> > >
>> > >         ServletContextHandler handler = new ServletContextHandler();
>> > >         handler.setContextPath("/");
>> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
>> > > EnumSet.allOf(DispatcherType.class));
>> > >         handler.addEventListener(new BeanManagerResourceBindingList
>> > ener());
>> > >         handler.addEventListener(new CdiServletRequestListener());
>> > >         handler.addServlet(new ServletHolder(new ServletContainer(new
>> > > PackagesResourceConfig(config.restPackage()))), "/*");
>> > >
>> > >
>> > > And the exception is an NPE in one of my JAX-RS POJOs where it tries
>> to
>> > > access a supposedly injected resource.
>> > >
>> > > DEven
>> > >
>> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
>> > deven.phillips@gmail.com>
>> > > wrote:
>> > >
>> > >> OK, the @Target exception was a classpath problem and I have resolved
>> > it,
>> > >> but I am still getting NullPointerExceptions because nothing is
>> getting
>> > >> injected into my JAX-RS classes...
>> > >>
>> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
>> > deven.phillips@gmail.com
>> > >> > wrote:
>> > >>
>> > >>> So, I just tried this:
>> > >>>
>> > >>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas",
>> > "/");
>> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>> > >>> EnumSet.allOf(DispatcherType.class));
>> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
>> > >>>     ctx.addEventListener(new BeanManagerResourceBindingListener());
>> > >>>
>> > >>> and I got the following Exceptions:
>> > >>>
>> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
>> > org.jboss.weld.Reflection:82
>> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
>> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
>> annotation,
>> > >>> however this may make the application unportable.
>> > >>>     Exception in thread "main"
>> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
>> > >>> exceptions:
>> > >>>     Exception 0 :
>> > >>>     javax.enterprise.event.ObserverException
>> > >>>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> > >>> Method)
>> > >>>     at
>> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
>> > NativeConstructorAccessorImpl.java:57)
>> > >>>     at
>> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>> > DelegatingConstructorAccessorImpl.java:45)
>> > >>>     at
>> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>> > >>>     at java.lang.Class.newInstance(Class.java:379)
>> > >>>     at
>> > >>> org.jboss.weld.security.NewInstanceAction.run(
>> > NewInstanceAction.java:33)
>> > >>>     at java.security.AccessController.doPrivileged(Native Method)
>> > >>>     at
>> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > Exceptions.java:40)
>> > >>>     at
>> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
>> > Exceptions.java:78)
>> > >>>     at
>> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > ObserverMethodImpl.java:271)
>> > >>>     at
>> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
>> > ExtensionObserverMethodImpl.java:121)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
>> > ObserverMethodImpl.java:258)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
>> > ObserverMethodImpl.java:237)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
>> > ObserverNotifier.java:174)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
>> > ObserverNotifier.java:133)
>> > >>>     at
>> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
>> > ObserverNotifier.java:107)
>> > >>>     at
>> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
>> > fire(AbstractContainerEvent.java:54)
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > AbstractDefinitionContainerEvent.java:42)
>> > >>>     at
>> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> > fire(AfterBeanDiscoveryImpl.java:59)
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > >>>     at
>> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > WeldBootstrap.java:83)
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > ForwardingBootstrap.java:63)
>> > >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > >>>     at
>> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > boot(WeldContainerControl.java:65)
>> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> > >>>     Caused by: java.lang.NoSuchMethodError:
>> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>> > >>>     at
>> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
>> > ThreadContext.java:40)
>> > >>>     at
>> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
>> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > >>>     at
>> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
>> > NativeMethodAccessorImpl.java:57)
>> > >>>     at
>> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> > DelegatingMethodAccessorImpl.java:43)
>> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
>> > >>>     at
>> > >>> org.jboss.weld.injection.MethodInjectionPoint.
>> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>> > >>>     ... 17 more
>> > >>>
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
>> > AbstractDefinitionContainerEvent.java:44)
>> > >>>     at
>> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
>> > fire(AfterBeanDiscoveryImpl.java:59)
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>> > >>>     at
>> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
>> > WeldBootstrap.java:83)
>> > >>>     at
>> > >>>
>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
>> > ForwardingBootstrap.java:63)
>> > >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>> > >>>     at
>> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
>> > boot(WeldContainerControl.java:65)
>> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>> > >>>
>> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>> > >>> deven.phillips@gmail.com> wrote:
>> > >>>
>> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted
>> using
>> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't
>> see
>> > how
>> > >>>> to translate that to embedded Jetty's startup... Normally, I would
>> do
>> > >>>> something like:
>> > >>>>
>> > >>>>     ServletContextHandler ctx = new ServletContextHandler("/");
>> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
>> > >>>> EnumSet.allOf(DispatcherType.class)
>> > >>>>     ctx.addServlet(new ServletContainer(new
>> > >>>> PackagesResourceConfig(restPackage));
>> > >>>>     ctx.addEventListener(new CdiRequestListener())
>> > >>>>
>> > >>>> Where in there would I put in the BeanManager and the
>> > >>>> ManagerObjectFactory? Or should I follow the lines below that where
>> > they
>> > >>>> talk about using a listener to automatically bind the BeanManager?
>> > >>>>
>> > >>>> Thanks in advance!!
>> > >>>>
>> > >>>> Deven
>> > >>>>
>> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
>> > lightguard.jp@gmail.com
>> > >>>> > wrote:
>> > >>>>
>> > >>>>> Which version of weld?
>> > >>>>>
>> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
>> > environments.html#_jetty
>> > >>>>> should be all you need for weld in jetty.
>> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
>> > deven.phillips@gmail.com
>> > >>>>> >
>> > >>>>> wrote:
>> > >>>>>
>> > >>>>> > Hi all,
>> > >>>>> >
>> > >>>>> >
>> > >>>>> >     I'm trying really hard to figure out how to make
>> > DeltaSpike/Weld
>> > >>>>> work
>> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to load,
>> but
>> > I
>> > >>>>> cannot
>> > >>>>> > get any of the dependencies to be injected... My goal is to
>> replace
>> > >>>>> > Google's Guice DI framework so that I can achieve better test
>> > >>>>> coverage and
>> > >>>>> > decoupling... I'm having a very hard time finding any
>> documentation
>> > >>>>> for
>> > >>>>> > wiring this up..
>> > >>>>> >
>> > >>>>> > Any help would be appreciated!
>> > >>>>> >
>> > >>>>> > Deven
>> > >>>>> >
>> > >>>>>
>> > >>>>
>> > >>>>
>> > >>>
>> > >>
>> > >
>> >
>>
>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
John,

    Have a look at com.zanclus.example.api.GetServerTime

Deven

On Fri, Nov 21, 2014 at 11:41 AM, John D. Ament <jo...@gmail.com>
wrote:

> Deven,
>
> Looks like there's no JAX-RS resources in this project...
>
> On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <deven.phillips@gmail.com
> >
> wrote:
>
> > I finally got around to trying to put together an example project which I
> > could share publicly...
> >
> > https://github.com/InfoSec812/JettyJerseyWeldExample
> >
> > I'm hoping I can figure out how to get DeltaSpike/Weld to work injecting
> > dependencies into my JAX-RS POJOs...
> >
> > On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <
> deven.phillips@gmail.com>
> > wrote:
> >
> > > Creating the ServletContextHandler now looks like:
> > >
> > >         ServletContextHandler handler = new ServletContextHandler();
> > >         handler.setContextPath("/");
> > >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > > EnumSet.allOf(DispatcherType.class));
> > >         handler.addEventListener(new BeanManagerResourceBindingList
> > ener());
> > >         handler.addEventListener(new CdiServletRequestListener());
> > >         handler.addServlet(new ServletHolder(new ServletContainer(new
> > > PackagesResourceConfig(config.restPackage()))), "/*");
> > >
> > >
> > > And the exception is an NPE in one of my JAX-RS POJOs where it tries to
> > > access a supposedly injected resource.
> > >
> > > DEven
> > >
> > > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> > deven.phillips@gmail.com>
> > > wrote:
> > >
> > >> OK, the @Target exception was a classpath problem and I have resolved
> > it,
> > >> but I am still getting NullPointerExceptions because nothing is
> getting
> > >> injected into my JAX-RS classes...
> > >>
> > >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> > deven.phillips@gmail.com
> > >> > wrote:
> > >>
> > >>> So, I just tried this:
> > >>>
> > >>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas",
> > "/");
> > >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> > >>> EnumSet.allOf(DispatcherType.class));
> > >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
> > >>> PackagesResourceConfig(config.restPackage()))), "/*");
> > >>>     ctx.addEventListener(new BeanManagerResourceBindingListener());
> > >>>
> > >>> and I got the following Exceptions:
> > >>>
> > >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> > org.jboss.weld.Reflection:82
> > >>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
> > >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this
> annotation,
> > >>> however this may make the application unportable.
> > >>>     Exception in thread "main"
> > >>> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
> > >>> exceptions:
> > >>>     Exception 0 :
> > >>>     javax.enterprise.event.ObserverException
> > >>>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > >>> Method)
> > >>>     at
> > >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > NativeConstructorAccessorImpl.java:57)
> > >>>     at
> > >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > DelegatingConstructorAccessorImpl.java:45)
> > >>>     at
> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> > >>>     at java.lang.Class.newInstance(Class.java:379)
> > >>>     at
> > >>> org.jboss.weld.security.NewInstanceAction.run(
> > NewInstanceAction.java:33)
> > >>>     at java.security.AccessController.doPrivileged(Native Method)
> > >>>     at
> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > Exceptions.java:40)
> > >>>     at
> > >>> org.jboss.weld.injection.Exceptions.rethrowException(
> > Exceptions.java:78)
> > >>>     at
> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > ObserverMethodImpl.java:271)
> > >>>     at
> > >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> > ExtensionObserverMethodImpl.java:121)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> > ObserverMethodImpl.java:258)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> > ObserverMethodImpl.java:237)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> > ObserverNotifier.java:174)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> > ObserverNotifier.java:133)
> > >>>     at
> > >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> > ObserverNotifier.java:107)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> > fire(AbstractContainerEvent.java:54)
> > >>>     at
> > >>>
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > AbstractDefinitionContainerEvent.java:42)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > fire(AfterBeanDiscoveryImpl.java:59)
> > >>>     at
> > >>>
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > WeldBootstrap.java:83)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > ForwardingBootstrap.java:63)
> > >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >>>     at
> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > boot(WeldContainerControl.java:65)
> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >>>     Caused by: java.lang.NoSuchMethodError:
> > >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> > >>>     at
> > >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> > ThreadContext.java:40)
> > >>>     at
> > >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> > registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> > >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >>>     at
> > >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:57)
> > >>>     at
> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:43)
> > >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> > >>>     at
> > >>> org.jboss.weld.injection.MethodInjectionPoint.
> > invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> > >>>     ... 17 more
> > >>>
> > >>>     at
> > >>>
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> > AbstractDefinitionContainerEvent.java:44)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> > fire(AfterBeanDiscoveryImpl.java:59)
> > >>>     at
> > >>>
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> > WeldBootstrap.java:83)
> > >>>     at
> > >>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> > ForwardingBootstrap.java:63)
> > >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> > >>>     at
> > >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> > boot(WeldContainerControl.java:65)
> > >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> > >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> > >>>
> > >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> > >>> deven.phillips@gmail.com> wrote:
> > >>>
> > >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted
> using
> > >>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't
> see
> > how
> > >>>> to translate that to embedded Jetty's startup... Normally, I would
> do
> > >>>> something like:
> > >>>>
> > >>>>     ServletContextHandler ctx = new ServletContextHandler("/");
> > >>>>     ctx.addFilter(AuthFilter.class, "/*",
> > >>>> EnumSet.allOf(DispatcherType.class)
> > >>>>     ctx.addServlet(new ServletContainer(new
> > >>>> PackagesResourceConfig(restPackage));
> > >>>>     ctx.addEventListener(new CdiRequestListener())
> > >>>>
> > >>>> Where in there would I put in the BeanManager and the
> > >>>> ManagerObjectFactory? Or should I follow the lines below that where
> > they
> > >>>> talk about using a listener to automatically bind the BeanManager?
> > >>>>
> > >>>> Thanks in advance!!
> > >>>>
> > >>>> Deven
> > >>>>
> > >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> > lightguard.jp@gmail.com
> > >>>> > wrote:
> > >>>>
> > >>>>> Which version of weld?
> > >>>>>
> > >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
> > environments.html#_jetty
> > >>>>> should be all you need for weld in jetty.
> > >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> > deven.phillips@gmail.com
> > >>>>> >
> > >>>>> wrote:
> > >>>>>
> > >>>>> > Hi all,
> > >>>>> >
> > >>>>> >
> > >>>>> >     I'm trying really hard to figure out how to make
> > DeltaSpike/Weld
> > >>>>> work
> > >>>>> > with Jetty and Jersey... I can get the Jersey servlet to load,
> but
> > I
> > >>>>> cannot
> > >>>>> > get any of the dependencies to be injected... My goal is to
> replace
> > >>>>> > Google's Guice DI framework so that I can achieve better test
> > >>>>> coverage and
> > >>>>> > decoupling... I'm having a very hard time finding any
> documentation
> > >>>>> for
> > >>>>> > wiring this up..
> > >>>>> >
> > >>>>> > Any help would be appreciated!
> > >>>>> >
> > >>>>> > Deven
> > >>>>> >
> > >>>>>
> > >>>>
> > >>>>
> > >>>
> > >>
> > >
> >
>

Re: Jetty/Jersey/Injection

Posted by "John D. Ament" <jo...@gmail.com>.
Deven,

Looks like there's no JAX-RS resources in this project...

On Fri Nov 21 2014 at 10:08:34 AM Deven Phillips <de...@gmail.com>
wrote:

> I finally got around to trying to put together an example project which I
> could share publicly...
>
> https://github.com/InfoSec812/JettyJerseyWeldExample
>
> I'm hoping I can figure out how to get DeltaSpike/Weld to work injecting
> dependencies into my JAX-RS POJOs...
>
> On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <de...@gmail.com>
> wrote:
>
> > Creating the ServletContextHandler now looks like:
> >
> >         ServletContextHandler handler = new ServletContextHandler();
> >         handler.setContextPath("/");
> >         handler.addFilter(ProxyAuthFilter.class, "/*",
> > EnumSet.allOf(DispatcherType.class));
> >         handler.addEventListener(new BeanManagerResourceBindingList
> ener());
> >         handler.addEventListener(new CdiServletRequestListener());
> >         handler.addServlet(new ServletHolder(new ServletContainer(new
> > PackagesResourceConfig(config.restPackage()))), "/*");
> >
> >
> > And the exception is an NPE in one of my JAX-RS POJOs where it tries to
> > access a supposedly injected resource.
> >
> > DEven
> >
> > On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <
> deven.phillips@gmail.com>
> > wrote:
> >
> >> OK, the @Target exception was a classpath problem and I have resolved
> it,
> >> but I am still getting NullPointerExceptions because nothing is getting
> >> injected into my JAX-RS classes...
> >>
> >> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <
> deven.phillips@gmail.com
> >> > wrote:
> >>
> >>> So, I just tried this:
> >>>
> >>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas",
> "/");
> >>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> >>> EnumSet.allOf(DispatcherType.class));
> >>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
> >>> PackagesResourceConfig(config.restPackage()))), "/*");
> >>>     ctx.addEventListener(new BeanManagerResourceBindingListener());
> >>>
> >>> and I got the following Exceptions:
> >>>
> >>>     [DEBUG] 2014-11-17 09:25:44,821 [main]
> org.jboss.weld.Reflection:82
> >>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
> >>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation,
> >>> however this may make the application unportable.
> >>>     Exception in thread "main"
> >>> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
> >>> exceptions:
> >>>     Exception 0 :
> >>>     javax.enterprise.event.ObserverException
> >>>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >>> Method)
> >>>     at
> >>> sun.reflect.NativeConstructorAccessorImpl.newInstance(
> NativeConstructorAccessorImpl.java:57)
> >>>     at
> >>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> DelegatingConstructorAccessorImpl.java:45)
> >>>     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> >>>     at java.lang.Class.newInstance(Class.java:379)
> >>>     at
> >>> org.jboss.weld.security.NewInstanceAction.run(
> NewInstanceAction.java:33)
> >>>     at java.security.AccessController.doPrivileged(Native Method)
> >>>     at
> >>> org.jboss.weld.injection.Exceptions.rethrowException(
> Exceptions.java:40)
> >>>     at
> >>> org.jboss.weld.injection.Exceptions.rethrowException(
> Exceptions.java:78)
> >>>     at
> >>> org.jboss.weld.injection.MethodInjectionPoint.
> invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
> >>>     at
> >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> ObserverMethodImpl.java:271)
> >>>     at
> >>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
> ExtensionObserverMethodImpl.java:121)
> >>>     at
> >>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(
> ObserverMethodImpl.java:258)
> >>>     at
> >>> org.jboss.weld.event.ObserverMethodImpl.notify(
> ObserverMethodImpl.java:237)
> >>>     at
> >>> org.jboss.weld.event.ObserverNotifier.notifyObserver(
> ObserverNotifier.java:174)
> >>>     at
> >>> org.jboss.weld.event.ObserverNotifier.notifyObservers(
> ObserverNotifier.java:133)
> >>>     at
> >>> org.jboss.weld.event.ObserverNotifier.fireEvent(
> ObserverNotifier.java:107)
> >>>     at
> >>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.
> fire(AbstractContainerEvent.java:54)
> >>>     at
> >>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> AbstractDefinitionContainerEvent.java:42)
> >>>     at
> >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> fire(AfterBeanDiscoveryImpl.java:59)
> >>>     at
> >>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>>     at
> >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> WeldBootstrap.java:83)
> >>>     at
> >>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> ForwardingBootstrap.java:63)
> >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>>     at
> >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> boot(WeldContainerControl.java:65)
> >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >>>     Caused by: java.lang.NoSuchMethodError:
> >>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
> >>>     at
> >>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(
> ThreadContext.java:40)
> >>>     at
> >>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.
> registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
> >>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>>     at
> >>> sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:57)
> >>>     at
> >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
> >>>     at java.lang.reflect.Method.invoke(Method.java:606)
> >>>     at
> >>> org.jboss.weld.injection.MethodInjectionPoint.
> invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
> >>>     ... 17 more
> >>>
> >>>     at
> >>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(
> AbstractDefinitionContainerEvent.java:44)
> >>>     at
> >>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.
> fire(AfterBeanDiscoveryImpl.java:59)
> >>>     at
> >>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
> >>>     at
> >>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
> WeldBootstrap.java:83)
> >>>     at
> >>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(
> ForwardingBootstrap.java:63)
> >>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
> >>>     at
> >>> org.apache.deltaspike.cdise.weld.WeldContainerControl.
> boot(WeldContainerControl.java:65)
> >>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
> >>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
> >>>
> >>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
> >>> deven.phillips@gmail.com> wrote:
> >>>
> >>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
> >>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't see
> how
> >>>> to translate that to embedded Jetty's startup... Normally, I would do
> >>>> something like:
> >>>>
> >>>>     ServletContextHandler ctx = new ServletContextHandler("/");
> >>>>     ctx.addFilter(AuthFilter.class, "/*",
> >>>> EnumSet.allOf(DispatcherType.class)
> >>>>     ctx.addServlet(new ServletContainer(new
> >>>> PackagesResourceConfig(restPackage));
> >>>>     ctx.addEventListener(new CdiRequestListener())
> >>>>
> >>>> Where in there would I put in the BeanManager and the
> >>>> ManagerObjectFactory? Or should I follow the lines below that where
> they
> >>>> talk about using a listener to automatically bind the BeanManager?
> >>>>
> >>>> Thanks in advance!!
> >>>>
> >>>> Deven
> >>>>
> >>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <
> lightguard.jp@gmail.com
> >>>> > wrote:
> >>>>
> >>>>> Which version of weld?
> >>>>>
> >>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/
> environments.html#_jetty
> >>>>> should be all you need for weld in jetty.
> >>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <
> deven.phillips@gmail.com
> >>>>> >
> >>>>> wrote:
> >>>>>
> >>>>> > Hi all,
> >>>>> >
> >>>>> >
> >>>>> >     I'm trying really hard to figure out how to make
> DeltaSpike/Weld
> >>>>> work
> >>>>> > with Jetty and Jersey... I can get the Jersey servlet to load, but
> I
> >>>>> cannot
> >>>>> > get any of the dependencies to be injected... My goal is to replace
> >>>>> > Google's Guice DI framework so that I can achieve better test
> >>>>> coverage and
> >>>>> > decoupling... I'm having a very hard time finding any documentation
> >>>>> for
> >>>>> > wiring this up..
> >>>>> >
> >>>>> > Any help would be appreciated!
> >>>>> >
> >>>>> > Deven
> >>>>> >
> >>>>>
> >>>>
> >>>>
> >>>
> >>
> >
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
I finally got around to trying to put together an example project which I
could share publicly...

https://github.com/InfoSec812/JettyJerseyWeldExample

I'm hoping I can figure out how to get DeltaSpike/Weld to work injecting
dependencies into my JAX-RS POJOs...

On Mon, Nov 17, 2014 at 9:58 AM, Deven Phillips <de...@gmail.com>
wrote:

> Creating the ServletContextHandler now looks like:
>
>         ServletContextHandler handler = new ServletContextHandler();
>         handler.setContextPath("/");
>         handler.addFilter(ProxyAuthFilter.class, "/*",
> EnumSet.allOf(DispatcherType.class));
>         handler.addEventListener(new BeanManagerResourceBindingListener());
>         handler.addEventListener(new CdiServletRequestListener());
>         handler.addServlet(new ServletHolder(new ServletContainer(new
> PackagesResourceConfig(config.restPackage()))), "/*");
>
>
> And the exception is an NPE in one of my JAX-RS POJOs where it tries to
> access a supposedly injected resource.
>
> DEven
>
> On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> OK, the @Target exception was a classpath problem and I have resolved it,
>> but I am still getting NullPointerExceptions because nothing is getting
>> injected into my JAX-RS classes...
>>
>> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <deven.phillips@gmail.com
>> > wrote:
>>
>>> So, I just tried this:
>>>
>>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas", "/");
>>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>>> EnumSet.allOf(DispatcherType.class));
>>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>>> PackagesResourceConfig(config.restPackage()))), "/*");
>>>     ctx.addEventListener(new BeanManagerResourceBindingListener());
>>>
>>> and I got the following Exceptions:
>>>
>>>     [DEBUG] 2014-11-17 09:25:44,821 [main]  org.jboss.weld.Reflection:82
>>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
>>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation,
>>> however this may make the application unportable.
>>>     Exception in thread "main"
>>> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
>>> exceptions:
>>>     Exception 0 :
>>>     javax.enterprise.event.ObserverException
>>>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>>     at
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>>>     at
>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>>     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>     at java.lang.Class.newInstance(Class.java:379)
>>>     at
>>> org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
>>>     at java.security.AccessController.doPrivileged(Native Method)
>>>     at
>>> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
>>>     at
>>> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
>>>     at
>>> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>>>     at
>>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
>>>     at
>>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
>>>     at
>>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
>>>     at
>>> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
>>>     at
>>> org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
>>>     at
>>> org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
>>>     at
>>> org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
>>>     at
>>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
>>>     at
>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:42)
>>>     at
>>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>>>     at
>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>>     at
>>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>>>     at
>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>>     at
>>> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>>     Caused by: java.lang.NoSuchMethodError:
>>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>>>     at
>>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(ThreadContext.java:40)
>>>     at
>>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>     at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>     at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>     at java.lang.reflect.Method.invoke(Method.java:606)
>>>     at
>>> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>>>     ... 17 more
>>>
>>>     at
>>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
>>>     at
>>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>>>     at
>>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>>     at
>>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>>>     at
>>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>>     at
>>> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>>
>>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <
>>> deven.phillips@gmail.com> wrote:
>>>
>>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
>>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't see how
>>>> to translate that to embedded Jetty's startup... Normally, I would do
>>>> something like:
>>>>
>>>>     ServletContextHandler ctx = new ServletContextHandler("/");
>>>>     ctx.addFilter(AuthFilter.class, "/*",
>>>> EnumSet.allOf(DispatcherType.class)
>>>>     ctx.addServlet(new ServletContainer(new
>>>> PackagesResourceConfig(restPackage));
>>>>     ctx.addEventListener(new CdiRequestListener())
>>>>
>>>> Where in there would I put in the BeanManager and the
>>>> ManagerObjectFactory? Or should I follow the lines below that where they
>>>> talk about using a listener to automatically bind the BeanManager?
>>>>
>>>> Thanks in advance!!
>>>>
>>>> Deven
>>>>
>>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <lightguard.jp@gmail.com
>>>> > wrote:
>>>>
>>>>> Which version of weld?
>>>>>
>>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
>>>>> should be all you need for weld in jetty.
>>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <deven.phillips@gmail.com
>>>>> >
>>>>> wrote:
>>>>>
>>>>> > Hi all,
>>>>> >
>>>>> >
>>>>> >     I'm trying really hard to figure out how to make DeltaSpike/Weld
>>>>> work
>>>>> > with Jetty and Jersey... I can get the Jersey servlet to load, but I
>>>>> cannot
>>>>> > get any of the dependencies to be injected... My goal is to replace
>>>>> > Google's Guice DI framework so that I can achieve better test
>>>>> coverage and
>>>>> > decoupling... I'm having a very hard time finding any documentation
>>>>> for
>>>>> > wiring this up..
>>>>> >
>>>>> > Any help would be appreciated!
>>>>> >
>>>>> > Deven
>>>>> >
>>>>>
>>>>
>>>>
>>>
>>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
Creating the ServletContextHandler now looks like:

        ServletContextHandler handler = new ServletContextHandler();
        handler.setContextPath("/");
        handler.addFilter(ProxyAuthFilter.class, "/*",
EnumSet.allOf(DispatcherType.class));
        handler.addEventListener(new BeanManagerResourceBindingListener());
        handler.addEventListener(new CdiServletRequestListener());
        handler.addServlet(new ServletHolder(new ServletContainer(new
PackagesResourceConfig(config.restPackage()))), "/*");


And the exception is an NPE in one of my JAX-RS POJOs where it tries to
access a supposedly injected resource.

DEven

On Mon, Nov 17, 2014 at 9:54 AM, Deven Phillips <de...@gmail.com>
wrote:

> OK, the @Target exception was a classpath problem and I have resolved it,
> but I am still getting NullPointerExceptions because nothing is getting
> injected into my JAX-RS classes...
>
> On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> So, I just tried this:
>>
>>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas", "/");
>>     ctx.addFilter(ProxyAuthFilter.class, "/*",
>> EnumSet.allOf(DispatcherType.class));
>>     ctx.addServlet(new ServletHolder(new ServletContainer(new
>> PackagesResourceConfig(config.restPackage()))), "/*");
>>     ctx.addEventListener(new BeanManagerResourceBindingListener());
>>
>> and I got the following Exceptions:
>>
>>     [DEBUG] 2014-11-17 09:25:44,821 [main]  org.jboss.weld.Reflection:82
>> - WELD-000620: interface javax.ws.rs.core.Context is not declared
>> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation,
>> however this may make the application unportable.
>>     Exception in thread "main"
>> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
>> exceptions:
>>     Exception 0 :
>>     javax.enterprise.event.ObserverException
>>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>     at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>>     at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>     at java.lang.Class.newInstance(Class.java:379)
>>     at
>> org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
>>     at java.security.AccessController.doPrivileged(Native Method)
>>     at
>> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
>>     at
>> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
>>     at
>> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>>     at
>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
>>     at
>> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
>>     at
>> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
>>     at
>> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
>>     at
>> org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
>>     at
>> org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
>>     at
>> org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
>>     at
>> org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
>>     at
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:42)
>>     at
>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>>     at
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>     at
>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>>     at
>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>     at
>> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>     Caused by: java.lang.NoSuchMethodError:
>> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>>     at
>> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(ThreadContext.java:40)
>>     at
>> org.jboss.weld.environment.se.WeldSEBeanRegistrant.registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>     at java.lang.reflect.Method.invoke(Method.java:606)
>>     at
>> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>>     ... 17 more
>>
>>     at
>> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
>>     at
>> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>>     at
>> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>>     at
>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>>     at
>> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>>     at
>> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>>
>> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <deven.phillips@gmail.com
>> > wrote:
>>
>>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
>>> DeltaSpike 1.0.2... I have seen that linked document, but I don't see how
>>> to translate that to embedded Jetty's startup... Normally, I would do
>>> something like:
>>>
>>>     ServletContextHandler ctx = new ServletContextHandler("/");
>>>     ctx.addFilter(AuthFilter.class, "/*",
>>> EnumSet.allOf(DispatcherType.class)
>>>     ctx.addServlet(new ServletContainer(new
>>> PackagesResourceConfig(restPackage));
>>>     ctx.addEventListener(new CdiRequestListener())
>>>
>>> Where in there would I put in the BeanManager and the
>>> ManagerObjectFactory? Or should I follow the lines below that where they
>>> talk about using a listener to automatically bind the BeanManager?
>>>
>>> Thanks in advance!!
>>>
>>> Deven
>>>
>>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <li...@gmail.com>
>>> wrote:
>>>
>>>> Which version of weld?
>>>>
>>>> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
>>>> should be all you need for weld in jetty.
>>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
>>>> wrote:
>>>>
>>>> > Hi all,
>>>> >
>>>> >
>>>> >     I'm trying really hard to figure out how to make DeltaSpike/Weld
>>>> work
>>>> > with Jetty and Jersey... I can get the Jersey servlet to load, but I
>>>> cannot
>>>> > get any of the dependencies to be injected... My goal is to replace
>>>> > Google's Guice DI framework so that I can achieve better test
>>>> coverage and
>>>> > decoupling... I'm having a very hard time finding any documentation
>>>> for
>>>> > wiring this up..
>>>> >
>>>> > Any help would be appreciated!
>>>> >
>>>> > Deven
>>>> >
>>>>
>>>
>>>
>>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
OK, the @Target exception was a classpath problem and I have resolved it,
but I am still getting NullPointerExceptions because nothing is getting
injected into my JAX-RS classes...

On Mon, Nov 17, 2014 at 9:28 AM, Deven Phillips <de...@gmail.com>
wrote:

> So, I just tried this:
>
>     WebAppContext ctx = new WebAppContext("cc-backend-sungardas", "/");
>     ctx.addFilter(ProxyAuthFilter.class, "/*",
> EnumSet.allOf(DispatcherType.class));
>     ctx.addServlet(new ServletHolder(new ServletContainer(new
> PackagesResourceConfig(config.restPackage()))), "/*");
>     ctx.addEventListener(new BeanManagerResourceBindingListener());
>
> and I got the following Exceptions:
>
>     [DEBUG] 2014-11-17 09:25:44,821 [main]  org.jboss.weld.Reflection:82 -
> WELD-000620: interface javax.ws.rs.core.Context is not declared
> @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation,
> however this may make the application unportable.
>     Exception in thread "main"
> org.jboss.weld.exceptions.DefinitionException: Exception List with 1
> exceptions:
>     Exception 0 :
>     javax.enterprise.event.ObserverException
>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>     at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>     at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>     at java.lang.Class.newInstance(Class.java:379)
>     at
> org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at
> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
>     at
> org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
>     at
> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
>     at
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
>     at
> org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
>     at
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
>     at
> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
>     at
> org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
>     at
> org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
>     at
> org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
>     at
> org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
>     at
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:42)
>     at
> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>     at
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>     at
> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>     at
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>     at
> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>     Caused by: java.lang.NoSuchMethodError:
> org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
>     at
> org.jboss.weld.environment.se.contexts.ThreadContext.<init>(ThreadContext.java:40)
>     at
> org.jboss.weld.environment.se.WeldSEBeanRegistrant.registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:606)
>     at
> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
>     ... 17 more
>
>     at
> org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
>     at
> org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
>     at
> org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
>     at
> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
>     at
> org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
>     at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
>     at
> org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
>     at com.sungardas.cc.edison.Main.start(Main.java:171)
>     at com.sungardas.cc.edison.Main.main(Main.java:68)
>
> On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <de...@gmail.com>
> wrote:
>
>> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
>> DeltaSpike 1.0.2... I have seen that linked document, but I don't see how
>> to translate that to embedded Jetty's startup... Normally, I would do
>> something like:
>>
>>     ServletContextHandler ctx = new ServletContextHandler("/");
>>     ctx.addFilter(AuthFilter.class, "/*",
>> EnumSet.allOf(DispatcherType.class)
>>     ctx.addServlet(new ServletContainer(new
>> PackagesResourceConfig(restPackage));
>>     ctx.addEventListener(new CdiRequestListener())
>>
>> Where in there would I put in the BeanManager and the
>> ManagerObjectFactory? Or should I follow the lines below that where they
>> talk about using a listener to automatically bind the BeanManager?
>>
>> Thanks in advance!!
>>
>> Deven
>>
>> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <li...@gmail.com>
>> wrote:
>>
>>> Which version of weld?
>>>
>>> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
>>> should be all you need for weld in jetty.
>>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
>>> wrote:
>>>
>>> > Hi all,
>>> >
>>> >
>>> >     I'm trying really hard to figure out how to make DeltaSpike/Weld
>>> work
>>> > with Jetty and Jersey... I can get the Jersey servlet to load, but I
>>> cannot
>>> > get any of the dependencies to be injected... My goal is to replace
>>> > Google's Guice DI framework so that I can achieve better test coverage
>>> and
>>> > decoupling... I'm having a very hard time finding any documentation for
>>> > wiring this up..
>>> >
>>> > Any help would be appreciated!
>>> >
>>> > Deven
>>> >
>>>
>>
>>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
So, I just tried this:

    WebAppContext ctx = new WebAppContext("cc-backend-sungardas", "/");
    ctx.addFilter(ProxyAuthFilter.class, "/*",
EnumSet.allOf(DispatcherType.class));
    ctx.addServlet(new ServletHolder(new ServletContainer(new
PackagesResourceConfig(config.restPackage()))), "/*");
    ctx.addEventListener(new BeanManagerResourceBindingListener());

and I got the following Exceptions:

    [DEBUG] 2014-11-17 09:25:44,821 [main]  org.jboss.weld.Reflection:82 -
WELD-000620: interface javax.ws.rs.core.Context is not declared
@Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation,
however this may make the application unportable.
    Exception in thread "main"
org.jboss.weld.exceptions.DefinitionException: Exception List with 1
exceptions:
    Exception 0 :
    javax.enterprise.event.ObserverException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at
org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.security.AccessController.doPrivileged(Native Method)
    at
org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
    at
org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
    at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:98)
    at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
    at
org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
    at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
    at
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
    at
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
    at
org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
    at
org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
    at
org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
    at
org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:42)
    at
org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
    at
org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
    at
org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at
org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
    at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
    at
org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
    at com.sungardas.cc.edison.Main.start(Main.java:171)
    at com.sungardas.cc.edison.Main.main(Main.java:68)
    Caused by: java.lang.NoSuchMethodError:
org.jboss.weld.context.AbstractUnboundContext.<init>(Z)V
    at
org.jboss.weld.environment.se.contexts.ThreadContext.<init>(ThreadContext.java:40)
    at
org.jboss.weld.environment.se.WeldSEBeanRegistrant.registerWeldSEContexts(WeldSEBeanRegistrant.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
    ... 17 more

    at
org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
    at
org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:59)
    at
org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:412)
    at
org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at
org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
    at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
    at
org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:65)
    at com.sungardas.cc.edison.Main.start(Main.java:171)
    at com.sungardas.cc.edison.Main.main(Main.java:68)

On Mon, Nov 17, 2014 at 9:09 AM, Deven Phillips <de...@gmail.com>
wrote:

> This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
> DeltaSpike 1.0.2... I have seen that linked document, but I don't see how
> to translate that to embedded Jetty's startup... Normally, I would do
> something like:
>
>     ServletContextHandler ctx = new ServletContextHandler("/");
>     ctx.addFilter(AuthFilter.class, "/*",
> EnumSet.allOf(DispatcherType.class)
>     ctx.addServlet(new ServletContainer(new
> PackagesResourceConfig(restPackage));
>     ctx.addEventListener(new CdiRequestListener())
>
> Where in there would I put in the BeanManager and the
> ManagerObjectFactory? Or should I follow the lines below that where they
> talk about using a listener to automatically bind the BeanManager?
>
> Thanks in advance!!
>
> Deven
>
> On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <li...@gmail.com>
> wrote:
>
>> Which version of weld?
>>
>> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
>> should be all you need for weld in jetty.
>> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
>> wrote:
>>
>> > Hi all,
>> >
>> >
>> >     I'm trying really hard to figure out how to make DeltaSpike/Weld
>> work
>> > with Jetty and Jersey... I can get the Jersey servlet to load, but I
>> cannot
>> > get any of the dependencies to be injected... My goal is to replace
>> > Google's Guice DI framework so that I can achieve better test coverage
>> and
>> > decoupling... I'm having a very hard time finding any documentation for
>> > wiring this up..
>> >
>> > Any help would be appreciated!
>> >
>> > Deven
>> >
>>
>
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
This is embedded Jetty 9.2.x and Weld version 1.1.9.Final booted using
DeltaSpike 1.0.2... I have seen that linked document, but I don't see how
to translate that to embedded Jetty's startup... Normally, I would do
something like:

    ServletContextHandler ctx = new ServletContextHandler("/");
    ctx.addFilter(AuthFilter.class, "/*",
EnumSet.allOf(DispatcherType.class)
    ctx.addServlet(new ServletContainer(new
PackagesResourceConfig(restPackage));
    ctx.addEventListener(new CdiRequestListener())

Where in there would I put in the BeanManager and the ManagerObjectFactory?
Or should I follow the lines below that where they talk about using a
listener to automatically bind the BeanManager?

Thanks in advance!!

Deven

On Sun, Nov 16, 2014 at 10:39 PM, Jason Porter <li...@gmail.com>
wrote:

> Which version of weld?
>
> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
> should be all you need for weld in jetty.
> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
> wrote:
>
> > Hi all,
> >
> >
> >     I'm trying really hard to figure out how to make DeltaSpike/Weld work
> > with Jetty and Jersey... I can get the Jersey servlet to load, but I
> cannot
> > get any of the dependencies to be injected... My goal is to replace
> > Google's Guice DI framework so that I can achieve better test coverage
> and
> > decoupling... I'm having a very hard time finding any documentation for
> > wiring this up..
> >
> > Any help would be appreciated!
> >
> > Deven
> >
>

Re: Jetty/Jersey/Injection

Posted by Deven Phillips <de...@gmail.com>.
Mark,

    I appreciate the suggestion, but I am using "Embedded" Jetty... There
is no web.xml... It's all programmatically configured.

Deven

On Sat, Nov 22, 2014 at 12:20 PM, Mark Struberg <st...@yahoo.de> wrote:

> For OpenWebBeans is equally easy. Just add WebBeansConfigurationListener
> as <listener> in web.xml and you are done.
>
> LieGrue,
> strub
>
>
>
>
>
> > On Monday, 17 November 2014, 4:41, Jason Porter <li...@gmail.com>
> wrote:
> > > Which version of weld?
> >
> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
> > should be all you need for weld in jetty.
> > On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
> > wrote:
> >
> >>  Hi all,
> >>
> >>
> >>      I'm trying really hard to figure out how to make DeltaSpike/Weld
> > work
> >>  with Jetty and Jersey... I can get the Jersey servlet to load, but I
> cannot
> >>  get any of the dependencies to be injected... My goal is to replace
> >>  Google's Guice DI framework so that I can achieve better test coverage
> > and
> >>  decoupling... I'm having a very hard time finding any documentation for
> >>  wiring this up..
> >>
> >>  Any help would be appreciated!
> >>
> >>  Deven
> >>
> >
>

Re: Jetty/Jersey/Injection

Posted by Mark Struberg <st...@yahoo.de>.
For OpenWebBeans is equally easy. Just add WebBeansConfigurationListener as <listener> in web.xml and you are done.

LieGrue,
strub





> On Monday, 17 November 2014, 4:41, Jason Porter <li...@gmail.com> wrote:
> > Which version of weld?
> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
> should be all you need for weld in jetty.
> On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
> wrote:
> 
>>  Hi all,
>> 
>> 
>>      I'm trying really hard to figure out how to make DeltaSpike/Weld 
> work
>>  with Jetty and Jersey... I can get the Jersey servlet to load, but I cannot
>>  get any of the dependencies to be injected... My goal is to replace
>>  Google's Guice DI framework so that I can achieve better test coverage 
> and
>>  decoupling... I'm having a very hard time finding any documentation for
>>  wiring this up..
>> 
>>  Any help would be appreciated!
>> 
>>  Deven
>> 
> 

Re: Jetty/Jersey/Injection

Posted by Jason Porter <li...@gmail.com>.
Which version of weld?
https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
should be all you need for weld in jetty.
On Sun, Nov 16, 2014 at 20:28 Deven Phillips <de...@gmail.com>
wrote:

> Hi all,
>
>
>     I'm trying really hard to figure out how to make DeltaSpike/Weld work
> with Jetty and Jersey... I can get the Jersey servlet to load, but I cannot
> get any of the dependencies to be injected... My goal is to replace
> Google's Guice DI framework so that I can achieve better test coverage and
> decoupling... I'm having a very hard time finding any documentation for
> wiring this up..
>
> Any help would be appreciated!
>
> Deven
>