Bad usage of web.xml by GWT application. Does not see servlet init-param

I'm trying to run my GWT application (based on maven) with usage of web.xml from src/main/webapp/WEB-INF/web.xml which I properly set in the configuration (see attachment).


This is a piece of web.xml:

<servlet>
    <servlet-name>TiaServicesInitSerlvlet</servlet-name>
    <servlet-class>pl.ncdc.tia.service.server.TiaServicesInitServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>DefaultAuthService</servlet-name>
    <servlet-class>pl.ncdc.tia.service.server.DefaultAuthService</servlet-class>
    <init-param>
        <param-name>SessionManagerImpl</param-name>
        <param-value>pl.ncdc.fair.claims.server.SchantzSessionManager</param-value>
    </init-param>
</servlet>

TiaServicesInitSerlvlet is responsible for connecting to DB. It works properly. But.... when DefaultAuthService is invoked I haven't access to its init-param. In this piece of code I got null in the attribute variable:

public class DefaultAuthService extends RemoteServiceServlet implements AuthService {
        @Override
        public void init(final ServletConfig config) throws ServletException {
        super.init(config);
        final ServletContext ctx = getServletContext();
        final String attribute = config.getInitParameter("SessionManagerImpl");
        [...]

It works good in Eclipse and in IDEA with maven-jetty-plugin. Also works great as a .war file. But I need of course to work in Intellij to develop an application in my favourite IDE   



 


I've made a JIRA issue for this http://www.jetbrains.net/jira/browse/IDEA-22008 but maybe someone has this problem too or knows the workaround.



Attachment(s):
run_config.png
8 comments
Comment actions Permalink

Hi again,
really anybody who can help me? Please tell me what and I will provide additional information.
I think this is vast bug... Am I wrong?

Thanks

0
Comment actions Permalink

In hosted mode GWT uses its own GWTShellServlet to process requests to remote services. So when you run GWT configuration with custom web.xml IDEA
removes all "servlet" tags related to remote services from web.xml.

I'm trying to run my GWT application (based on maven) with usage of web.xml from src/main/webapp/WEB-INF/web.xml which I properly set in the configuration (see attachment).


This is a piece of web.xml:

<servlet>
<servlet-name>TiaServicesInitSerlvlet</servlet-name>
<servlet-class>pl.ncdc.tia.service.server.TiaServicesInitServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>DefaultAuthService</servlet-name>
<servlet-class>pl.ncdc.tia.service.server.DefaultAuthService</servlet-class>
<init-param>
<param-name>SessionManagerImpl</param-name>
<param-value>pl.ncdc.fair.claimsserver.SchantzSessionManager</param-value>
</init-param>
</servlet>

TiaServicesInitSerlvlet is responsible for connecting to DB. It works properly. But.... when DefaultAuthService is invoked I haven't access to its init-param. In this piece of code I got null in the attribute variable:

public class DefaultAuthService extends RemoteServiceServlet implements AuthService {
@Override
public void init(final ServletConfig config) throws ServletException {
super.init(config);
final ServletContext ctx = getServletContext();
final String attribute = config.getInitParameter("SessionManagerImpl");


It works good in Eclipse and in IDEA with maven-jetty-plugin. Also works great as a .war file. But I need of course to work in Intellij to develop an application in my favourite IDE



I've made a JIRA issue for this http://www.jetbrains.net/jira/browse/IDEA-22008 but maybe someone has this problem too or knows the workaround.

---
Original message URL: http://www.jetbrains.net/devnet/message/5232539#5232539


------------------------------------------------------------------------



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

OK, you are right, but GWT creates tomcat directory where is web.xml. I have defined my servlets there with <load-on-startup> and IDEA does not see them.

0
Comment actions Permalink

Hi Leszek,
I have created an issue that seems similar long time ago http://www.jetbrains.net/jira/browse/IDEADEV-27881
It has not been solved, but might contain some helpful information.

Adam

0
Comment actions Permalink

Hi,
thanks for help, but I don't use any other "framework" like Spring. This is pure GWT. You know, coping necessary files for each run is not a solution.

I really don't know why this problem occurs. If more people has this like issues, developing larger applications is completely useless :/

0
Comment actions Permalink

Will this workaround work for you?
- create Ant task which does the copy
- select this task in Run/Debug Configuration -> Run Ant target

0
Comment actions Permalink

IDEA copies all servlets from your web.xml except servlets inherited from RemoteServiceServlet to web.xml file generated by GWT. So if your servlet
isn't GWT Remote service servlet it should work ok. When GWT shell is running you can find web.xml used by GWT in
<idea.system.path>/gwt/<project_name...>/<module_name...>/run/tomcat/webapps/root/web-inf folder to see if your servlet is copied into it.

OK, you are right, but GWT creates tomcat directory where is web.xml. I have defined my servlets there with <load-on-startup> and IDEA does not see them.

---
Original message URL: http://www.jetbrains.net/devnet/message/5233153#5233153



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Under the path you have described is web.xml, but this is whole content:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>

        <servlet>
                <servlet-name>shell</servlet-name>
                <servlet-class>com.google.gwt.dev.shell.GWTShellServlet</servlet-class>
        </servlet>
       
        <servlet-mapping>
                <servlet-name>shell</servlet-name>
                <url-pattern>/*</url-pattern>
        </servlet-mapping>

</web-app>

GWT compilator produces tomcat/webapps[...] directory where web.xml is produced and by default filled with these servlets:
  <servlet>
    <servlet-name>shell</servlet-name>
    <servlet-class>com.google.gwt.dev.shell.GWTShellServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>shell</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

And GWT uses this file to maintain application in GWT Hosted mode. I had modified this web.xml (I remind it works with Eclipse) to maintain our servlets:
<?xml version="1.0" encoding="UTF-8"?>
<web-app  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"
          version="2.4">
         
  <context-param>
    <param-name>webapp-name</param-name>
    <param-value>fair-web-claims</param-value>
  </context-param>
  
  <servlet>
    <servlet-name>TiaServicesInitSerlvlet</servlet-name>
    <servlet-class>pl.ncdc.tia.service.server.TiaServicesInitServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>AuthService</servlet-name>
    <servlet-class>pl.ncdc.tia.service.server.DefaultAuthService</servlet-class>
    <init-param>
        <param-name>SessionManagerImpl</param-name>
          <param-value>pl.ncdc.fair.claims.server.SchantzSessionManager</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>shell</servlet-name>
    <servlet-class>com.google.gwt.dev.shell.GWTShellServlet</servlet-class>
    <init-param>
            <param-name>SessionManagerImpl</param-name>
              <param-value>pl.ncdc.fair.claims.server.SchantzSessionManager</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>shell</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
 
</web-app>

As you can see IDEA does not take this web.xml at all.
DefaultAuthService is a RemoteServiceServlet, but TiaServicesInitSerlvlet is a HTTPServlet and isn't invoked too. Nothing will be, because web.xml in Caches dir is quite empty.

Guest wrote:

IDEA copies all servlets from your web.xml except servlets inherited from RemoteServiceServlet to web.xml file generated by GWT. So if your servlet
isn't GWT Remote service servlet it should work ok.


I've made a test and that's not true. When I delete tomcat directory generated by GWT and run a HostedMode, GWT don't create a new one, but it should vide:
http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=DevGuideDirectoriesPackageConventions

"tomcat/     Directory created for hosted mode's internal tomcat server. This directory is created automatically when hosted mode is run sucessfully for the first time."
Application started and showed me a site.

Thanks!

0

Please sign in to leave a comment.