创建.exe时,Restlet API停止工作

时间:2014-11-26 11:27:48

标签: java restlet restful-url exe4j

我正在创建一个使用Restlet来创建restful API的Java应用程序。 从Eclipse运行它时效果很好,但每当我生成一个.exe文件(exe4j)并从那里运行它时,restful API停止工作,显示Not found错误(10.4.5 404 Not实测值)

为什么会这样?

据我所知,我在创建.exe时包含了所有需要的库。这是我在exe4j中使用的.xml文件:

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

如果这完全相关,这就是我创建路线的方式:

   /* 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 个答案:

答案 0 :(得分:1)

很难说,我不知道exe4j。

我看到的是,您使用exe4jc.exe来自${lib}的广告,但您没有引用${dist}/${ant.project.name}.jar。因此,构建的代码似乎不会进入可执行文件。这就是服务器无法找到它的原因(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>