That should have been jersey-guice-1.1.0-ea.jar ... not
1.0.3-SNAPSHOT. Same result.
On Fri, Jul 3, 2009 at 11:58 AM, Christopher Piggott<cpiggott_at_gmail.com> wrote:
> Thanks, especially since you're on vacation. I'm getting further, but
> still not there yet.
>
> My webapp descriptor looks like this:
> <web-app>
> <display-name>Autofrog Alarm Monitor</display-name>
> <listener>
> <listener-class>
> com.autofrog.agents.jersey.ModbusGuiceContextListener
> </listener-class>
> </listener>
> <filter>
> <servlet-name>alarm-servlet</servlet-name>
> <servlet-class>com.google.inject.servlet.GuiceFilter</servlet-class>
> </filter>
> </web-app>
>
>
> and ModbusGuiceContextListener looks like this:
>
> public class ModbusGuiceContextListener extends GuiceServletContextListener {
> static Logger log = LogManager.getLogger(ModbusGuiceContextListener.class);
>
> @Override
> protected Injector getInjector() {
> return Guice.createInjector(new JerseyGuiceModule());
> }
>
> @Override
> public void contextInitialized(ServletContextEvent servletContextEvent) {
> log.info("Initializing servlet context");
> super.contextDestroyed(servletContextEvent);
> }
>
> @Override
> public void contextDestroyed(ServletContextEvent servletContextEvent) {
> log.info("Destroying servlet context");
> super.contextDestroyed(servletContextEvent);
> }
> }
>
> JerseyGuiceModule is simple (Same as the examples, more or less - I
> just didn't make it anonymous):
>
>
> public class JerseyGuiceModule extends ServletModule {
> @Override
> protected void configureServlets() {
> bind(CacheResource.class);
> serve("/*").with(GuiceContainer.class);
> }
> }
>
>
> I think that's all right, but tomcat 6.0.18 is refusing to load it. I
> am sending it this:
>
> # ls webapps/alarm/WEB-INF/lib/
> asm-3.1.jar
> guice-all-2.0.jar
> guice-servlet-2.0.jar
> jamod-extras.jar
> jamod.jar
> jersey-core-1.1.0-ea.jar
> jersey-guice-1.0.3-SNAPSHOT.jar
> jersey-server-1.1.0-ea.jar
> jsr311-api-1.1.jar
> log4j-1.2.jar
> stax-api-1.0-2.jar
>
>
> So I think that's everything it should need. The GuiceFilter
> specified in web.xml is in guice-servlet-2.0.jar. When I try to
> deploy or run it, I get a crazy exception (see below). I don't know
> what getBootClassPathEntryForClass() is supposed to do or why it's
> getting a null.
>
> Maybe I still have the wrong libraries?
>
> --Chris
>
> P.S. this is a hobby project, not for work or any kind of profit
> making activities. I just wanted to say that because I feel bad being
> so dependent :(
>
> SEVERE: Null component
> Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/alarm,J2EEApplication=none,J2EEServer=none
> Jul 3, 2009 11:53:24 AM org.apache.catalina.startup.HostConfig
> deployWAR
> SEVERE: Error deploying web application archive alarm.war
> java.lang.NullPointerException
> at sun.jkernel.DownloadManager.getBootClassPathEntryForClass(DownloadManager.java:928)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:293)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1302)
> at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
> at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
> at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:84)
> at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:57)
> at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
> at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1068)
> at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
> at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4248)
> at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
> at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)
> at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:145)
> at java.security.AccessController.doPrivileged(Native Method)
> at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)
> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
> at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
> at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:515)
> at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1231)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
> at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
> at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
> at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1471)
> at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:645)
> at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:432)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
> at java.security.AccessController.doPrivileged(Native Method)
> at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
> at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
> at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:283)
> at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)
> at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)
> at java.security.AccessController.doPrivileged(Native Method)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
>
>
>
> On Thu, Jul 2, 2009 at 2:00 AM, Paul Sandoz<Paul.Sandoz_at_sun.com> wrote:
>> Hi,
>>
>> Strictly speaking i am on holiday, i definitely will not be able to follow
>> up with any for emails until return, because i will not have email access.
>>
>>
>> Christian's article is fairly old (and in your previous email you were
>> referring to some old classes).
>>
>> Make sure you are using Jersey 1.1.0-ea.
>>
>> The last section of the following explains how to use Guice:
>>
>> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.1.0-ea/jersey/dependencies.html
>>
>> See also the JavaDoc:
>>
>> https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html
>>
>>
>> If you are not using maven then you require the 1.1.0-ea server and/or
>> client jars plus:
>>
>> http://download.java.net/maven/2/com/sun/jersey/contribs/jersey-guice/1.1.0-ea/jersey-guice-1.1.0-ea.jar
>>
>> If you download Guice you require: aopalliance.jar, guice-2.0.jar and
>> guice-servlet.jar.
>>
>> Note that we compile against Guice as distributed with GuiceyFruit. But if
>> you are using standard Guice 2.0 features then jars from Guice should work.
>>
>> Hope this helps,
>> Paul.
>>
>> On Jul 2, 2009, at 6:10 AM, Christopher Piggott wrote:
>>
>>> Perhaps I should explain what I am trying to do a little better.
>>>
>>> I extendi com.sun.jersey.spi.container.servlet.ServletContainer:
>>>
>>> public class MyServletContainer extends ServletContainer {
>>> @Override
>>> protected void configure(ServletConfig servletConfig, ResourceConfig rc,
>>> WebApplication wa) {
>>> super.configure(servletConfig, rc, wa);
>>> ...
>>> }
>>> }
>>>
>>> The guts of that method set up an InjectableProvider that is able to
>>> inject my own resources of various sorts. It works, but it is tedious
>>> to add new things that I want to inject...it's basically a large if
>>> ... else ... else block that identifies what is to be injected and
>>> returns an Injectable<Object> for each.
>>>
>>> What I'd like to do is replace this with a more generic injection
>>> framework. Guice looks lpretty good. What I don't understand is how
>>> to wire it into jersey's ServletContainer. I did my best to follow
>>> Christian Rivasseau's jersey-guice article, but the link to his source
>>> code is dead, and I wasn't clear where to find the ResourceProvider
>>> interface or how to hook it in so that Jersey uses it.
>>>
>>>
>>> The sense I get is that I have to write my own resourceConfigClass and
>>> splice it in as an init-param to the ServletContainer. Is this close?
>>>
>>> --Chris
>>>
>>>
>>>
>>> On Wed, Jul 1, 2009 at 10:58 PM, Christopher Piggott<cpiggott_at_gmail.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to find all the jars I need to add guice to my jersey based
>>>> application. Right now I'm having trouble finding, among other
>>>> things:
>>>>
>>>> com.sun.ws.rest.api.container.ContainerException;
>>>> com.sun.ws.rest.spi.resource.ResourceProvider;
>>>> com.sun.ws.rest.spi.resource.ResourceProviderContext;
>>>>
>>>> Something tells me this shouldn't be quite so dfficult.
>>>>
>>>> 1) Are there any more up-to-date examples?
>>>> 2) Most of the jersey "downloads" page has maven and non-maven links,
>>>> but not the guice side. Would somebody be willing to fix up that
>>>> document to include links to the jars for non-maven users?
>>>>
>>>> Thanks for any pointers.
>>>>
>>>> --Chris
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>