Repository: quarkusio/quarkus
Issue: TypeNotPresentException during entity augmentation

**Describe the bug**
I'm seeing Maven build failures from the package phase (and later phases) due to entity class augmentation failures.

**Expected behavior**
Jar files are created for the project.

**Actual behavior**
No jar files are created.  This is failing on an entity that is catching a `NoResultException` or a `NonUniqueResultException`.  These classes are in the dependency tree of the project, and show up in the class path and constructed class loader during the build.

**To Reproduce**
Run `./mvnw clean package` on the attached example project.

**Screenshots**
```
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 2155ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.066 s
[INFO] Finished at: 2019-08-08T10:03:17-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:0.20.0:build (default) on project getting-started: Failed to build a runnable JAR: Failed to build a runner jar: Failed to augment application classes: java.lang.TypeNotPresentException: Type javax/persistence/NoResultException not present: javax.persistence.NoResultException -> [Help 1]
```

**Environment (please complete the following information):**
 - Output of `uname -a` or `ver`: 
`Linux **** 5.0.0-23-generic #24-Ubuntu SMP Mon Jul 29 15:36:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux`
 - Output of `java -version`: 
```
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)
```
 - GraalVM version (if different from Java): n/a (not using GraalVM)
 - Quarkus version or git rev: 0.20.0

**Additional context**
It looks like when `HibernateEnhancingClassVisitor` is constructed, it does not pass along the class loader to the new instance of `ClassWriter`.  It somehow gets a different class loader, which knows nothing about the carefully constructed class loader from Quarkus, so it throws a `ClassNotFound` exception when it processes the entity class, trying to find `NoResultException` or `NonUniqueResultException`.


Changed files:
extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
core/deployment/src/main/java/io/quarkus/deployment/QuarkusClassWriter.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusClassWriter.java b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusClassWriter.java
index 198829dc44c..1b32a46a504 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusClassWriter.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusClassWriter.java
@@ -15,6 +15,10 @@ public QuarkusClassWriter(final ClassReader classReader, final int flags) {
         super(classReader, flags);
     }
 
+    public QuarkusClassWriter(final int flags) {
+        super(flags);
+    }
+
     @Override
     protected String getCommonSuperClass(String type1, String type2) {
         ClassLoader cl = getClassLoader();
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
index 6b0a88f6893..6d618920e57 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
@@ -10,6 +10,8 @@
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.Opcodes;
 
+import io.quarkus.deployment.QuarkusClassWriter;
+
 /**
  * Used to transform bytecode by registering to
  * io.quarkus.deployment.ProcessorContext#addByteCodeTransformer(java.util.function.Function).
@@ -38,7 +40,7 @@ private class HibernateEnhancingClassVisitor extends ClassVisitor {
         private final Enhancer enhancer;
 
         public HibernateEnhancingClassVisitor(String className, ClassVisitor outputClassVisitor) {
-            super(Opcodes.ASM7, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
+            super(Opcodes.ASM7, new QuarkusClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
             this.className = className;
             this.outputClassVisitor = outputClassVisitor;
             //note that as getLoadingClassLoader is resolved immediately this can't be created until transform time