diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java index da5e46fdbd8..fdb5765e0c3 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.orm.jpa.persistenceunit; import jakarta.persistence.spi.ClassTransformer; +import org.apache.commons.logging.LogFactory; import org.springframework.core.DecoratingClassLoader; import org.springframework.instrument.classloading.LoadTimeWeaver; @@ -79,10 +80,12 @@ class SpringPersistenceUnitInfo extends MutablePersistenceUnitInfo { */ @Override public void addTransformer(ClassTransformer classTransformer) { - if (this.loadTimeWeaver == null) { - throw new IllegalStateException("Cannot apply class transformer without LoadTimeWeaver specified"); + if (this.loadTimeWeaver != null) { + this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer)); + } + else { + LogFactory.getLog(getClass()).info("No LoadTimeWeaver setup: ignoring JPA class transformer"); } - this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer)); } /**