Question

I am developing a GWT application, but I got the following Exception when I deploy it into a Equinox-jetty server:

404 Servlet class com.cartif.gui.autentication.server.AppServiceImpl is not a javax.servlet.Servlet <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Servlet class com.cartif.gui.autentication.server.AppServiceImpl is not a javax.servlet.Servlet</title>
</head>
<body><h2>HTTP ERROR 404</h2>
    <p>Problem accessing /baasGUIAutentication/baasgui/autentication. Reason:
    <pre>    
    Servlet class com.cartif.gui.autentication.server.AppServiceImpl is not a javax.servlet.Servlet</pre></p><h3>Caused by:</h3><pre>javax.servlet.UnavailableException: Servlet class com.cartif.gui.autentication.server.AppServiceImpl is not a javax.servlet.Servlet
         at org.mortbay.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:362)
         at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:243)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
         at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
         at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
         at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
         at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
         at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
         at org.springframework.osgi.web.deployer.jetty.JettyWarDeployer.startWebAppContext(JettyWarDeployer.java:210)
         at org.springframework.osgi.web.deployer.jetty.JettyWarDeployer.startDeployment(JettyWarDeployer.java:122)
         at org.springframework.osgi.web.deployer.support.AbstractWarDeployer.deploy(AbstractWarDeployer.java:93)
         at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$DeploymentManager$DeployTask.doRun(WarLoaderListener.java:257)
         at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$DeploymentManager$BaseTask.run(WarLoaderListener.java:215)
         at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66)
         at java.util.TimerThread.mainLoop(Unknown Source)
         at java.util.TimerThread.run(Unknown Source)

    </pre>
<hr /><i><small>Powered by Jetty://</small></i><br/> 

The code header for the AppServiceImpl class is:

public class AppServiceImpl extends RemoteServiceServlet implements AppService  

And AppService:

@RemoteServiceRelativePath("autentication")
public interface AppService extends RemoteService {
    User getUser(String user, String pass) throws Exception;
}

Moreover, the web.xml declares the servlet as follows:

<servlet>
    <servlet-name>baasguiServlet</servlet-name>
    <servlet-class>com.cartif.gui.autentication.server.AppServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>baasguiServlet</servlet-name>
    <url-pattern>/baasgui/autentication</url-pattern>
</servlet-mapping>

And baasgui is the folder where the GWT Java code is compiled. I have also checked the javax.servlet class and it is used only once.

Could anyone help me??

Thank you very much in advance!! Jose

Était-ce utile?

La solution 3

I got the solution. In the GWT libraries bundle I had to add the following lines:

Bundle-SymbolicName: gwtlibraries; singleton:=true
Require-Bundle: javax.servlet

Instead of importing packages, the tag Require-Bundle and the part of singleton bundle. Also in the GUI manifest I had to add the next line:

Bundle-SymbolicName: GUI; singleton:=true
Require-Bundle: gwtlibraries //apart from importing the specific libraries
Eclipse-RegisterBuddy: com.cartif.gwt
Eclipse-BuddyPolicy: registered

This was not happening with the previous versions of the GWT libraries I had deployed, but the bundle structure was different because now I am using the unzipped libraries and in previous ones the zipped jar files.

Thank you for your collaboration and help!!!!

Autres conseils

This typically happens if you embed the javax.servlet package into your bundle. Then jetty sees the normal javax.servlet deployed as a bundle while your application sees only the embedded class. So the interfaces are considered to be different.

The best solution is to not embed external stuff into your bundle. If you can not avoid it then export and import the javax.servlet package. So the framework can wire jetty and you bundle to the same classloader providing the package.

  • Start equinox with console
    • If it is equinox 3.7.x, -Dosgi.console=6666
    • If it is equinox 3.8 or newer: -Dosgi.console.enable.builtin=true -Dosgi.console=6666
  • You will be able to telnet to port 6666
  • Enter the command in telnet session: packages javax.servlet
  • In the result list, you will see that the package is available in your OSGi container multiple times. Jersey wires to one of them while your wab wires to the other one. Try to achieve having the package only ones in the container.

Here is a rather mundane reason why I got this exception. I adapted my new servlet from an old servlet. Right above the class definition in the .java file, there is a line of the kind: @WebServlet(name="OldServlet",urlPatterns={"/OldServlet"}). Although I properly renamed my class from OldServlet to NewServlet throughout (in the java and web.xml files), I forgot to change the name in the above line. After I changed the above line to @WebServlet(name="NewServlet",urlPatterns={"/NewServlet"}), I stopped getting this exception. Hope this helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top