Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:44:01+00:00 2026-05-31T18:44:01+00:00

I am new to Guice. I want to create a server application with RESTful

  • 0

I am new to Guice.
I want to create a server application with RESTful web services and Guice for DI. I followed the tutorial here, instead of a jetty I use a Tomcat6. But I cannot get it to run 🙁

I always get Could not find a suitable constructor in com.sun.jersey.guice.spi.container.servlet.GuiceContainer on the application startup.

Exception sending context initialized event to listener instance of class de.server.MyGuiceServletConfig
com.google.inject.CreationException: Guice creation errors:
1) Could not find a suitable constructor in com.sun.jersey.guice.spi.container.servlet.GuiceContainer. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.class(GuiceContainer.java:108)
at com.sun.jersey.guice.JerseyServletModule.webApp(JerseyServletModule.java:90)

The GuiceContainer class has an constructor with an @Inject statement where it wants an Injector.

  @Inject
public GuiceContainer(Injector injector) {
    this.injector = injector;
}

My web.xml looks like this:

<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<filter>
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
    <listener-class>de.server.MyGuiceServletConfig</listener-class>
</listener>

<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/rest</param-value>
</context-param>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    </listener-class>
</listener>

<servlet>
    <servlet-name>resteasy-servlet</servlet-name>
    <servlet-class>
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>resteasy-servlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping> 

My config class looks like this:

public class MyGuiceServletConfig extends GuiceServletContextListener {

public MyGuiceServletConfig() {

}

public class MyJerseyServletModule extends JerseyServletModule {
    @Override
    protected void configureServlets() {
        // Must configure at least one JAX-RS resource or the
        // server will fail to start.
        bind(ITest.class).to(Test2.class);  
        bind(TestRestService.class);

        serve("/*").with(GuiceContainer.class);
    }
}

@Override
protected Injector getInjector() {
    return Guice.createInjector(new MyJerseyServletModule());
}}

And last but not least the rest service:

@Path("/test")
public class TestRestService {

private ITest test;

@Inject
public TestRestService(ITest t){
    this.test = t;
}

@GET
@Path("/getMe")
public String getMe() {
    return test.getName();
}


@GET
@Path("/getAll")
public Response getAll() {
    return Response.status(200).entity("sadsads").build();
}}

I don’t know what I am missing. Hope you can tell me what I did wrong…

If you need any further information, just leave a comment and I’ll add it.

Thx in advance,
TJ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:44:02+00:00Added an answer on May 31, 2026 at 6:44 pm

    Ok, I found the problem.

    It sounds a little weird, but the problem is the following (I didn’t mentioned it in my question, cause I never suggested that it could be the build process which causes the problems):

    I defined a final name in my pom:

    <build>
    <finalName>mytest</finalName>
    

    And this is exactly the problem. When I remove this line, everything works perfect…

    Can someone tell me why this it is problematic to enter a final name when building a war?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to Android and Google chrome web application development. I want to create
I am new to Facebook application development. I want to create a test user
I am new to iphone development, i want to create SMS application in my
I want to create an Application with tabs, and I have found this guide
I am new to Symbian development(also in c++). i want to create a multiple
I want to add new custom SQL Server Role and assign the new users
I want to create a simple web service in Eclipse (Helios J2EE), using Apache
I am new with xcode. I want to create a simple interface in xcode
Hi I'm very new to android development, and want to create an app with
I'm quite new with couchdb and I want to create a view based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.