Questions tagged [guice-servlet]

Guice's servlet extensions allow you to completely eliminate web.xml from your servlet application and take advantage of type-safe, idiomatic Java configuration of your servlet and filter components

Guice Servlet Extensions

Guice Servlet provides a complete story for use in web applications and servlet containers. Guice's servlet extensions allow you to completely eliminate web.xml from your servlet application and take advantage of type-safe, idiomatic Java configuration of your servlet and filter components.

This has advantages not only in being able to use a nicer API for configuring your web applications, but also in tying together dependency injection with web components. Meaning that your servlets and filters benefit from:

  • Constructor injection
  • Type-safe, idiomatic configuration
  • Modularization (package and distribute custom Guice Servlet libraries)
  • Guice AOP

While keeping the benefits of the standard servlet lifecycle.

References

100 questions
1
vote
0 answers

Continuation of request scope after request has been completed

I am having trouble finding a definitive approach to achieving the following objective. We have a nice implementation for request scoped operation invocation from client. These operations are expected to be fast and nimble i.e. <10 ms and any heavy…
Gautam
  • 1,030
  • 13
  • 37
1
vote
1 answer

Java Guice with servlets Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions

I'm trying to configure Guice with Google App Engine, but I get this problem when I start the server (with "gradle appengineRun"): Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions at…
1
vote
1 answer

difference between ContextLoader and ContextLoaderListener

the difference between ContextLoader and ContextLoaderListenerI am not understanding the difference. I have tried to search on google but I am not able to search. Please help me on this.
1
vote
1 answer

Issue with Jersery1.x, Guice and Tomcat

I am developing a simple application using Jersey 1.x, Guice and trying to run on Tomcat. I used Guice filter and Guice Listener along with Resources and Application. Below is my web.xml : guiceFilter
user1767288
  • 105
  • 1
  • 11
1
vote
1 answer

Google Guice MethodInterceptor under Tomcat 8.5

We wan't to use aop methodinterceptors using guice as provider under tomcat 8.5. We are currently already using interceptors and guice in our Java-FX applications without any problems. Trying to do the same under Tomcat does not work. Objects are…
user3240383
  • 115
  • 1
  • 1
  • 10
1
vote
2 answers

Guice injection doesn't work in ServletContextListener

Is the a reason why Guice injection doesn't work in a ServletConextListener? Here is my code: public class QuartzContextListener implements ServletContextListener { @Inject private DataAccess dataAccess; @Override public void…
bashan
  • 3,572
  • 6
  • 41
  • 58
1
vote
1 answer

Embedded jetty and guice Handler servlet upon request domain(vhost)

In details, I am using one single jetty server by java embedding that will handle multiple request. I am injecting the event listener and the security filter with guice. But i need to server servlet upon the request domian. I am trying with virtual…
sadlil
  • 3,077
  • 5
  • 23
  • 36
1
vote
0 answers

Jersey & Guice: How to appoint base path to each ServletModule?

Question(s): How can I define Jersey resources and ExceptionMappers in such a way that they only respond to requests for a certain subset of paths? How can I do this without having to decide ahead of time under what base path I would like to host…
derabbink
  • 2,419
  • 1
  • 22
  • 47
1
vote
2 answers

Guice breaks AppEngine devserver module to instance routing

I have two modules in application. First module is producing tasks for second module via Push Queue. Both modules use manual scaling. Queue queue = QueueFactory.getQueue("update-job"); ModulesService ms =…
1
vote
1 answer

Guice and URLRewrite filter integration

I'm incrementally migrating our application servlets from web.xml to Guice servlet module and encountered problem with UrlRewrite filter (tuckey.org/urlrewrite/‎). It does not process servlets registered in Guice module. If I register both servlet…
1
vote
0 answers

Update to entity is not recognized or persisted when using guice-persist

I am having an issue with guice-persist and guice-servlet (http-request scoped jpa sessions) where I attempt to update an entity's value and persist that update, but the update is never persisted to the database. I have tried forcing the write with…
1
vote
0 answers

Why a filter defined in guice does not listen on /*?

My DI framework is Guice. I also use sitebricks. Perhaps I am fascinated by how simple these two APIs are. However I want to bind a filter, using guice, to listen to /* however the filter only listens on / ? Why is that? public class CoreModule…
Adelin
  • 18,144
  • 26
  • 115
  • 175
1
vote
1 answer

Guice ServletScopes.scopeRequest and @RequestParameters when testing

I have to deal with some legacy code. There is one point where I need a function like NewCodeAccessor.get() which gives me an object that is obtained from Guice. public class NewCodeAccessor { @Inject public static Provider
jcvj
  • 130
  • 8
1
vote
2 answers

Register web.xml listeners using guice servlet module

I'm using guice and guice servlet in my project. I can map servlets and filters in a servletmodule using the serve(...) and filter(...) methods. How do you register a listener (listener-tag in web.xml) in the servlet module. I am using a…
1
vote
1 answer

How to let Jersey instantiate and manage the life-cycle and let Guice perform injection

I have referred to this link for the guide on how to do it. https://jersey.java.net/nonav/apidocs/latest/jersey/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html I have followed what is shown there. In…
Ken Chen
  • 62
  • 1
  • 7