在Eclipse安装iDempiere

来自iDempiere zh
跳转至:导航搜索

在Eclipse安装iDempiere

如果您要进行源代码开发,您必须在Eclipse环境下安装源代码树 (source tree?)

友情提示:由于国内的网络环境,有几个安装环节的报错往往跟网络有关,为此建议:

1. 选择稳定、可靠、畅通的互联网接入点;
2. 如果屡屡报错,必要时尝试一下翻(墙)是否有改善。(如涉及当地法律,请自担风险)

网络不畅容易导致报错的环节有:

  1. Eclipse 插件安装
  2. Buckminster源代码库下载/更新
  3. 项目导入和具体化 (Import & Materializing )

具体报错见文后所附报错举例。


环境前置要求

即准备工作
另外可以参看Carlos之前的一篇文章:http://www.globalqss.com/wiki/index.php/IDempiere/Install_Prerequisites_on_Ubuntu

操作系统

Linux, MS Windows 或 MacOS

JDK

Java Development Kit (JDK)是指Java开发环境。
建议用Java6。你可以用Sun Java 6 或者 OpenJDK6。iDempiere 在Java7 也能运行,但是会跳出一些警告提示。

数据库

PostgreSQL 9.1或更高版本。iDempiere 仍然可以在PostgreSQL 8.4 下工作,但是存在一些特殊问题。

源代码管理工具

Mercurial 客户端。 hg 的命令行。 用来从 Buckminster 更新源代码。

Eclipse

建议使用 Eclipse Indigo 3.7.2.
  • 使用 Eclipse Indigo 3.7 版本开发 iDempiere 是最安全、最简易的方法。大多数问题总是来源于使用了不同的版本,没有尊照本文所规定的环境前置要求。
  • 有用户报告 Eclipse 同样可行,例如 Eclipse Juno 4.2 (TBayen 报告), Eclipse Kepler SP2 4.3 (Banym 报告)。如果你准备使用新的版本,你需要自担风险。

Eclipse 插件: Eclipse Mercurial

  • Eclipse Mercurial 用于代码提交,如果你不需要提交代码,这个插件可以略过不安装。
  • Eclipse 菜单路径: 英文: Help -> Install New Software -> Add 。 中文:帮助 -> 安装新软件 -> 添加
  • 名称:Eclipse Mercurial
  • 更新网站/Update Site: http://cbes.javaforge.com/update
  • 只选择包"Mercurial Eclipse",其他的不需要。

Eclipse 插件: Buckminster


下载 iDempiere 代码树

选择你信任的主干资料库( trunk repository),然后进行克隆:

 hg clone https://bitbucket.org/idempiere/idempiere idempiere

iDempiere 代码下载小窍门

在国内,由于网络环境等方面的原因,从 https://bitbucket.org 更新代码速度慢,而且经常会断线失败。这里有两种途径来解决。

方法一:利用打包好的完整资料库

利用已经打包好了的完整资料库,在这个基础上进行更新,例如 idempiere_hgrepo_v1.0c.zip ,或者 idempiere_hgrepo_v2.0.zip

 $ unzip -d /app/idempiere idempiere_hgrepo_v2.0.zip
  • 第三步:更新到最新的代码。示例:
 $ cd /app/idempiere
 $ hg pull -u
  • 现在,你的代码库已经是最新的了。

方法二:分而治之,增量更新

由于 Mercurial 并不直接支持增量更新,所以窍门是先克隆第一个修改版本,然后分批增量拉取修改版本。示例如下:

 hg clone -r 1 https://bitbucket.org/idempiere/idempiere
 cd idempiere
 hg pull -r 100 -u
 hg pull -r 200 -u
 hg pull -r 300 -u
 hg pull -r 400 -u
 hg pull -r 500 -u
 ... 一直下去,直到代码库的当前修改版本。

设置Eclipse Workspace

有两篇图文并茂的优秀文章讲解iDempiere在Eclipse的设置:

转换 Workspace

  • Eclipse 菜单路径:英文:File -> Switch Workspace -> Other。 中文: 文件 -> 变更工作区 -> 其他
  • 选择之前你克隆代码库的目录作为workspace。

项目具体化

