Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » download service servlet error on Tomcat 8
download service servlet error on Tomcat 8 [message #1803482] Fri, 01 March 2019 13:03 Go to next message
Hsuan-Ming Chen is currently offline Hsuan-Ming ChenFriend
Messages: 2
Registered: February 2019
Junior Member
Recently, I have made an Eclipse RAP program using javax servlet package to create a File Download service. It works pretty well when using the built-in server inside the Eclipse IDE. However, after deploying the program on the Tomcat server, while opening the download link, the error message shows HTTP 500 error as following:

Type: Exception Report

Message: Servlet execution threw an exception Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception: javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(

Root Cause: java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpServletResponse" testproject.DownloadServiceHandler.service( org.eclipse.rap.rwt.engine.RWTServlet.handleValidRequest( org.eclipse.rap.rwt.engine.RWTServlet.handleRequest( org.eclipse.rap.rwt.engine.RWTServlet.doGet( javax.servlet.http.HttpServlet.service( javax.servlet.http.HttpServlet.service( org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service( org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl$LegacyServlet.service( org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service( org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest( org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch( org.eclipse.equinox.http.servlet.internal.servlet.ProxyServlet.service( javax.servlet.http.HttpServlet.service( org.eclipse.equinox.servletbridge.BridgeServlet.service( javax.servlet.http.HttpServlet.service( org.apache.tomcat.websocket.server.WsFilter.doFilter(

Following is my code and related file:
package testproject;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
import org.eclipse.rap.rwt.client.WebClient;

public class BasicApplication implements ApplicationConfiguration {

    public void configure(Application application) {
        Map<String, String> properties = new HashMap<String, String>();
        properties.put(WebClient.PAGE_TITLE, "Test Project");
        application.addEntryPoint("/", BasicEntryPoint.class, properties);

public class BasicEntryPoint extends AbstractEntryPoint {

    protected void createContents(Composite parent) {
        parent.setLayout(new GridLayout(2, false));

        Button downloadButton = new Button(parent, SWT.PUSH);
        downloadButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              try {
                    File testfile = new File("/home/user/Desktop/test.file");
                    byte[] fileContent = Files.readAllBytes(testfile.toPath());
                    sendDownload(fileContent, testfile.getName());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block

    public boolean sendDownload(byte[] data, String filename) {
        DownloadServiceHandler service = new DownloadServiceHandler(data, filename);
        UrlLauncher launcher = RWT.getClient().getService(UrlLauncher.class);
        return true;

public class DownloadServiceHandler implements ServiceHandler {

    private final byte[] data;
    private final String filename;
    private String id;

    public DownloadServiceHandler(byte[] data, String filename) { = data;
        this.filename = filename; = calculateId();

    public String getURL() {
        return RWT.getServiceManager().getServiceHandlerUrl(getId());

    private String getId() {
        return id;

    private String calculateId() {
        return String.valueOf(System.currentTimeMillis()) + data.length;

    public boolean register() {
        try {
            RWT.getServiceManager().registerServiceHandler(getId(), this);
            return true;
        } catch (Exception e) {
            System.out.println("failed to register download service handler");
            return false;

    private boolean unregister() {
        try {
            return true;
        } catch (Exception e) {
            System.out.println("failed to unregister download service handler");
            return false;

    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        try {
            response.setContentType("application/octet-stream"); // this is the error line ""
            response.setHeader("Content-Disposition", "attachment; filename=\"" + filename
                    + "\"");
        } catch (Exception e) {
            System.out.println("failed to dispatch download");
        } finally {


Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Testproject
Bundle-SymbolicName: testproject
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: testproject
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.rap.rwt;bundle-version="[3.0.0,4.0.0)"
Service-Component: OSGI-INF/contribution.xml
Import-Package: javax.servlet;version="3.1.0",
Bundle-ClassPath: .

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www osgi org/xmlns/scr/v1.1.0" name="BasicApplication">
   <implementation class="testproject.BasicApplication"/>
      <provide interface="org.eclipse.rap.rwt.application.ApplicationConfiguration"/>

How am I suppose to fix this bug? I do not know how come it works in Eclipse IDE but not working after deploying it on the Tomcat server. Thanks in advance.
Re: download service servlet error on Tomcat 8 [message #1803582 is a reply to message #1803482] Mon, 04 March 2019 23:55 Go to previous message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
Are you packaging javax.servlet in your WAR file? you may have multiple copies of the servlet classes.
Previous Topic:check size and format before FileUpload
Next Topic:Show Image from Server on Browsers Canvas
Goto Forum:

Current Time: Sat Jan 28 08:02:25 GMT 2023

Powered by FUDForum. Page generated in 0.05468 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top