0

I use eclipselink 2.6.3. And I have two classes:

@Entity
class ClassA extends ClassB{...}

@MappedSuperclass
class ClassB{...}

And I do static weaving using maven-plugin:

           <plugin>
               <groupId>de.empulse.eclipselink</groupId>
               <artifactId>staticweave-maven-plugin</artifactId>
               <version>1.0.0</version>
               <executions>
                   <execution>
                       <phase>process-classes</phase>
                       <goals>
                           <goal>weave</goal>
                       </goals>
                       <configuration>
                           <persistenceXMLLocation>META-INF/persistence.xml</persistenceXMLLocation>
                           <logLevel>ALL</logLevel>
                       </configuration>
                   </execution>
               </executions>
               <dependencies>
                   <dependency>
                       <groupId>org.eclipse.persistence</groupId>
                       <artifactId>org.eclipse.persistence.jpa</artifactId>
                       <version>${eclipselink.version}</version>
                   </dependency>
               </dependencies>
           </plugin>

When ClassA and ClassB are in the same bundle weaving works. However, when they are in different bundles weaving doesn't work (although I added this plugin to both bundles). How to fix this problem?

Pavel_K
  • 10,748
  • 13
  • 73
  • 186
  • How you know that "weaving doesn't work" ? Do you have any error ? If so please post the error. – Alexandre Cartapanis Jun 09 '16 at 10:06
  • @Alexandre Cartapanis I need weaving for EntityGraph (FetchGroup). When weaving doesn't work I get exception (You need to use fetch group manager ...). When weaving works I don't get this exception. Besides, static weaving can be easily checked via retrospective analysis of the class (getDeclaredFields - you will see the fields like ` _persistence_` etc). – Pavel_K Jun 09 '16 at 10:28
  • I use JPA in OSGi and i do not need to manually weave classes ... – Alexandre Cartapanis Jun 09 '16 at 11:44
  • Can you post the full exception please ? and the code that generate the exception ? – Alexandre Cartapanis Jun 09 '16 at 11:46
  • @Alexandre Cartapanis It is the way how you use. Take two classes and put them in different bundles. One class extends the another. In third bundle put persistence.xml. After that in trird bundle use EntityGraph like this http://stackoverflow.com/a/37053402/5057736 . See the result. Also see this my question https://www.eclipse.org/forums/index.php/t/1078217/ – Pavel_K Jun 09 '16 at 12:14
  • Sorry i can't help you more as i do not use weaving nor entitygraph. But I remember that putting classes and persistence.xml in different bundles can be a problem in osgi – Alexandre Cartapanis Jun 09 '16 at 12:24
  • @Alexandre Cartapanis Anyway thank you for your time. By the way, weaving is highly recommended for performance. – Pavel_K Jun 09 '16 at 13:58
  • Are you able to build your bundles after statically weaving your classes? Weaving of the persistence unit must be able to find all bundles in the classloader used for weaving to work. Runtime weaving should also work if the PU's classloader can see the classes, so you might turn on logging to finest to see what might be going on. – Chris Jun 09 '16 at 16:32
  • @Chris PU classloader see the classes as when I don't use EntityGraph (= I don't need weaving) everything works. ClassA extends ClassB. `ClassB{`@Id int id;}`. The problem appeared only when I required EntityGraph. – Pavel_K Jun 10 '16 at 04:06

0 Answers0