接下来是在 Eclipse 里对 iDempiere 项目进行具体化 ( materialize )。也就是从互联网下载所有的依赖或关联包。

  • Eclipse 菜单路径:
    • 英文: File -> Import -> Buckminster -> Materialize from Buckminster MSPEC, CQUERY or BOM
    • 中文: 文件 -> 导入 -> Buckminster -> 从Buckminster MSPEC, CQUERY或BOM具体化
  • 点击按钮 "Next" / "下一步",选择workspace目录 org.adempiere.sdk-feature 文件夹下的 adempiere.cquery 。
注意:浏览文件时注意右下角的文件类型选为:*.cquery 。
  • 接下来 Eclipse 会花费一些时间检验依赖性,之后你就可以点击"Finish"/"完成"按钮。

现在是美好的咖啡时间了,Eclipse会下载并配置整个项目,这会花费很长的时间。

呃,这是老外的咖啡时间,而国内的朋友往往是噩梦的开始,各种花样的报错就在这里不断地冒出来。绝大多数问题基本上是两大原因,第一大原因是没有严格按本文的要求进行安装,例如软件版本号、具体配置等等,如果你严格遵守了,那么剩下的基本上是国内网络环境的问题了,如果有朋友在国内不需要翻(墙)就能顺利进行的话,欢迎您把方法共享给大家。
  • 友情提示:当这一步完成后,建议你关闭Eclipse,备份你的Workspace/工作区。将来你要是把事情弄糟了,还可以从备份中恢复,而不需要从互联网整个重新下载。

报错分析:NoClassDefFoundError

"Java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetPlatformService"

这个报错基本出现在 Eclipse Juno 版本,在 Eclipse Indigo 3.7 版本上不会出现。因此建议使用Eclipse Indigo 3.7。

重建和启动

你可以标记所有项目,点击鼠标右键,选择菜单中的 Refresh 刷新你的Eclipse项目。然后你打开菜单 "Project -> Clean ..." / "项目 -> 清理..." ,重建整个Workspace/工作区。接下来就你可以启动 iDempiere 代码了。

启动方法一:菜单 "Run -> Debug Configurations...",在窗口左栏选择"Eclipse Application" > "swingclient.product",然后点击"Debug"按钮启动。

启动方法二:在Package Explorer栏目中选择 org.adempiere.ui.swing,然后鼠标右键 -> Run As > Eclipse Application。

附录:常见报错举例

Eclipse插件更新报错

这里是 Eclipse Mercurial 插件更新报错,"connect timed out"是典型的网络问题。

