【问题标题】:Enable static weaving in eclipselink在 eclipselink 中启用静态编织
【发布时间】:2012-05-30 09:31:17
【问题描述】:

当我运行使用 jpa 的 rcp 应用程序时,我收到了这些警告消息:

[EL Info]: 2012-05-23 22:29:26.841--ServerSession(20341825)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Warning]: 2012-05-23 22:29:27.338--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [infoid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [groupid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeSchedule] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeescheduleid] for the entity class [class org.company.management.entity.EmployeeScheduleInfo] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [scheduleid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.341--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employee] for the entity class [class org.company.management.entity.EmployeeInfo] since weaving was not enabled or did not occur.
[EL Info]: 2012-05-23 22:29:27.556--ServerSession(20341825)--bundleresource://29.fwk31583837:2_Management login successful

我想启用延迟加载。

我的 persistence.xml 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="Management" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.company.management.entity.EmployeeGroup</class>
<class>org.company.management.entity.Company</class>
<class>org.company.management.entity.Employee</class>
<class>org.company.management.entity.Schedule</class>
<class>org.company.management.entity.EmployeeInfo</class>
<class>org.company.management.entity.EmployeeSchedule</class>
<class>org.company.management.entity.EmployeeScheduleInfo</class>

<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:derby:.cafedb;create=true"/>
  <property name="javax.persistence.jdbc.password" value="vodbomb"/>
  <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
  <property name="javax.persistence.jdbc.user" value="root"/>

  <property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>

我有一个构建脚本“build.xml”来进行静态编织:

<project name="Management" basedir=".">
<target name="define.task" description="New task definition for toplink static weaving">
<taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
</taskdef>
</target>    
<target name="weaving" description="perform weaving" depends="define.task"
<weave  source="${basedir}/src/org/company/management/entity"
                target="${basedir}/src/org/company/management/entity/woven.jar"
                persistenceinfo="${basedir}/META-INF/persistence.xml">     
</weave>
</target>
</project>

当我运行 ant 脚本“build.xml”时,我遇到了这个错误:

Buildfile: C:\Users\J\workspace\org.company.management\build.xml
define.task:
weaving:

BUILD FAILED
C:\Users\J\workspace\org.company.management\build.xml:13: Exception [EclipseLink-40007]     (Eclipse Persistence Services - 2.3.2.v20111125-r10461):     org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: An exception was thrown while weaving:     C:\Users\J\workspace\org.company.management\src\org\company\management\entity
Internal Exception: Exception [EclipseLink-40001] (Eclipse Persistence Services -     2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: An exception was thrown while trying to open an archive from     URL: file:/C:/Users/J/workspace/org.company.management/META-INF/persistence.xml 
Internal Exception: java.util.zip.ZipException: error in opening zip file

Total time: 242 milliseconds

如何开启静态编织???我一团糟

【问题讨论】:

    标签: jpa eclipselink rcp


    【解决方案1】:

    How to apply Static Weaving Ant Task with Eclipse-Link JPA in Netbeans?

    结合问题和答案,您将获得有效的示例。

    【讨论】:

      【解决方案2】:

      我认为您的问题是源应该是 jar,而不是目录。尝试给它一个已编译类的 jar。

      看,

      http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

      【讨论】:

        【解决方案3】:

        使用 DALI SETTINGS 在 Eclipse 中打开它。请注意,我必须打开 Projects->Build Automatically 设置,否则它会不断重建文件!

        【讨论】:

          【解决方案4】:

          您的persistance.xml 中缺少静态编织声明:

          <properties>
              ...
              <property name="eclipselink.weaving" value="static"/>
              ...
          </properties>
          

          【讨论】:

            【解决方案5】:

            你需要在你的 persistence.xml 中有这个属性

            <property name="eclipselink.weaving" value="static"/>
            

            如果您愿意,可以使用展开的目录结构而不是 jar 文件。

            当persistenceinfo位置中有空格时我遇到了问题,所以我在编织它们之前将我的persistence.xml文件移动到要编织的类文件的位置。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2013-08-31
              • 2019-07-22
              • 1970-01-01
              • 1970-01-01
              • 2015-04-13
              • 2011-10-25
              • 2017-05-24
              • 1970-01-01
              相关资源
              最近更新 更多