Restlet API stops working when creating a .exe

146 views Asked by At

I'm making a Java application which uses Restlet to create a restful API. It works pretty well when running it from Eclipse but whenever I generate a .exe file (with exe4j ) and I run it from there the restful API stops working showing a Not found error (10.4.5 404 Not Found)

Why is this happening?

I'm including all the needed libraries when creating the .exe as far as I know. This is my .xml file used in exe4j:

    <pathelement location="${lib}/com.mysql.jdbc_5.1.5.jar" />
    <pathelement location="${lib}/jacob.jar" />
    <pathelement location="${lib}/joda-time-2.3.jar" />
    <pathelement location="${lib}/json-simple-1.1.1.jar" />
    <pathelement location="${lib}/junit-4.11.jar" />
    <pathelement location="${lib}/log4j-api-2.0.1.jar" />
    <pathelement location="${lib}/log4j-core-2.0.1.jar" />
    <pathelement location="${lib}/mail.jar" />
    <pathelement location="${lib}/ojdbc6.jar" />
    <pathelement location="${lib}/org.restlet.jar" />
    <pathelement location="${lib}/pdfbox-app-1.8.0.jar" />
    <pathelement location="${lib}/sigar.jar" />
    <pathelement location="${lib}/sqlite-jdbc-3.7.2.jar" />
    <pathelement location="${lib}/guava-17.0.jar" />
    <pathelement location="${lib}/zeromq.jar" />

In case this is relevant at all, here's the way I create the routes:

   /* Creates a root Restlet that will receive all incoming calls.*/
   @Override
   public Restlet createInboundRoot() {
       // Create a router Restlet that routes each call to  the relevant instance
       Router router = new Router(getContext());

       // Defines routes
       router.attach("/users", UsersController.class);
       router.attach("/departments", DepartmentsController.class);
       router.attach("/absences", AbsencesController.class);

       router.attachDefault(RestDefault.class);

       return router;
   }
1

There are 1 answers

5
PeterMmm On BEST ANSWER

Hard to say, I don't know exe4j.

What I see is, that you use exe4jc.exe with jars from ${lib} but you don't reference to ${dist}/${ant.project.name}.jar. So it seems your code that is build won't get into the executable. That is the reason the server cannot find it (404).

    <!-- Put everything in ${build} into the <Project>.jar file -->
    <jar jarfile="${dist}/${ant.project.name}.jar" basedir="${build}"/>

    <!-- Copy MY program into lib to get packed by exe4jc -->
    <copy file="${dist}/${ant.project.name}.jar" todir="${lib}"/>

    <!-- Create an exe -->
    <apply executable="c:\Program Files\exe4j\bin\exe4jc.exe" failonerror="true">
      <fileset dir="${lib}">
        <patternset>
          <include name="${ant.project.name}.exe4j"/>
        </patternset>
      </fileset>
    </apply>