的Java Servlet项目和Android库项目在Eclipse中 - 的NoClassDefFoundError [英] java servlet project and android library project in eclipse - NoClassDefFoundError

查看:271
本文介绍了的Java Servlet项目和Android库项目在Eclipse中 - 的NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的工作区的一些项目:

I have some projects in my workspace :

AndroidMonitoring # an android application
MonitoringModel # an android library project
DataServlet # servlet project

AndroidMonitoring(它取决于MonitoringModel,

AndroidMonitoring (which depends on MonitoringModel,

)

编译和运行得很好,但我需要的MonitoringModel类可用也在DataServlet项目。我加入了模型作为DataServlet项目的Java构建路径依赖,但我得到:

compiles and runs just fine but I need the MonitoringModel classes to be available also in the DataServlet project. I added the Model as a dependency in the Java Build path of the DataServlet project but I get :

java.lang.NoClassDefFoundError: gr/uoa/di/monitoring/model/Battery
    gr.uoa.di.monitoring.server.servlets.DataCollectionServlet.doGet(DataCollectionServlet.java:20)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

我需要的模型是一个Android库项目,因为它包含了Android的类 - 但也包含了方法来解析在Servlet中的文件 - 这可能吗?我应该如何设置?

I need the Model to be an Android library project as it contains android classes - but also contains the methods to parse the files in the servlet - is it possible ? How should I set this up ?

修改:MonitoringModel是这里

EDIT : MonitoringModel is here

推荐答案

解决了!

  1. 从DataServlet的Java构建路径中删除相关
  2. 进入 MonitoringModel 的项目,并删除该库属性,运行它作为一个Android应用程序改造成一个库(从的here 清洁MonitoringModel项目
  3. 抓住从斌的monitoringmodel.jar /拖放到 DataServlet / WEB-INF / lib目录
  4. 刷新和运行在服务器
  5. <一个href="https://github.com/Utumno/DataCollectionServlet/commit/4d232dbcb69b38a02ccf3745d25f09744e3c87a6"相对=nofollow>做的!
  1. remove the dependency from DataServlet's java build path
  2. go to the MonitoringModel project and remove the library attribute, run it as an Android app remake it into a library (from here) Clean the MonitoringModel project
  3. grab the monitoringmodel.jar from bin/ and drop it into the DataServlet/WEB-INF/lib
  4. refresh and run on server
  5. done !

将尽力改善这个技巧(链接到外部罐子似乎并没有正常工作的BTW) - 更好的想法将被接受作为一个答案 - 但关闭此现在

Will try and improve on this hack (linking to an external jar did not seem to work btw) - any better ideas will be accepted as an answer - however closing this for now.

修改:显然步骤3,可以通过创建一个硬链接 DataServlet取代/ WEB-INF / lib目录/ monitoringmodel.jar 来monitoringmodel.jar - 还在测试这一一些动作场面断开链接记错。符号链接似乎没有工作,虽然 - 报告这是一个错误

EDIT : apparently step 3. can be substituted by creating a hard link from DataServlet/WEB-INF/lib/monitoringmodel.jar to monitoringmodel.jar - still testing this as some action sequences break the link methinks. Symbolic links do not seem to work though - reported this as a bug

EDIT2 :这似乎工作 - 但我离开的手动过程,因为它肯定工程

EDIT2 : this seems to work - but I leave the manual procedure as it definitely works

  1. 从DataServlet的Java构建路径中删除相关
  2. 硬链接的monitoringmodel.jar从斌/并向 DataServlet / WEB-INF / lib目录。我用外壳链接扩展,但这样的:

  1. remove the dependency from DataServlet's java build path
  2. Hard link the monitoringmodel.jar from bin/ and to the DataServlet/WEB-INF/lib. I used shell link extension but this :

mklink /H c:\path\to\WebContent\WEB-INF\lib\monitoringmodel.jar c:\path\to\bin\monitoringmodel.jar

也应努力

现在每次你做的监控模型的改变罐子被更新。你只需要的刷新的servlet的项目(默认情况下将重新部署在服务器上自己的)

Now everytime you make a change in monitoring model the jar is updated. You only have to refresh the servlet project (will be redeployed on server on its own by default)

<子>澄清:当然servlet的项目并不意味着使用安卓* 类 - 这不是我的问题 - 我的问题是有模型code。在一个地方,这个地方必须是一个Android库

Clarification : of course the servlet project is not meant to use android.* classes - this was not my issue - my issue was to have the model code in one place and this place had to be an android library

这篇关于的Java Servlet项目和Android库项目在Eclipse中 - 的NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