1 2 3 4 Previous Next 53 Replies Latest reply on Jul 1, 2014 11:29 AM by smarlow

    Eclipselink Weaving Issue


      Wildfly 8.1

      Eclipselink 2.5.1


      Hi everyone.  I am in the middle of trying to switch from Glassfish to Wildfly.  I've followed some of the guides and have worked through most of the migration, but am stuck on an Eclipselink issue.  I have an EJB module that has my database entities, database access classes with PersistenceUnit injected in to them, and my persistence.xml


      <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="MyPU" transaction-type="JTA">








      When I deploy this EJB module to the server on it's own, I have no issues.  I have added the eclipselink.jar and updated the module xml to include it and this works as expected.


      I then also have a Web App that is dependent on the EJB module (it is not included in the WAR file is that matters). This Web app does not have any database entities, persistence information, etc.  Instead, it relies on using the data access classes and entities from the ejb module.


      I then package the EJB module and the Web module into an EAR and deploy it to Wildfly.  When I deploy this, I get a warning for any class that has a @ManyToOne annotation with fetch = FetchType.LAZY


      Reverting the lazy setting on the OneToOne or ManyToOne attribute [organization] for the entity class [class com.cyber2.tc.entities.User] since weaving was not enabled or did not occur.


      I have removed the Web app/WAR file from the EAR and deployed it with just the EJB module in it, and the problem goes away.   The problem only occurs when the web module is in the EAR with the EJB module.  I know I could try to enable static weaving before deployment, but I'm not sure if this should be necessary since I didn't have to do it on glassfish.  Any Thoughts?




        • 1. Re: Eclipselink Weaving Issue

          After playing with it some more, I realized the issue is even more sporadic.  If I take the same EAR and deploy it multiple times in a row, sometimes I'll get 65 of these warnings, other times I get 5 or 20, and one time I got 0 of these warnings.


          Odd that the same EAR deployed over and over again has different behavior.  I have yet to check the SQL log to see if it has actually disabled the lazy fetching, but I suspect it has.

          • 2. Re: Eclipselink Weaving Issue

            I have verified that lazy fetching is disabled and is hurting application performance significantly on one of our pages that loads multiple entities with a bunch of one to one relationships.  I am going to look and see if I can get Static weaving working on an EAR file (haven't seen a lot of guidance on this), but if I can't, this seems to be a deal breaker in terms of switching from glassfish.


            I thought it might be an issue with the order the modules were getting deployed inside the EAR since there are no issues when the EAR just contains the ejb-module so I tried to use <initialize-in-order>true</initialize-in-order> with the EJB module first in application.xml since the Web module is dependent on the ejb module and not the other way around, but this didn't work and actually created other issues that caused the application to not deploy.

            • 3. Re: Eclipselink Weaving Issue

              If I recall correctly, there is an issue that prevents dynamic weaving from working correctly in WildFly. Some sort of chicken/egg problem where the classes needed to be loaded for something before they could be weaved, but then they couldn't be weaved because they were already loaded. This might explain why you get varying amounts of warnings: sometimes the weaver gets to the classes first, sometimes other things do.


              Static weaving works fine for me. If you're using Maven, check out the eclipselink-staticweave-maven-plugin. If you're using Maven with Eclipse as your IDE, make sure you install m2e and m2e-apt, but be aware that sometimes the staticweave plugin doesn't get along with them and can cause an infinite incremental build loop.


              If you want a better answer as to why dynamic weaving doesn't work, I'd recommend PMing Scott Marlow. He handles all of the JPA-related stuff in WildFly. He's active on this forum and I'm actually a little surprised he hasn't weighed in here.

              • 4. Re: Eclipselink Weaving Issue

                Thanks Rich.  Unfortunately this project is using Ant and not Maven but we should be able to add it to the build script when we have a little bit of time to figure it out.  I'll also ping Scott and see if he has any advice.  Thanks again!

                • 5. Re: Eclipselink Weaving Issue

                  Not sure why but I missed this interesting thread.  Reading now...

                  • 6. Re: Eclipselink Weaving Issue

                    Might be helpful to enable TRACE logging for org.jboss.as.jpa as mentioned here.  Please attach the resulting server.log (from server starting up until application deployment completes).


                    Also look at the (excellent) earlier documentation for using EclipseLink + AS7.  Seems that https://bugs.eclipse.org/bugs/show_bug.cgi?id=383199 is targeted to be fixed in EclipseLink 2.6.  Not sure if your hitting that but others have.

                    • 7. Re: Eclipselink Weaving Issue

                      I'll work on getting the log now.  In reference to Eclipselink bug 383199, I just tried setting <property name="eclipselink.deploy-on-startup" value="true" /> as shown in the bug in my persistence.xml and it didn't not solve the issue.

                      • 8. Re: Re: Eclipselink Weaving Issue

                        Sorry for the delay, it wasn't letting me post.. some error about being over my frequency.  Below is the log, sorry for the length, I wasn't sure what could be cut so I left it all. Please let me know if there is anything else I can provide.  Thanks!


                        pasted log removed for readability.. more recent ones added as attachments are further in thread

                        • 9. Re: Re: Eclipselink Weaving Issue

                          This might be an ordering bug in https://github.com/wildfly/wildfly/blob/master/jpa/src/main/java/org/jboss/as/jpa/subsystem/JPASubSystemAdd.java#L109 


                          The JPAClassFileTransformerProcessor is responsible for registering the classfile transformer that EclipseLink will use and needs to be set before PersistenceBeginInstallProcessor creates the persistence unit (via PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map). Having both of these actions from the same deployment phase is causing this.  My local change will merge the two.  I'll push a change to github and ask you to build it and test in a bit.

                          • 10. Re: Re: Eclipselink Weaving Issue


                            • 11. Re: Re: Re: Eclipselink Weaving Issue

                              Potential fix is at https://github.com/scottmarlow/wildfly/tree/transformers.  You should be able to:

                              git clone git://github.com/scottmarlow/wildfly.git

                              cd wildfly

                              git checkout transformers

                              ./build.sh clean install


                              Then deploy your application with the built build/target/wildfly-9.0.0.Alpha1-SNAPSHOT (also setup eclipselink module as you did before).

                              • 12. Re: Re: Re: Eclipselink Weaving Issue

                                Let us know the result of trying the above.  We can create a jira for the bug after you confirm the fix helps.

                                • 13. Re: Re: Eclipselink Weaving Issue

                                  This may be a bit of ignorance on my part since I've never had to make wildfly before, but when running the commands above, after a long time in the build process, it fails with:


                                  [INFO] BUILD FAILURE

                                  [INFO] ------------------------------------------------------------------------

                                  [INFO] Total time: 8:48.378s

                                  [INFO] Finished at: Tue Jun 10 19:35:45 EDT 2014

                                  [INFO] Final Memory: 338M/683M

                                  [INFO] ------------------------------------------------------------------------

                                  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project wildfly-logging: There are test failures.


                                  [ERROR] Please refer to /root/wildfly/logging/target/surefire-reports for the individual test results.

                                  [ERROR] -> [Help 1]


                                  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

                                  [ERROR] Re-run Maven using the -X switch to enable full debug logging.


                                  [ERROR] For more information about the errors and possible solutions, please read the following articles:

                                  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


                                  [ERROR] After correcting the problems, you can resume the build with the command

                                  [ERROR]   mvn <goals> -rf :wildfly-logging



                                  I updated my JDK to 7u60 since I was on a slightly older one and reran it just in case but still got the same issue.  Any idea what I'm doing wrong?  Thanks again!

                                  • 14. Re: Re: Eclipselink Weaving Issue

                                    Try "./build.sh clean install -Dmaven.test.skip=true"


                                    That should ignore the tests.

                                    1 2 3 4 Previous Next