Quantcast
Channel: BTSoru.com - Bilisim ve Yazilim Teknolojileri Soru/Cevap Platformu - latest questions
Viewing all articles
Browse latest Browse all 4270

Guice Servlet Eklentisi

$
0
0

Bir servlet app için Guice Servlet Extension kullanıyorum. Ama uygulama deploy olmasına rağmen isteklere cevap vermiyor. Aynen dökümandaki gibi yaptım. Web.xml dosyası:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="myapp" version="2.5">

    <listener>
        <listener-class>myapp.Initialization</listener-class>
    </listener>

    <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>

    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Initialization.java:

public final class Initialization extends GuiceServletContextListener{

    private static Logger logger = LoggerFactory.getLogger( Initialization.class );
    ......

    @Override
    public void contextInitialized( ServletContextEvent sce ){
        super.contextInitialized( sce );

        logger.info( "Initializing application" );

        servletContext = sce.getServletContext();
        // ... my own codes ...
    }

    @Override
    public void contextDestroyed( ServletContextEvent sce ){
        super.contextDestroyed( sce );
        servletContext = null;
    }

    @Override
    protected Injector getInjector(){
        logger.info( "Creating injector" );

        return Guice.createInjector( new ServletModule(){

            @Override
            protected void configureServlets(){
                logger.debug( "Configuring servlets" );

                // filters
                filter( "/*" ).through( SessionFilter.class );

                //servlets
                serve( "/frontcontroller/*" ).with( FrontControllerServlet.class );
            }
        } );
    }
}

Tüm logları log file'da görüyorum ama servlete bir türlü erişemedim. 2 gündür üzerinde çalışmama rağmen nerede hata yaptığımı bir türlü bulamadım :( Yardımlarınız için şimdiden teşekkürler..


Viewing all articles
Browse latest Browse all 4270