问题描述
我有我的工作区的一些项目:
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
推荐答案
解决了!
- 从DataServlet的Java构建路径中删除相关
- 清洁MonitoringModel项目
- 抓住从斌的monitoringmodel.jar /拖放到
DataServlet / WEB-INF / lib目录
- 刷新和运行在服务器
- 做的!
- remove the dependency from DataServlet's java build path
- Clean the MonitoringModel project
- grab the monitoringmodel.jar from bin/ and drop it into the
DataServlet/WEB-INF/lib
- refresh and run on server
- 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
- 从DataServlet的Java构建路径中删除相关
-
硬链接的monitoringmodel.jar从斌/并向
DataServlet / WEB-INF / lib目录
。我用外壳链接扩展,但这样的:
- remove the dependency from DataServlet's java build path
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库
这篇关于的Java Servlet项目和Android库项目在Eclipse中 - 的NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!