An error occurred while collecting items to be installed
session context was:(profile=PlatformProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Unable to read repository at http://cbes.javaforge.com/update/features/mercurialeclipse_2.0.0.v201210091230.jar.
connect timed out

项目导入:依赖分析报错

项目导入依赖分析报错,java.lang.NoClassDefFoundError 无法找到类定义,也跟网络不稳定有关

java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetPlatformService
ERROR   [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
ERROR   [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
Errors and Warnings
E [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
ERROR   [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
Errors and Warnings
E [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
ERROR   [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle
Errors and Warnings
E [0001] : java.lang.NoClassDefFoundError: org/eclipse/pde/internal/core/target/provisional/ITargetHandle: org/eclipse/pde/internal/core/target/provisional/ITargetHandle


项目具体化报错1:未找到资料库

No repository found containing ... 无法找到包含...的资料库。也网络问题造成,找不到对应的资料库。

An error occurred while collecting items to be installed
session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.draw2d,3.7.2.v20111017-2020
No repository found containing: osgi.bundle,org.eclipse.emf.common,2.7.0.v20120127-1122
No repository found containing: osgi.bundle,org.eclipse.emf.common.ui,2.7.0.v20120130-0943
No repository found containing: osgi.bundle,org.eclipse.emf.ecore,2.7.0.v20120127-1122
No repository found containing: osgi.bundle,org.eclipse.emf.ecore.change,2.7.1.v20120127-1122
No repository found containing: osgi.bundle,org.eclipse.emf.ecore.xmi,2.7.0.v20120127-1122
No repository found containing: osgi.bundle,org.eclipse.emf.edit,2.7.2.v20120130-0943
No repository found containing: osgi.bundle,org.eclipse.emf.edit.ui,2.7.0.v20120130-0943

项目具体化报错2:无法读取资料库

Unable to read repository - 无法读取资料库。网络问题造成,找到了对应的资料库,但是无法读取,比如响应时间过长。

Unable to read repository at http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/.
Unable to read repository at http://archive.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/.
Premature end of file.

ERROR   [0002] : Unable to read repository at http://archive.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/.
Errors and Warnings
TAG-ID 0002 = Query for org.adempiere.sdk:eclipse.feature, path: org.adempiere.sdk:eclipse.feature$2.0.0.qualifier

项目具体化报错3:连接失败

Connection to ... failed - 连接失败,网络问题。

Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.net/maven-metadata.xml failed on maven.restlet.com. Retry attempt 1 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.servlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 1 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 1 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.ssl/maven-metadata.xml failed on maven.restlet.com. Retry attempt 1 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 2 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.net/maven-metadata.xml failed on maven.restlet.com. Retry attempt 2 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.ssl/maven-metadata.xml failed on maven.restlet.com. Retry attempt 2 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.servlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 2 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 3 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.net/maven-metadata.xml failed on maven.restlet.com. Retry attempt 3 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.ssl/maven-metadata.xml failed on maven.restlet.com. Retry attempt 3 started
Connection to http://maven.restlet.org/org/restlet/osgi/org.restlet.ext.servlet/maven-metadata.xml failed on maven.restlet.com. Retry attempt 3 started
ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in resourceMap file:/home/store/workspace/idempiere/org.adempiere.sdk-feature/adempiere.rmap
  ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.jar
    ERROR   [0011] : Rejecting provider p2(file:///{0}/lib[file:////home/store/workspace/idempiere/lib]): No component match was found
  ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath restlet.maven
    ERROR   [0011] : Rejecting provider maven2(http://maven.restlet.org[http://maven.restlet.org]): No component match was found
      ERROR   java.net.UnknownHostException: maven.restlet.com
  ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath orbit
    ERROR   [0011] : Rejecting provider p2(http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/[http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/]): No component match was found
  ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.project
    ERROR   [0011] : Resolution attempt ended with exception: Provider local(/home/store/workspace/idempiere/org.restlet): Missing CSpec source required by component type osgi.bundle
      ERROR   Provider local(/home/store/workspace/idempiere/org.restlet): Missing CSpec source required by component type osgi.bundle
  ERROR   [0011] : No suitable provider for component org.restlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.feature.project
    ERROR   [0011] : Rejecting provider local({0}/{1}-feature[/home/store/workspace/idempiere/org.restlet-feature]): Components of type osgi.bundle are not supported
ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in resourceMap file:/home/store/workspace/idempiere/org.adempiere.sdk-feature/adempiere.rmap
  ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.jar
    ERROR   [0004] : Rejecting provider p2(file:///{0}/lib[file:////home/store/workspace/idempiere/lib]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in searchPath restlet.maven
    ERROR   [0004] : Rejecting provider maven2(http://maven.restlet.org[http://maven.restlet.org]): No component match was found
      ERROR   java.net.UnknownHostException: maven.restlet.com
  ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in searchPath orbit
    ERROR   [0004] : Rejecting provider p2(http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/[http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.project
    ERROR   [0004] : Resolution attempt ended with exception: Provider local(/home/store/workspace/idempiere/org.restlet.ext.net): Missing CSpec source required by component type osgi.bundle
      ERROR   Provider local(/home/store/workspace/idempiere/org.restlet.ext.net): Missing CSpec source required by component type osgi.bundle
  ERROR   [0004] : No suitable provider for component org.restlet.ext.net:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.feature.project
    ERROR   [0004] : Rejecting provider local({0}/{1}-feature[/home/store/workspace/idempiere/org.restlet.ext.net-feature]): Components of type osgi.bundle are not supported
ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in resourceMap file:/home/store/workspace/idempiere/org.adempiere.sdk-feature/adempiere.rmap
  ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.jar
    ERROR   [0004] : Rejecting provider p2(file:///{0}/lib[file:////home/store/workspace/idempiere/lib]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath restlet.maven
    ERROR   [0004] : Rejecting provider maven2(http://maven.restlet.org[http://maven.restlet.org]): No component match was found
      ERROR   java.net.UnknownHostException: maven.restlet.com
  ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath orbit
    ERROR   [0004] : Rejecting provider p2(http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/[http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.project
    ERROR   [0004] : Resolution attempt ended with exception: Provider local(/home/store/workspace/idempiere/org.restlet.ext.servlet): Missing CSpec source required by component type osgi.bundle
      ERROR   Provider local(/home/store/workspace/idempiere/org.restlet.ext.servlet): Missing CSpec source required by component type osgi.bundle
  ERROR   [0004] : No suitable provider for component org.restlet.ext.servlet:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.feature.project
    ERROR   [0004] : Rejecting provider local({0}/{1}-feature[/home/store/workspace/idempiere/org.restlet.ext.servlet-feature]): Components of type osgi.bundle are not supported
ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in resourceMap file:/home/store/workspace/idempiere/org.adempiere.sdk-feature/adempiere.rmap
  ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.jar
    ERROR   [0004] : Rejecting provider p2(file:///{0}/lib[file:////home/store/workspace/idempiere/lib]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in searchPath restlet.maven
    ERROR   [0004] : Rejecting provider maven2(http://maven.restlet.org[http://maven.restlet.org]): No component match was found
      ERROR   java.net.UnknownHostException: maven.restlet.com
  ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in searchPath orbit
    ERROR   [0004] : Rejecting provider p2(http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/[http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/]): No component match was found
  ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.bundle.project
    ERROR   [0004] : Resolution attempt ended with exception: Provider local(/home/store/workspace/idempiere/org.restlet.ext.ssl): Missing CSpec source required by component type osgi.bundle
      ERROR   Provider local(/home/store/workspace/idempiere/org.restlet.ext.ssl): Missing CSpec source required by component type osgi.bundle
  ERROR   [0004] : No suitable provider for component org.restlet.ext.ssl:osgi.bundle/[2.1.0,2.2.0) was found in searchPath workspace.feature.project
    ERROR   [0004] : Rejecting provider local({0}/{1}-feature[/home/store/workspace/idempiere/org.restlet.ext.ssl-feature]): Components of type osgi.bundle are not supported
Connection to http://repository.springsource.com/maven/bundles/external/net/sourceforge/cglib/com.springsource.net.sf.cglib/2.2.0/com.springsource.net.sf.cglib-2.2.0.jar.md5 failed on connect timed out. Retry attempt 1 started
ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in resourceMap file:/home/store/workspace/idempiere/org.adempiere.sdk-feature/adempiere.rmap
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath workspace.bundle.jar
    ERROR   [0013] : Rejecting provider p2(file:///{0}/lib[file:////home/store/workspace/idempiere/lib]): No component match was found
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath gemini
    ERROR   [0013] : Rejecting provider p2(http://download.eclipse.org/gemini/updates/web/2.0.1/[http://download.eclipse.org/gemini/updates/web/2.0.1/]): No component match was found
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath spring.external.maven
    ERROR   [0013] : Resolution attempt ended with exception: Unable to read the 16 character hexadecimal form of the digest for http://repository.springsource.com/maven/bundles/external/net/sourceforge/cglib/com.springsource.net.sf.cglib/2.2.0/com.springsource.net.sf.cglib-2.2.0.jar.md5
      ERROR   Unable to read the 16 character hexadecimal form of the digest for http://repository.springsource.com/maven/bundles/external/net/sourceforge/cglib/com.springsource.net.sf.cglib/2.2.0/com.springsource.net.sf.cglib-2.2.0.jar.md5
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath orbit
    ERROR   [0013] : Rejecting provider p2(http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/[http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/]): No component match was found
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath workspace.bundle.project
    ERROR   [0013] : Resolution attempt ended with exception: Provider local(/home/store/workspace/idempiere/com.springsource.net.sf.cglib): Missing CSpec source required by component type osgi.bundle
      ERROR   Provider local(/home/store/workspace/idempiere/com.springsource.net.sf.cglib): Missing CSpec source required by component type osgi.bundle
  ERROR   [0013] : No suitable provider for component com.springsource.net.sf.cglib:osgi.bundle/[2.2.0,2.2.0] was found in searchPath workspace.feature.project
    ERROR   [0013] : Rejecting provider local({0}/{1}-feature[/home/store/workspace/idempiere/com.springsource.net.sf.cglib-feature]): Components of type osgi.bundle are not supported
Cookie帮助我们提供我们的服务。通过使用我们的服务,您同意我们使用cookie。