Symptoms
- Breakpoints set on JPA entity classes (or other classes managed by a runtime bytecode-rewriting framework) show as invalid (red X icon) after a HotSwap reload during a debug session.
- Code edits are reflected at runtime. For example, a newly added
System.out.printlnproduces output, but the debugger no longer stops on lines inside the modified method. - Adding or removing lines inside a method desynchronizes breakpoint line numbers.
- In a fresh debug session, before any edit is made, breakpoints work correctly. The problem appears only after the first HotSwap reload.
- The issue persists after disabling JRebel.
- A minimal Tomcat/Vaadin sample project does not reproduce the issue. Only the project that uses EclipseLink JPA does.
Environment
- Customer type: Personal and commercial customers
- Region affected: All regions
- Product affected: IntelliJ IDEA
Cause
EclipseLink performs dynamic bytecode weaving on entity classes at class-load time. The bytecode loaded into the JVM no longer matches the bytecode compiled from sources. After a HotSwap reload, the JVM reports that the source line maps to no executable bytecode instruction, so the debugger marks the breakpoint invalid. The mismatch is independent of any third-party reloading agent. The same effect occurs with plain HotSwap.
A similar effect can appear with any framework that rewrites bytecode at runtime: Hibernate bytecode enhancement, AspectJ load-time weaving, Mockito inline mock maker, JaCoCo on-the-fly instrumentation.
Resolution
Disable EclipseLink dynamic weaving.
If the EntityManagerFactory is created programmatically, add the weaving property before creating the factory. Programmatic properties override persistence.xml, so when both exist, the programmatic value wins:
Map<String, Object> map = new HashMap<>();
map.put(PersistenceUnitProperties.WEAVING, "false");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("unit-name", map);
If the persistence unit is configured only via persistence.xml, add the property to the unit:
<property name="eclipselink.weaving" value="false"/>
For container-managed deployments (Tomcat, GlassFish, WildFly), rebuild and redeploy the exploded artifact after the change, then restart the debug session. Breakpoints on entity classes are now valid and stay valid across HotSwap reloads.
Disabling weaving turns off EclipseLink optimizations such as lazy loading for @OneToOne/@ManyToOne, attribute change tracking, and fetch groups. Verify that production performance is acceptable, or keep weaving enabled in production and disable it only in the debug profile.
For unrelated HotSwap setup and limits, see HotSwap in IntelliJ IDEA.
Additional Relevant Phrases
breakpoint not hit after hotswap, red cross breakpoint, breakpoint invalid after reload, EclipseLink WEAVING property, JPA entity breakpoint, bytecode weaving debugger out of sync, hotswap Tomcat breakpoint desync, RD debugger: Adding new lines breaks breakpoint highlighting (and deletes a breakpoint)
Comments
0 comments
Please sign in to leave a comment.