1
votes

I am using the current release of GlassFish 4.1 with EclipseLink version 2.5.2 included. At this GlassFish, I have an enterprise application and a web application deployed. If an EJB that returns a loaded entity, is called from outside the GlassFish (like an external JavaFX application), the entity is returned properly.

But if the same EJB is called from the web application, the entity is not returned properly due to this bug GLASSFISH-17432.

The workaround I already found here Calling Remote EJB in EJB 3.1 is not really solving this problem, because if I disable the weaving in EclipseLink, the following does not work any more properly:

@ManyToOne(fetch=FetchType.LAZY)
public Foo getFoo() {
    return foo;
}

@ManyToOne(fetch=FetchType.EAGER)
public Bar getBar() {
    return bar;
}
1

1 Answers

1
votes

You can try static weaving as another workaround.

Byte code weaving is a technique for changing the byte code of compiled Java classes. You can configure byte code weaving to enable a number of EclipseLink JPA performance optimizations, including support for the lazy loading of one-to-one and many-to-one relationships, attribute-level change tracking, and fetch groups.

Weaving can be performed either dynamically when entity classes are loaded, or statically as part of the build process.

(Source)

As suggested in GLASSFISH-16164 you can try the eclipselink-staticweave-maven-plugin. A detailed explanation about static weaving and the usage of the plugin (alternativly you can use ant) can be found in the EclipseLink Wiki.

You then have to set this property in your persistence.xml:

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

See also: