You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Martin Funk <Ma...@MartinFunk.de> on 2014/02/19 18:36:15 UTC
Context in a Restful Service
Working my way through, "Java Web Services" up and running.
On Page 69 i stumble over a @Context Annotation
[...]
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
@Path("/predict")
public class PredictionsRS {
@Context
private ServletContext sctx; // dependency injection
private static PredictionsList plist; // set in populate()
[...]
the ServletContext sctx doesnt get initialized, on request the Server logs:
... 37 more
Caused by: javax.naming.NameNotFoundException: Name [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
I'm most likely missing something, just not sure what.
Is there some configuration needed for TomEE to pick up the annotated field 'sctx' and inject a ServletContext into it?
mf
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Good point. Provide us with a sample makes it far more easier :)
JLouis
2014-02-19 22:16 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> I boiled my question down to a tiny Eclipse project containing 4 classes
> and published that on github.
>
> https://github.com/mafulafunk/FooJaxRs
>
> Quite happy if someone could put an eye on that.
>
> mf
>
> Am 19.02.2014 um 18:36 schrieb Martin Funk <ma...@martinfunk.de>:
>
> > Working my way through, "Java Web Services" up and running.
> >
> > On Page 69 i stumble over a @Context Annotation
> >
> > [...]
> > import javax.ws.rs.core.Context;
> > import javax.ws.rs.core.MediaType;
> > import javax.ws.rs.core.Response;
> >
> > import com.fasterxml.jackson.databind.ObjectMapper;
> >
> > @Path("/predict")
> > public class PredictionsRS {
> > @Context
> > private ServletContext sctx; // dependency injection
> > private static PredictionsList plist; // set in populate()
> > [...]
> >
> > the ServletContext sctx doesnt get initialized, on request the Server
> logs:
> >
> > ... 37 more
> > Caused by: javax.naming.NameNotFoundException: Name
> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
> this Context. Unable to find [comp].
> > at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> > at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >
> >
> > I'm most likely missing something, just not sure what.
> > Is there some configuration needed for TomEE to pick up the annotated
> field 'sctx' and inject a ServletContext into it?
> >
> > mf
>
>
--
Jean-Louis
Re: Context in a Restful Service
Posted by Martin Funk <Ma...@MartinFunk.de>.
I boiled my question down to a tiny Eclipse project containing 4 classes
and published that on github.
https://github.com/mafulafunk/FooJaxRs
Quite happy if someone could put an eye on that.
mf
Am 19.02.2014 um 18:36 schrieb Martin Funk <ma...@martinfunk.de>:
> Working my way through, "Java Web Services" up and running.
>
> On Page 69 i stumble over a @Context Annotation
>
> [...]
> import javax.ws.rs.core.Context;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
>
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> @Path("/predict")
> public class PredictionsRS {
> @Context
> private ServletContext sctx; // dependency injection
> private static PredictionsList plist; // set in populate()
> [...]
>
> the ServletContext sctx doesnt get initialized, on request the Server logs:
>
> ... 37 more
> Caused by: javax.naming.NameNotFoundException: Name [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in this Context. Unable to find [comp].
> at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>
>
> I'm most likely missing something, just not sure what.
> Is there some configuration needed for TomEE to pick up the annotated field 'sctx' and inject a ServletContext into it?
>
> mf
Re: Context in a Restful Service
Posted by Daniel Cunha <da...@gmail.com>.
Doesn't you need declaring @ApplicationPath in your
de.martinfunk.foo.FooApplication class?
On Thu, Feb 20, 2014 at 11:38 AM, Jean-Louis MONTEIRO <je...@gmail.com>wrote:
> One note: which tomee version?
>
>
>
> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>
> > Working my way through, "Java Web Services" up and running.
> >
> > On Page 69 i stumble over a @Context Annotation
> >
> > [...]
> > import javax.ws.rs.core.Context;
> > import javax.ws.rs.core.MediaType;
> > import javax.ws.rs.core.Response;
> >
> > import com.fasterxml.jackson.databind.ObjectMapper;
> >
> > @Path("/predict")
> > public class PredictionsRS {
> > @Context
> > private ServletContext sctx; // dependency injection
> > private static PredictionsList plist; // set in populate()
> > [...]
> >
> > the ServletContext sctx doesnt get initialized, on request the Server
> logs:
> >
> > ... 37 more
> > Caused by: javax.naming.NameNotFoundException: Name
> > [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
> > this Context. Unable to find [comp].
> > at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> > at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >
> >
> > I'm most likely missing something, just not sure what.
> > Is there some configuration needed for TomEE to pick up the annotated
> > field 'sctx' and inject a ServletContext into it?
> >
> > mf
>
>
>
>
> --
> Jean-Louis
>
--
*Daniel Cunha*
Site <http://danielsoro.com.br> - G
<http://github.com/danielsoro>itHub<http://github.com/danielsoro>-
LinkedIn <http://www.linkedin.com/in/danielvlcunha>
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
One note: which tomee version?
2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> Working my way through, "Java Web Services" up and running.
>
> On Page 69 i stumble over a @Context Annotation
>
> [...]
> import javax.ws.rs.core.Context;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
>
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> @Path("/predict")
> public class PredictionsRS {
> @Context
> private ServletContext sctx; // dependency injection
> private static PredictionsList plist; // set in populate()
> [...]
>
> the ServletContext sctx doesnt get initialized, on request the Server logs:
>
> ... 37 more
> Caused by: javax.naming.NameNotFoundException: Name
> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
> this Context. Unable to find [comp].
> at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>
>
> I'm most likely missing something, just not sure what.
> Is there some configuration needed for TomEE to pick up the annotated
> field 'sctx' and inject a ServletContext into it?
>
> mf
--
Jean-Louis
Re: Context in a Restful Service
Posted by Martin Funk <ma...@gmail.com>.
Both, the mvn build with bigger MaxPermGen and without the tests
and the Rest Application itself.
mf
Am 20.02.2014 um 22:27 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
> You mean the compilation or the fix :) ?
> Le 20 févr. 2014 19:20, "Martin Funk" <ma...@gmail.com> a écrit :
>
>> works like a charm now :-)
>>
>>
>> Am 20.02.2014 um 19:11 schrieb Thiago Veronezi <th...@veronezi.org>:
>>
>>> Try skipping the tests. Its much faster (~5 mins?).
>>>
>>> "mvn clean install -DskipTests=true"
>>>
>>> []s,
>>> Thiago.
>>>
>>>
>>>
>>>
>>> On Thu, Feb 20, 2014 at 1:08 PM, Martin Funk <ma...@gmail.com>
>> wrote:
>>>
>>>> Great thank you.
>>>>
>>>> What is the place to get the shapshot files?
>>>>
>>>> I tried to compile tomee myself, but no success yet, maven quit with an
>>>> java.lang.OutOfMemoryError: PermGen
>>>> space
>>>>
>>>> and the current try with reconfigured MAVEN_OPTS is still running.
>>>>
>>>> Martin
>>>>
>>>> Am 20.02.2014 um 17:31 schrieb Jean-Louis MONTEIRO <jeanouii@gmail.com
>>> :
>>>>
>>>>> Fixed on trunk.
>>>>> Should be there is next snapshot
>>>>>
>>>>> JLouis
>>>>>
>>>>>
>>>>> 2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>>
>>>>>> FYI
>>>>>>
>>>>>> https://issues.apache.org/jira/browse/TOMEE-1130
>>>>>>
>>>>>>
>>>>>> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>>>
>>>>>> I will fixed that. We forgot that type in @Context injection (bug)
>>>>>>>
>>>>>>> JLouis
>>>>>>>
>>>>>>>
>>>>>>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
>>>>>>>
>>>>>>> Hi JLouis,
>>>>>>>>
>>>>>>>> running on: apache-tomee-plus-1.6.0
>>>>>>>>
>>>>>>>> About declaring @ApplicationPath I can only say that if I drop the
>>>> usage
>>>>>>>> of the ServletContext all together
>>>>>>>> and fill the FooList fooList with fake content (see the commented
>>>> lines
>>>>>>>> in) FooRestService.populate()
>>>>>>>> the Application runs just fine.
>>>>>>>>
>>>>>>>> See I'm quite new into the subject and I wasn't sure if the
>>>>>>>> ServletContext ought to be injectable in that situation.
>>>>>>>> But surfing the net I came along
>>>>>>>>
>>>>
>> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
>>>>>>>> That made me confident to state my question.
>>>>>>>>
>>>>>>>> Martin
>>>>>>>>
>>>>>>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <
>>>> jeanouii@gmail.com>:
>>>>>>>>
>>>>>>>>> Ok, will fix that now.
>>>>>>>>>
>>>>>>>>> JLouis
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <jeanouii@gmail.com
>>> :
>>>>>>>>>
>>>>>>>>>> Strange, it does not seem in the list of supported REST injections
>>>>>>>> through
>>>>>>>>>> @Context.
>>>>>>>>>> Whereas it's in the spec.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>>>>>>>>>>
>>>>>>>>>>> Working my way through, "Java Web Services" up and running.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Page 69 i stumble over a @Context Annotation
>>>>>>>>>>>
>>>>>>>>>>> [...]
>>>>>>>>>>> import javax.ws.rs.core.Context;
>>>>>>>>>>> import javax.ws.rs.core.MediaType;
>>>>>>>>>>> import javax.ws.rs.core.Response;
>>>>>>>>>>>
>>>>>>>>>>> import com.fasterxml.jackson.databind.ObjectMapper;
>>>>>>>>>>>
>>>>>>>>>>> @Path("/predict")
>>>>>>>>>>> public class PredictionsRS {
>>>>>>>>>>> @Context
>>>>>>>>>>> private ServletContext sctx; // dependency injection
>>>>>>>>>>> private static PredictionsList plist; // set in populate()
>>>>>>>>>>> [...]
>>>>>>>>>>>
>>>>>>>>>>> the ServletContext sctx doesnt get initialized, on request the
>>>> Server
>>>>>>>>>>> logs:
>>>>>>>>>>>
>>>>>>>>>>> ... 37 more
>>>>>>>>>>> Caused by: javax.naming.NameNotFoundException: Name
>>>>>>>>>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
>>>>>>>> bound in
>>>>>>>>>>> this Context. Unable to find [comp].
>>>>>>>>>>> at
>>>>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>>>>>>>>>>> at
>>>>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I'm most likely missing something, just not sure what.
>>>>>>>>>>> Is there some configuration needed for TomEE to pick up the
>>>> annotated
>>>>>>>>>>> field 'sctx' and inject a ServletContext into it?
>>>>>>>>>>>
>>>>>>>>>>> mf
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Jean-Louis
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Jean-Louis
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jean-Louis
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jean-Louis
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Jean-Louis
>>>>
>>>>
>>
>>
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
You mean the compilation or the fix :) ?
Le 20 févr. 2014 19:20, "Martin Funk" <ma...@gmail.com> a écrit :
> works like a charm now :-)
>
>
> Am 20.02.2014 um 19:11 schrieb Thiago Veronezi <th...@veronezi.org>:
>
> > Try skipping the tests. Its much faster (~5 mins?).
> >
> > "mvn clean install -DskipTests=true"
> >
> > []s,
> > Thiago.
> >
> >
> >
> >
> > On Thu, Feb 20, 2014 at 1:08 PM, Martin Funk <ma...@gmail.com>
> wrote:
> >
> >> Great thank you.
> >>
> >> What is the place to get the shapshot files?
> >>
> >> I tried to compile tomee myself, but no success yet, maven quit with an
> >> java.lang.OutOfMemoryError: PermGen
> >> space
> >>
> >> and the current try with reconfigured MAVEN_OPTS is still running.
> >>
> >> Martin
> >>
> >> Am 20.02.2014 um 17:31 schrieb Jean-Louis MONTEIRO <jeanouii@gmail.com
> >:
> >>
> >>> Fixed on trunk.
> >>> Should be there is next snapshot
> >>>
> >>> JLouis
> >>>
> >>>
> >>> 2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >>>
> >>>> FYI
> >>>>
> >>>> https://issues.apache.org/jira/browse/TOMEE-1130
> >>>>
> >>>>
> >>>> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >>>>
> >>>> I will fixed that. We forgot that type in @Context injection (bug)
> >>>>>
> >>>>> JLouis
> >>>>>
> >>>>>
> >>>>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
> >>>>>
> >>>>> Hi JLouis,
> >>>>>>
> >>>>>> running on: apache-tomee-plus-1.6.0
> >>>>>>
> >>>>>> About declaring @ApplicationPath I can only say that if I drop the
> >> usage
> >>>>>> of the ServletContext all together
> >>>>>> and fill the FooList fooList with fake content (see the commented
> >> lines
> >>>>>> in) FooRestService.populate()
> >>>>>> the Application runs just fine.
> >>>>>>
> >>>>>> See I'm quite new into the subject and I wasn't sure if the
> >>>>>> ServletContext ought to be injectable in that situation.
> >>>>>> But surfing the net I came along
> >>>>>>
> >>
> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
> >>>>>> That made me confident to state my question.
> >>>>>>
> >>>>>> Martin
> >>>>>>
> >>>>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <
> >> jeanouii@gmail.com>:
> >>>>>>
> >>>>>>> Ok, will fix that now.
> >>>>>>>
> >>>>>>> JLouis
> >>>>>>>
> >>>>>>>
> >>>>>>> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <jeanouii@gmail.com
> >:
> >>>>>>>
> >>>>>>>> Strange, it does not seem in the list of supported REST injections
> >>>>>> through
> >>>>>>>> @Context.
> >>>>>>>> Whereas it's in the spec.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> >>>>>>>>
> >>>>>>>>> Working my way through, "Java Web Services" up and running.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Page 69 i stumble over a @Context Annotation
> >>>>>>>>>
> >>>>>>>>> [...]
> >>>>>>>>> import javax.ws.rs.core.Context;
> >>>>>>>>> import javax.ws.rs.core.MediaType;
> >>>>>>>>> import javax.ws.rs.core.Response;
> >>>>>>>>>
> >>>>>>>>> import com.fasterxml.jackson.databind.ObjectMapper;
> >>>>>>>>>
> >>>>>>>>> @Path("/predict")
> >>>>>>>>> public class PredictionsRS {
> >>>>>>>>> @Context
> >>>>>>>>> private ServletContext sctx; // dependency injection
> >>>>>>>>> private static PredictionsList plist; // set in populate()
> >>>>>>>>> [...]
> >>>>>>>>>
> >>>>>>>>> the ServletContext sctx doesnt get initialized, on request the
> >> Server
> >>>>>>>>> logs:
> >>>>>>>>>
> >>>>>>>>> ... 37 more
> >>>>>>>>> Caused by: javax.naming.NameNotFoundException: Name
> >>>>>>>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
> >>>>>> bound in
> >>>>>>>>> this Context. Unable to find [comp].
> >>>>>>>>> at
> >>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> >>>>>>>>> at
> >>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> I'm most likely missing something, just not sure what.
> >>>>>>>>> Is there some configuration needed for TomEE to pick up the
> >> annotated
> >>>>>>>>> field 'sctx' and inject a ServletContext into it?
> >>>>>>>>>
> >>>>>>>>> mf
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Jean-Louis
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> Jean-Louis
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Jean-Louis
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Jean-Louis
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Jean-Louis
> >>
> >>
>
>
Re: Context in a Restful Service
Posted by Martin Funk <ma...@gmail.com>.
works like a charm now :-)
Am 20.02.2014 um 19:11 schrieb Thiago Veronezi <th...@veronezi.org>:
> Try skipping the tests. Its much faster (~5 mins?).
>
> "mvn clean install -DskipTests=true"
>
> []s,
> Thiago.
>
>
>
>
> On Thu, Feb 20, 2014 at 1:08 PM, Martin Funk <ma...@gmail.com> wrote:
>
>> Great thank you.
>>
>> What is the place to get the shapshot files?
>>
>> I tried to compile tomee myself, but no success yet, maven quit with an
>> java.lang.OutOfMemoryError: PermGen
>> space
>>
>> and the current try with reconfigured MAVEN_OPTS is still running.
>>
>> Martin
>>
>> Am 20.02.2014 um 17:31 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>>
>>> Fixed on trunk.
>>> Should be there is next snapshot
>>>
>>> JLouis
>>>
>>>
>>> 2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>
>>>> FYI
>>>>
>>>> https://issues.apache.org/jira/browse/TOMEE-1130
>>>>
>>>>
>>>> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>
>>>> I will fixed that. We forgot that type in @Context injection (bug)
>>>>>
>>>>> JLouis
>>>>>
>>>>>
>>>>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
>>>>>
>>>>> Hi JLouis,
>>>>>>
>>>>>> running on: apache-tomee-plus-1.6.0
>>>>>>
>>>>>> About declaring @ApplicationPath I can only say that if I drop the
>> usage
>>>>>> of the ServletContext all together
>>>>>> and fill the FooList fooList with fake content (see the commented
>> lines
>>>>>> in) FooRestService.populate()
>>>>>> the Application runs just fine.
>>>>>>
>>>>>> See I'm quite new into the subject and I wasn't sure if the
>>>>>> ServletContext ought to be injectable in that situation.
>>>>>> But surfing the net I came along
>>>>>>
>> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
>>>>>> That made me confident to state my question.
>>>>>>
>>>>>> Martin
>>>>>>
>>>>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <
>> jeanouii@gmail.com>:
>>>>>>
>>>>>>> Ok, will fix that now.
>>>>>>>
>>>>>>> JLouis
>>>>>>>
>>>>>>>
>>>>>>> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>>>>
>>>>>>>> Strange, it does not seem in the list of supported REST injections
>>>>>> through
>>>>>>>> @Context.
>>>>>>>> Whereas it's in the spec.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>>>>>>>>
>>>>>>>>> Working my way through, "Java Web Services" up and running.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Page 69 i stumble over a @Context Annotation
>>>>>>>>>
>>>>>>>>> [...]
>>>>>>>>> import javax.ws.rs.core.Context;
>>>>>>>>> import javax.ws.rs.core.MediaType;
>>>>>>>>> import javax.ws.rs.core.Response;
>>>>>>>>>
>>>>>>>>> import com.fasterxml.jackson.databind.ObjectMapper;
>>>>>>>>>
>>>>>>>>> @Path("/predict")
>>>>>>>>> public class PredictionsRS {
>>>>>>>>> @Context
>>>>>>>>> private ServletContext sctx; // dependency injection
>>>>>>>>> private static PredictionsList plist; // set in populate()
>>>>>>>>> [...]
>>>>>>>>>
>>>>>>>>> the ServletContext sctx doesnt get initialized, on request the
>> Server
>>>>>>>>> logs:
>>>>>>>>>
>>>>>>>>> ... 37 more
>>>>>>>>> Caused by: javax.naming.NameNotFoundException: Name
>>>>>>>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
>>>>>> bound in
>>>>>>>>> this Context. Unable to find [comp].
>>>>>>>>> at
>>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>>>>>>>>> at
>>>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I'm most likely missing something, just not sure what.
>>>>>>>>> Is there some configuration needed for TomEE to pick up the
>> annotated
>>>>>>>>> field 'sctx' and inject a ServletContext into it?
>>>>>>>>>
>>>>>>>>> mf
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Jean-Louis
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jean-Louis
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Jean-Louis
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Jean-Louis
>>>>
>>>
>>>
>>>
>>> --
>>> Jean-Louis
>>
>>
Re: Context in a Restful Service
Posted by Thiago Veronezi <th...@veronezi.org>.
Try skipping the tests. Its much faster (~5 mins?).
"mvn clean install -DskipTests=true"
[]s,
Thiago.
On Thu, Feb 20, 2014 at 1:08 PM, Martin Funk <ma...@gmail.com> wrote:
> Great thank you.
>
> What is the place to get the shapshot files?
>
> I tried to compile tomee myself, but no success yet, maven quit with an
> java.lang.OutOfMemoryError: PermGen
> space
>
> and the current try with reconfigured MAVEN_OPTS is still running.
>
> Martin
>
> Am 20.02.2014 um 17:31 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>
> > Fixed on trunk.
> > Should be there is next snapshot
> >
> > JLouis
> >
> >
> > 2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >
> >> FYI
> >>
> >> https://issues.apache.org/jira/browse/TOMEE-1130
> >>
> >>
> >> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >>
> >> I will fixed that. We forgot that type in @Context injection (bug)
> >>>
> >>> JLouis
> >>>
> >>>
> >>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
> >>>
> >>> Hi JLouis,
> >>>>
> >>>> running on: apache-tomee-plus-1.6.0
> >>>>
> >>>> About declaring @ApplicationPath I can only say that if I drop the
> usage
> >>>> of the ServletContext all together
> >>>> and fill the FooList fooList with fake content (see the commented
> lines
> >>>> in) FooRestService.populate()
> >>>> the Application runs just fine.
> >>>>
> >>>> See I'm quite new into the subject and I wasn't sure if the
> >>>> ServletContext ought to be injectable in that situation.
> >>>> But surfing the net I came along
> >>>>
> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
> >>>> That made me confident to state my question.
> >>>>
> >>>> Martin
> >>>>
> >>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <
> jeanouii@gmail.com>:
> >>>>
> >>>>> Ok, will fix that now.
> >>>>>
> >>>>> JLouis
> >>>>>
> >>>>>
> >>>>> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >>>>>
> >>>>>> Strange, it does not seem in the list of supported REST injections
> >>>> through
> >>>>>> @Context.
> >>>>>> Whereas it's in the spec.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> >>>>>>
> >>>>>>> Working my way through, "Java Web Services" up and running.
> >>>>>>>
> >>>>>>>
> >>>>>>> On Page 69 i stumble over a @Context Annotation
> >>>>>>>
> >>>>>>> [...]
> >>>>>>> import javax.ws.rs.core.Context;
> >>>>>>> import javax.ws.rs.core.MediaType;
> >>>>>>> import javax.ws.rs.core.Response;
> >>>>>>>
> >>>>>>> import com.fasterxml.jackson.databind.ObjectMapper;
> >>>>>>>
> >>>>>>> @Path("/predict")
> >>>>>>> public class PredictionsRS {
> >>>>>>> @Context
> >>>>>>> private ServletContext sctx; // dependency injection
> >>>>>>> private static PredictionsList plist; // set in populate()
> >>>>>>> [...]
> >>>>>>>
> >>>>>>> the ServletContext sctx doesnt get initialized, on request the
> Server
> >>>>>>> logs:
> >>>>>>>
> >>>>>>> ... 37 more
> >>>>>>> Caused by: javax.naming.NameNotFoundException: Name
> >>>>>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
> >>>> bound in
> >>>>>>> this Context. Unable to find [comp].
> >>>>>>> at
> >>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> >>>>>>> at
> >>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >>>>>>>
> >>>>>>>
> >>>>>>> I'm most likely missing something, just not sure what.
> >>>>>>> Is there some configuration needed for TomEE to pick up the
> annotated
> >>>>>>> field 'sctx' and inject a ServletContext into it?
> >>>>>>>
> >>>>>>> mf
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> Jean-Louis
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Jean-Louis
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Jean-Louis
> >>>
> >>
> >>
> >>
> >> --
> >> Jean-Louis
> >>
> >
> >
> >
> > --
> > Jean-Louis
>
>
Re: Context in a Restful Service
Posted by Martin Funk <ma...@gmail.com>.
Great thank you.
What is the place to get the shapshot files?
I tried to compile tomee myself, but no success yet, maven quit with an
java.lang.OutOfMemoryError: PermGen
space
and the current try with reconfigured MAVEN_OPTS is still running.
Martin
Am 20.02.2014 um 17:31 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
> Fixed on trunk.
> Should be there is next snapshot
>
> JLouis
>
>
> 2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>
>> FYI
>>
>> https://issues.apache.org/jira/browse/TOMEE-1130
>>
>>
>> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>
>> I will fixed that. We forgot that type in @Context injection (bug)
>>>
>>> JLouis
>>>
>>>
>>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
>>>
>>> Hi JLouis,
>>>>
>>>> running on: apache-tomee-plus-1.6.0
>>>>
>>>> About declaring @ApplicationPath I can only say that if I drop the usage
>>>> of the ServletContext all together
>>>> and fill the FooList fooList with fake content (see the commented lines
>>>> in) FooRestService.populate()
>>>> the Application runs just fine.
>>>>
>>>> See I'm quite new into the subject and I wasn't sure if the
>>>> ServletContext ought to be injectable in that situation.
>>>> But surfing the net I came along
>>>> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
>>>> That made me confident to state my question.
>>>>
>>>> Martin
>>>>
>>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>
>>>>> Ok, will fix that now.
>>>>>
>>>>> JLouis
>>>>>
>>>>>
>>>>> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>>>>
>>>>>> Strange, it does not seem in the list of supported REST injections
>>>> through
>>>>>> @Context.
>>>>>> Whereas it's in the spec.
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>>>>>>
>>>>>>> Working my way through, "Java Web Services" up and running.
>>>>>>>
>>>>>>>
>>>>>>> On Page 69 i stumble over a @Context Annotation
>>>>>>>
>>>>>>> [...]
>>>>>>> import javax.ws.rs.core.Context;
>>>>>>> import javax.ws.rs.core.MediaType;
>>>>>>> import javax.ws.rs.core.Response;
>>>>>>>
>>>>>>> import com.fasterxml.jackson.databind.ObjectMapper;
>>>>>>>
>>>>>>> @Path("/predict")
>>>>>>> public class PredictionsRS {
>>>>>>> @Context
>>>>>>> private ServletContext sctx; // dependency injection
>>>>>>> private static PredictionsList plist; // set in populate()
>>>>>>> [...]
>>>>>>>
>>>>>>> the ServletContext sctx doesnt get initialized, on request the Server
>>>>>>> logs:
>>>>>>>
>>>>>>> ... 37 more
>>>>>>> Caused by: javax.naming.NameNotFoundException: Name
>>>>>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
>>>> bound in
>>>>>>> this Context. Unable to find [comp].
>>>>>>> at
>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>>>>>>> at
>>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>>>>>>
>>>>>>>
>>>>>>> I'm most likely missing something, just not sure what.
>>>>>>> Is there some configuration needed for TomEE to pick up the annotated
>>>>>>> field 'sctx' and inject a ServletContext into it?
>>>>>>>
>>>>>>> mf
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jean-Louis
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Jean-Louis
>>>>
>>>>
>>>
>>>
>>> --
>>> Jean-Louis
>>>
>>
>>
>>
>> --
>> Jean-Louis
>>
>
>
>
> --
> Jean-Louis
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Fixed on trunk.
Should be there is next snapshot
JLouis
2014-02-20 17:27 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> FYI
>
> https://issues.apache.org/jira/browse/TOMEE-1130
>
>
> 2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>
> I will fixed that. We forgot that type in @Context injection (bug)
>>
>> JLouis
>>
>>
>> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
>>
>> Hi JLouis,
>>>
>>> running on: apache-tomee-plus-1.6.0
>>>
>>> About declaring @ApplicationPath I can only say that if I drop the usage
>>> of the ServletContext all together
>>> and fill the FooList fooList with fake content (see the commented lines
>>> in) FooRestService.populate()
>>> the Application runs just fine.
>>>
>>> See I'm quite new into the subject and I wasn't sure if the
>>> ServletContext ought to be injectable in that situation.
>>> But surfing the net I came along
>>> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
>>> That made me confident to state my question.
>>>
>>> Martin
>>>
>>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>>>
>>> > Ok, will fix that now.
>>> >
>>> > JLouis
>>> >
>>> >
>>> > 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>>> >
>>> >> Strange, it does not seem in the list of supported REST injections
>>> through
>>> >> @Context.
>>> >> Whereas it's in the spec.
>>> >>
>>> >>
>>> >>
>>> >> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>>> >>
>>> >>> Working my way through, "Java Web Services" up and running.
>>> >>>
>>> >>>
>>> >>> On Page 69 i stumble over a @Context Annotation
>>> >>>
>>> >>> [...]
>>> >>> import javax.ws.rs.core.Context;
>>> >>> import javax.ws.rs.core.MediaType;
>>> >>> import javax.ws.rs.core.Response;
>>> >>>
>>> >>> import com.fasterxml.jackson.databind.ObjectMapper;
>>> >>>
>>> >>> @Path("/predict")
>>> >>> public class PredictionsRS {
>>> >>> @Context
>>> >>> private ServletContext sctx; // dependency injection
>>> >>> private static PredictionsList plist; // set in populate()
>>> >>> [...]
>>> >>>
>>> >>> the ServletContext sctx doesnt get initialized, on request the Server
>>> >>> logs:
>>> >>>
>>> >>> ... 37 more
>>> >>> Caused by: javax.naming.NameNotFoundException: Name
>>> >>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not
>>> bound in
>>> >>> this Context. Unable to find [comp].
>>> >>> at
>>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>>> >>> at
>>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>> >>>
>>> >>>
>>> >>> I'm most likely missing something, just not sure what.
>>> >>> Is there some configuration needed for TomEE to pick up the annotated
>>> >>> field 'sctx' and inject a ServletContext into it?
>>> >>>
>>> >>> mf
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Jean-Louis
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Jean-Louis
>>>
>>>
>>
>>
>> --
>> Jean-Louis
>>
>
>
>
> --
> Jean-Louis
>
--
Jean-Louis
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
FYI
https://issues.apache.org/jira/browse/TOMEE-1130
2014-02-20 17:18 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> I will fixed that. We forgot that type in @Context injection (bug)
>
> JLouis
>
>
> 2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
>
> Hi JLouis,
>>
>> running on: apache-tomee-plus-1.6.0
>>
>> About declaring @ApplicationPath I can only say that if I drop the usage
>> of the ServletContext all together
>> and fill the FooList fooList with fake content (see the commented lines
>> in) FooRestService.populate()
>> the Application runs just fine.
>>
>> See I'm quite new into the subject and I wasn't sure if the
>> ServletContext ought to be injectable in that situation.
>> But surfing the net I came along
>> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
>> That made me confident to state my question.
>>
>> Martin
>>
>> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>>
>> > Ok, will fix that now.
>> >
>> > JLouis
>> >
>> >
>> > 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>> >
>> >> Strange, it does not seem in the list of supported REST injections
>> through
>> >> @Context.
>> >> Whereas it's in the spec.
>> >>
>> >>
>> >>
>> >> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>> >>
>> >>> Working my way through, "Java Web Services" up and running.
>> >>>
>> >>>
>> >>> On Page 69 i stumble over a @Context Annotation
>> >>>
>> >>> [...]
>> >>> import javax.ws.rs.core.Context;
>> >>> import javax.ws.rs.core.MediaType;
>> >>> import javax.ws.rs.core.Response;
>> >>>
>> >>> import com.fasterxml.jackson.databind.ObjectMapper;
>> >>>
>> >>> @Path("/predict")
>> >>> public class PredictionsRS {
>> >>> @Context
>> >>> private ServletContext sctx; // dependency injection
>> >>> private static PredictionsList plist; // set in populate()
>> >>> [...]
>> >>>
>> >>> the ServletContext sctx doesnt get initialized, on request the Server
>> >>> logs:
>> >>>
>> >>> ... 37 more
>> >>> Caused by: javax.naming.NameNotFoundException: Name
>> >>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound
>> in
>> >>> this Context. Unable to find [comp].
>> >>> at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>> >>> at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>> >>>
>> >>>
>> >>> I'm most likely missing something, just not sure what.
>> >>> Is there some configuration needed for TomEE to pick up the annotated
>> >>> field 'sctx' and inject a ServletContext into it?
>> >>>
>> >>> mf
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Jean-Louis
>> >>
>> >
>> >
>> >
>> > --
>> > Jean-Louis
>>
>>
>
>
> --
> Jean-Louis
>
--
Jean-Louis
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
I will fixed that. We forgot that type in @Context injection (bug)
JLouis
2014-02-20 16:44 GMT+01:00 Martin Funk <ma...@gmail.com>:
> Hi JLouis,
>
> running on: apache-tomee-plus-1.6.0
>
> About declaring @ApplicationPath I can only say that if I drop the usage
> of the ServletContext all together
> and fill the FooList fooList with fake content (see the commented lines
> in) FooRestService.populate()
> the Application runs just fine.
>
> See I'm quite new into the subject and I wasn't sure if the ServletContext
> ought to be injectable in that situation.
> But surfing the net I came along
> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
> That made me confident to state my question.
>
> Martin
>
> Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
>
> > Ok, will fix that now.
> >
> > JLouis
> >
> >
> > 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> >
> >> Strange, it does not seem in the list of supported REST injections
> through
> >> @Context.
> >> Whereas it's in the spec.
> >>
> >>
> >>
> >> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> >>
> >>> Working my way through, "Java Web Services" up and running.
> >>>
> >>>
> >>> On Page 69 i stumble over a @Context Annotation
> >>>
> >>> [...]
> >>> import javax.ws.rs.core.Context;
> >>> import javax.ws.rs.core.MediaType;
> >>> import javax.ws.rs.core.Response;
> >>>
> >>> import com.fasterxml.jackson.databind.ObjectMapper;
> >>>
> >>> @Path("/predict")
> >>> public class PredictionsRS {
> >>> @Context
> >>> private ServletContext sctx; // dependency injection
> >>> private static PredictionsList plist; // set in populate()
> >>> [...]
> >>>
> >>> the ServletContext sctx doesnt get initialized, on request the Server
> >>> logs:
> >>>
> >>> ... 37 more
> >>> Caused by: javax.naming.NameNotFoundException: Name
> >>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound
> in
> >>> this Context. Unable to find [comp].
> >>> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> >>> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:168)
> >>>
> >>>
> >>> I'm most likely missing something, just not sure what.
> >>> Is there some configuration needed for TomEE to pick up the annotated
> >>> field 'sctx' and inject a ServletContext into it?
> >>>
> >>> mf
> >>>
> >>
> >>
> >>
> >> --
> >> Jean-Louis
> >>
> >
> >
> >
> > --
> > Jean-Louis
>
>
--
Jean-Louis
Re: Context in a Restful Service
Posted by Martin Funk <ma...@gmail.com>.
Hi JLouis,
running on: apache-tomee-plus-1.6.0
About declaring @ApplicationPath I can only say that if I drop the usage of the ServletContext all together
and fill the FooList fooList with fake content (see the commented lines in) FooRestService.populate()
the Application runs just fine.
See I'm quite new into the subject and I wasn't sure if the ServletContext ought to be injectable in that situation.
But surfing the net I came along https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations
That made me confident to state my question.
Martin
Am 20.02.2014 um 16:07 schrieb Jean-Louis MONTEIRO <je...@gmail.com>:
> Ok, will fix that now.
>
> JLouis
>
>
> 2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
>
>> Strange, it does not seem in the list of supported REST injections through
>> @Context.
>> Whereas it's in the spec.
>>
>>
>>
>> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>>
>>> Working my way through, "Java Web Services" up and running.
>>>
>>>
>>> On Page 69 i stumble over a @Context Annotation
>>>
>>> [...]
>>> import javax.ws.rs.core.Context;
>>> import javax.ws.rs.core.MediaType;
>>> import javax.ws.rs.core.Response;
>>>
>>> import com.fasterxml.jackson.databind.ObjectMapper;
>>>
>>> @Path("/predict")
>>> public class PredictionsRS {
>>> @Context
>>> private ServletContext sctx; // dependency injection
>>> private static PredictionsList plist; // set in populate()
>>> [...]
>>>
>>> the ServletContext sctx doesnt get initialized, on request the Server
>>> logs:
>>>
>>> ... 37 more
>>> Caused by: javax.naming.NameNotFoundException: Name
>>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
>>> this Context. Unable to find [comp].
>>> at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>>> at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>>
>>>
>>> I'm most likely missing something, just not sure what.
>>> Is there some configuration needed for TomEE to pick up the annotated
>>> field 'sctx' and inject a ServletContext into it?
>>>
>>> mf
>>>
>>
>>
>>
>> --
>> Jean-Louis
>>
>
>
>
> --
> Jean-Louis
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Ok, will fix that now.
JLouis
2014-02-20 16:02 GMT+01:00 Jean-Louis MONTEIRO <je...@gmail.com>:
> Strange, it does not seem in the list of supported REST injections through
> @Context.
> Whereas it's in the spec.
>
>
>
> 2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
>
>> Working my way through, "Java Web Services" up and running.
>>
>>
>> On Page 69 i stumble over a @Context Annotation
>>
>> [...]
>> import javax.ws.rs.core.Context;
>> import javax.ws.rs.core.MediaType;
>> import javax.ws.rs.core.Response;
>>
>> import com.fasterxml.jackson.databind.ObjectMapper;
>>
>> @Path("/predict")
>> public class PredictionsRS {
>> @Context
>> private ServletContext sctx; // dependency injection
>> private static PredictionsList plist; // set in populate()
>> [...]
>>
>> the ServletContext sctx doesnt get initialized, on request the Server
>> logs:
>>
>> ... 37 more
>> Caused by: javax.naming.NameNotFoundException: Name
>> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
>> this Context. Unable to find [comp].
>> at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>> at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>>
>>
>> I'm most likely missing something, just not sure what.
>> Is there some configuration needed for TomEE to pick up the annotated
>> field 'sctx' and inject a ServletContext into it?
>>
>> mf
>>
>
>
>
> --
> Jean-Louis
>
--
Jean-Louis
Re: Context in a Restful Service
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Strange, it does not seem in the list of supported REST injections through
@Context.
Whereas it's in the spec.
2014-02-19 18:36 GMT+01:00 Martin Funk <Ma...@martinfunk.de>:
> Working my way through, "Java Web Services" up and running.
>
> On Page 69 i stumble over a @Context Annotation
>
> [...]
> import javax.ws.rs.core.Context;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
>
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> @Path("/predict")
> public class PredictionsRS {
> @Context
> private ServletContext sctx; // dependency injection
> private static PredictionsList plist; // set in populate()
> [...]
>
> the ServletContext sctx doesnt get initialized, on request the Server logs:
>
> ... 37 more
> Caused by: javax.naming.NameNotFoundException: Name
> [comp/env/de.martinfunk.predictions3.PredictionsRS/sctx] is not bound in
> this Context. Unable to find [comp].
> at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>
>
> I'm most likely missing something, just not sure what.
> Is there some configuration needed for TomEE to pick up the annotated
> field 'sctx' and inject a ServletContext into it?
>
> mf
--
Jean-Louis