Skip to content

Instantly share code, notes, and snippets.

Scott Marlow scottmarlow

Block or report user

Report or block scottmarlow

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jpatests.sh
#!/bin/bash
echo "run hibernate + jpa tests"
cd testsuite/integration/basic/
mvn install -Dtest=org.jboss.as.test.integration.jpa.packaging.PersistenceUnitPackagingTestCase > /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.packaging.EJBJarPackagingTestCase >> /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.packaging.PersistenceUnitWarPackagingTestCase >> /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.cfgfile.CfgFileTestCase >> /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.multipleinjections.MultiplePersistenceContextInjectionsTestCase >> /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.webnontxem.NonTransactionalEmTestCase >> /tmp/orm53.txt
mvn install -Dtest=org.jboss.as.test.integration.jpa.ormxml.OrmTestCase >> /tmp/orm53.txt
@scottmarlow
scottmarlow / gist:0e74cd16d7229812261b7c14e452b3cd
Created Mar 26, 2019
BB throwing IllegalStateException("Cannot resolve type description for " + name)
View gist:0e74cd16d7229812261b7c14e452b3cd
at net.bytebuddy.pool.TypePool$Resolution$Illegal.resolve(TypePool.java:159)
at net.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:1407)
at net.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getModifiers(TypeDescription.java:8115)
at net.bytebuddy.dynamic.scaffold.InstrumentedType$Factory$Default$1.represent(InstrumentedType.java:359)
at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:731)
at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.lambda$enhance$0(EnhancerImpl.java:137)
at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.rewrite(ByteBuddyState.java:149)
at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:136)
@scottmarlow
scottmarlow / gist:f07cc2289b8c05aa0c6827bb6e3945ba
Last active Dec 3, 2018
chicken + egg jpa deployment ordering issue on WildFly
View gist:f07cc2289b8c05aa0c6827bb6e3945ba
http://docs.wildfly.org/14/Developer_Guide.html#persistence-unit-properties lists the various WildFly persistence unit hints, some of them, which can prevent runtime bytecode enhancement.
Some chicken/egg situations:
1. CDI deployment processing reads application deployment class definitions into memory, if the Hibernate ORM javax.persistence.spi.ClassTransformer is not yet registered at the time that the application class definitions are read by the CDI deployment processor, then runtime bytecode enhancement will not occur.
2. Application deployments that include @DataSourceDefinition and include persistence units that use the application defined datasource, will need to bootstrap the persistence unit very late (e.g. well after applications class definitions are already read), as the @DataSourceDefinition is not available before application classes have already been read. These apps might set jboss.as.jpa.classtransformer=false or wildfly.jpa.twophasebootstrap=false (see example unit test [1]).
[1] h
View gist:2a624b6676cab391b3ed7986c455c52d
[INFO] Running org.jboss.as.test.integration.jpa.transaction.TransactionTestCase
[ERROR] Tests run: 12, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.836 s <<< FAILURE! - in org.jboss.as.test.integration.jpa.transaction.TransactionTestCase
[ERROR] testConcurrentAccess(org.jboss.as.test.integration.jpa.transaction.TransactionTestCase) Time elapsed: 7.008 s <<< ERROR!
java.util.concurrent.ExecutionException: java.lang.RuntimeException: javax.ejb.EJBException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.jboss.as.test.integration.jpa.transaction.TransactionTestCase.testConcurrentAccess(TransactionTestCase.java:309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43
View gist:9edbe9131fee2a41b3267c78e06f2d0e
[INFO] Running org.jboss.as.test.integration.jpa.transaction.TransactionTestCase
[ERROR] Tests run: 12, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.53 s <<< FAILURE! - in org.jboss.as.test.integration.jpa.transaction.TransactionTestCase
[ERROR] testConcurrentAccess(org.jboss.as.test.integration.jpa.transaction.TransactionTestCase) Time elapsed: 0.583 s <<< ERROR!
java.util.concurrent.ExecutionException: java.lang.RuntimeException: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet : EntityKey[org.jboss.as.test.integration.jpa.transaction.Employee#500]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.jboss.as.test.integration.jpa.transaction.TransactionTestCase.testConcurrentAccess(TransactionTestCase.java:309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.r
View gist:788a654b9dc53d078093ce64df9d4f26
[ERROR] Tests run: 12, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.265 s <<< FAILURE! - in org.jboss.as.test.integration.jpa.transaction.TransactionTestCase
[ERROR] testConcurrentAccess(org.jboss.as.test.integration.jpa.transaction.TransactionTestCase) Time elapsed: 1.684 s <<< ERROR!
java.util.concurrent.ExecutionException: java.lang.RuntimeException: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet : EntityKey[org.jboss.as.test.integration.jpa.transaction.Employee#500]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.jboss.as.test.integration.jpa.transaction.TransactionTestCase.testConcurrentAccess(TransactionTestCase.java:309)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
View MultipleInitiatorTest.java
package org.hibernate.service;
import java.util.Map;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.internal.RegionFactoryInitiator;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.spi.ServiceContributor;
View gist:0123fe4e2f9c0afda3b0422252eb1cf9
mv = cw.visitMethod(ACC_PUBLIC, "nullSafeGet", "(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SharedSessionContractImplementor;Ljava/lang/Object;)Ljava/lang/Object;", null, new String[] { "org/hibernate/HibernateException", "java/sql/SQLException" });
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 2);
mv.visitVarInsn(ALOAD, 3);
mv.visitTypeInsn(CHECKCAST, "org/hibernate/engine/spi/SessionImplementor");
mv.visitVarInsn(ALOAD, 4);
mv.visitMethodInsn(INVOKEVIRTUAL, "org/jboss/as/test/integration/hibernate/Student", "nullSafeGet", "(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;", false);
mv.visitInsn(ARETURN);
View StateType.java
public class StateType implements UserType {
// this represents what the transformer will generate
public Object nullSafeGet(ResultSet rs, String[] names, org.hibernate.SharedSessionContract session, Object owner) throws HibernateException, SQLException {
return nullSafeGet(rs,names, (SessionImplementor)session, owner);
}
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
int result = rs.getInt( names[0] );
if ( rs.wasNull() ) return null;
You can’t perform that action at this time.