Hi Paul
Thanks a lot and worked like magic ;).
- Geeth
On Wed, Oct 13, 2010 at 10:11 AM, Paul Sandoz-2 [via Jersey] <
ml-node+5630326-383891238-293298_at_n2.nabble.com<ml-node%2B5630326-383891238-293298_at_n2.nabble.com>
> wrote:
> Hi,
>
> You need to use the maven shade plugin:
>
> http://maven.apache.org/plugins/maven-shade-plugin/
>
> and also configure the ServicesResourceTransformer:
>
>
> http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
>
> to correctly process META-INF/services files.
>
> Paul.
>
> On Oct 12, 2010, at 5:50 PM, spudtm wrote:
>
> > Hi PaulÂ
> >
> > First of all, apologies for the long silence; I have been away. Â
> > I am creating the complete jar in maven using the "maven assembly
> > plugin"
> > <plugin>
> > <artifactId>maven-assembly-plugin</artifactId>
> > <version>2.2-beta-5</version>
> > <configuration>
> > <archive>
> > <manifest>
> > <mainClass>MyServer</mainClass>
> > </manifest>
> > </archive>
> > <descriptorRefs>
> > <descriptorRef>jar-with-dependencies</descriptorRef>
> > </descriptorRefs>
> > </configuration>
> > </plugin>
> >
> > If I run the target with jersey - 1.0.3 META-INF/services got a file
> > named "com.sun.jersey.spi.inject.InjectableProvider" with value
> > "com
> > .sun
> > .jersey.atom.abdera.impl.provider.injectable.ContentHelperProvider".
> > Â However, if I upgrade to jersey 1.4 and run the same target the
> > contents of the "com.sun.jersey.spi.inject.InjectableProvider" are
> > as follows:Â
> >
> > com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider
> > com.sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider
> > com.sun.jersey.core.impl.provider.xml.DocumentBuilderFactoryProvider
> > com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider
> >
> > Now I can see that there is of-course nothing about the
> > "com
> > .sun
> > .jersey.atom.abdera.impl.provider.injectable.ContentHelperProvider"
> > in the "com.sun.jersey.spi.inject.InjectableProvider".  Is it
> > something to do with the jersey configuration or wrong use of maven
> > assembly build?
> >
> > Any advice would be appreciated; I can still carry on with the
> > jersey 1.0.3 but would like to use the newer version.
> >
> > - GeethÂ
> >
> > On Tue, Oct 5, 2010 at 3:48 PM, Paul Sandoz-2 [via Jersey] <[hidden
> > email]> wrote:
> > Hi,
> >
> > How are you creating the complete jar?
> >
> > You need to ensure that META-INF/services files from each jar are Â
> > merged when making the complete jar.
> >
> > Paul.
> >
> > On Sep 27, 2010, at 9:07 PM, spudtm wrote:
> >
> > >
> > > Hi guys
> > >
> > > I am trying out jersey for a set of REST services and having a
> > similar
> > > problem with regard to the dependency injection with jersey 1.4
> > (If Â
> > > I use
> > > 1.0.3 then, there are no errors).
> > >
> > > I want to use  Abdera ContentHelper in my resources (i.e.,
> > '_at_Context
> > > ContentHelper contentHelper' at the top level of the class Â
> > > declaration) for
> > > easy atom feed entity write. Â When I run my resources from
> > eclipse, Â
> > > the
> > > dependencies are injected and if I run my mvn project from command Â
> > > line as
> > > 'mvn exec:java' it still works, but when I create a complete jar
> > of Â
> > > the
> > > project (including all the dependencies) and execute the jar file Â
> > > (i.e.,
> > > java -jar <jar file>) it throws up an exception which says
> > >
> > > "
> > > SEVERE: The following errors and warnings have been detected with Â
> > > resource
> > > and/or provider classes:
> > > Â SEVERE: Missing dependency for field:
> > > com.sun.jersey.atom.abdera.ContentHelper <MyClass>.contentHelper
> > > Sep 23, 2010 7:55:53 PM com.sun.grizzly.http.servlet.ServletAdapter
> > > doService
> > > SEVERE: service exception:
> > > Throwable occurred: com.sun.jersey.spi.inject.Errors
> > > $ErrorMessagesException
> > > ...
> > > "
> > >
> > > This is of course jerser+grizzly not been able to get hold of an Â
> > > instance of
> > > ContentHelper.
> > >
> > > Following an example
> > > (
> http://jersey.576304.n2.nabble.com/Simplest-Dependency-Injection-with-Jersey-td3393338.html#a5564545Â<http://jersey.576304.n2.nabble.com/Simplest-Dependency-Injection-with-Jersey-td3393338.html?by-user=t#a5564545Â>
>
> > > ),
> > > I have create an injector (See the bottom of the query) and load
> > it Â
> > > up with
> > > my grizzly server as follows.
> > > jsa.addInitParameter( "com.sun.jersey.config.property.packages",
> > > Â Â Â Â Â Â Â Â Â Â Â Â Â
> > "rs.csd.abdn.ac.uk.resources;" +
> > > Â Â Â Â Â Â Â Â Â Â Â Â Â
> > "rs.csd.abdn.ac.uk.providers");
> > >
> > > From the output of the jersey/grizzly I can see that the class is Â
> > > picked.
> > >
> > > Can you shed any light on this? The dependencies I am using are
> > >
> > > 1) jersey-core
> > > 2) jersey-server
> > > 3) jsr311-api
> > > 4) grizzly-servlet-webserver
> > > 5) jersey-atom-abdera
> > > 6) jaxb-api
> > >
> > > Thanks
> > > - Geeth
> > >
> > > Injector class
> > > ========
> > > package rs.csd.abdn.ac.uk.resources.injector;
> > >
> > > import java.lang.reflect.Type;
> > >
> > > import javax.annotation.Resource;
> > > import javax.naming.Context;
> > > import javax.naming.InitialContext;
> > > import javax.naming.NamingException;
> > > import javax.ws.rs.ext.Provider;
> > >
> > > import com.sun.jersey.core.spi.component.ComponentContext;
> > > import com.sun.jersey.core.spi.component.ComponentScope;
> > > import com.sun.jersey.spi.inject.Injectable;
> > > import com.sun.jersey.spi.inject.InjectableProvider;
> > >
> > > @Provider
> > > public class ResourceInjector implements Â
> > > InjectableProvider<Resource, Type>
> > > {
> > > Â public Injectable getInjectable(ComponentContext cc, Resource Â
> > > r,Type t)
> > > Â {
> > > Â Â final Object value = get(r);
> > >
> > >   return  new Injectable()
> > > Â Â Â Â Â Â {
> > > Â Â Â Â Â Â Â public Object getValue()
> > > Â Â Â Â Â Â Â {
> > > Â Â Â Â Â Â Â Â return value;
> > > Â Â Â Â Â Â Â }
> > > Â Â Â Â Â Â };
> > > Â }
> > >
> > > Â public ComponentScope getScope()
> > > Â {
> > > Â Â return ComponentScope.Singleton;
> > > Â }
> > >
> > > Â private Object get(Resource r)
> > > Â {
> > > Â Â try
> > > Â Â {
> > > Â Â Â Â Context ctx = new InitialContext();
> > > Â Â Â Â try
> > > Â Â Â Â {
> > > Â Â Â Â Â return ctx.lookup(r.name());
> > > Â Â Â Â }
> > > Â Â Â Â catch (NamingException ex)
> > > Â Â Â Â {
> > > Â Â Â Â Â Â return ctx.lookup("java:comp/env/" + r.name());
> > > Â Â Â Â }
> > > Â Â }
> > > Â Â catch (Exception ex)
> > > Â Â {
> > > Â Â Â Â throw new RuntimeException(ex);
> > > Â Â }
> > > }
> > > }
> > > --
> > > View this message in context:
> http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5576514.html<http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5576514.html?by-user=t>
> > > Sent from the Jersey mailing list archive at Nabble.com.
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> >
> > View message @
> http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5603716.html<http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5603716.html?by-user=t>
> > To start a new topic under Jersey, email [hidden email]
> > To unsubscribe from Jersey, click here.
> >
> >
> >
> >
> > --
> > Geeth Ranmal de Mel
> > Research Assistant
> > Department of Computing Science
> > University of Aberdeen
> > Aberdeen AB24 3UE
> > Scotland (UK)
> >
> > Tele : +44 - 1224 - 274174
> > Fax : +44 - 1224 - 273422
> > Web : http://www.csd.abdn.ac.uk/~gdemel
> >
> > View this message in context: Re: Dependency injection jersey +
> > grizzly
> > Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5630326&i=0>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5630326&i=1>
>
>
>
> ------------------------------
> View message @
> http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5630326.html
> To unsubscribe from Dependency injection jersey + grizzly, click here<http://jersey.576304.n2.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=5576514&code=Z2VldGguZGVtZWxAZ21haWwuY29tfDU1NzY1MTR8LTE3MTkyNDg2NjE=>.
>
>
>
--
Geeth Ranmal de Mel
Research Assistant
Department of Computing Science
University of Aberdeen
Aberdeen AB24 3UE
Scotland (UK)
Tele : +44 - 1224 - 274174
Fax : +44 - 1224 - 273422
Web : http://www.csd.abdn.ac.uk/~gdemel
--
View this message in context: http://jersey.576304.n2.nabble.com/Dependency-injection-jersey-grizzly-tp5576514p5631149.html
Sent from the Jersey mailing list archive at Nabble.com.