Repository: quarkusio/quarkus
Issue: Entities extending PanacheEntityBase are not enhanced in dev mode when located in a dependency

**Describe the bug**
Getters and setters are not generated for an entity extending `PanacheEntityBase` and located in a dependency of a Quarkus project. This dependency contains an empty `beans.xml`.

**Expected behavior**
The Quarkus documentation says entities getter/setter generation should work for entities from dependencies as long as there's an empty beans.xml in the dependencies:
> Hibernate ORM in Quarkus relies on compile-time bytecode enhancements to your entities. If you define your entities in the same project where you build your Quarkus application, everything will work fine. If the entities come from external projects or jars, you can make sure that your jar is treated like a Quarkus application library by adding an empty META-INF/beans.xml file. This will allow Quarkus to index and enhance your entities as if they were inside the current project.

**Actual behavior**
```
org.jboss.resteasy.spi.UnhandledException: java.lang.NoSuchMethodError: com.gwenneg.EntityWithoutGetterSetter.setName(Ljava/lang/String;)V
	at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
	at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:234)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$8$1$1.call(UndertowDeploymentTemplate.java:482)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:197)
	at io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
	at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$1.handleRequest(UndertowDeploymentTemplate.java:90)
	at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup.handleHotDeploymentRequest(UndertowHotReplacementSetup.java:77)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup$1$1.handleRequest(UndertowHotReplacementSetup.java:56)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
	at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:243)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1429)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.NoSuchMethodError: com.gwenneg.EntityWithoutGetterSetter.setName(Ljava/lang/String;)V
	at com.gwenneg.todo.application.ReproducerResource.test(ReproducerResource.java:16)
	at com.gwenneg.todo.application.ReproducerResource_ClientProxy.test(ReproducerResource_ClientProxy.zig:159)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
	at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:143)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:568)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:442)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:396)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:398)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:367)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:341)
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:143)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:341)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
	... 50 more
```

**To Reproduce**
Steps to reproduce the behavior:
1. Clone https://github.com/gwenneg/quarkus-panache-getter-setter-generation
2. Run `cd entity-dependency`
3. Run `./mvnw clean install`
4. Run `cd ../jaxrs-resource`
5. Run `./mvnw clean compile quarkus:dev`
6. Call http://localhost:8080/reproducer/test from browser

**Environment:**
 - Output of `java -version`: `openjdk version "11" 2018-09-25`
 - Quarkus version or git rev: `0.17.0`

Changed files:
core/deployment/src/main/java/io/quarkus/runner/RuntimeRunner.java, core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java

diff --git a/core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java b/core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java
index 22ec24c77c4..912622810e1 100644
--- a/core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java
+++ b/core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java
@@ -26,6 +26,7 @@
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
@@ -80,7 +81,9 @@ public void accept(Path path) {
                     });
                 }
             }
+
             this.applicationClasses = applicationClasses;
+
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
@@ -201,17 +204,11 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
                 }
             }
             try {
-                byte[] buf = new byte[1024];
-                int r;
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                try (FileInputStream in = new FileInputStream(classLoc.toFile())) {
-                    while ((r = in.read(buf)) > 0) {
-                        out.write(buf, 0, r);
-                    }
+                try {
+                    bytes = Files.readAllBytes(classLoc);
                 } catch (IOException e) {
                     throw new ClassNotFoundException("Failed to load class", e);
                 }
-                bytes = out.toByteArray();
                 bytes = handleTransform(name, bytes);
                 definePackage(name);
                 Class<?> clazz = defineClass(name, bytes, 0, bytes.length);
@@ -273,6 +270,38 @@ public void setTransformers(Map<String, List<BiFunction<String, ClassVisitor, Cl
         this.bytecodeTransformers = functions;
     }
 
+    public void setApplicationArchives(List<Path> archives) {
+        //we also need to be able to transform application archives
+        //this is not great but I can't really see a better solution
+        if (bytecodeTransformers == null) {
+            return;
+        }
+        try {
+            for (Path root : archives) {
+                Map<String, Path> classes = new HashMap<>();
+                AtomicBoolean transform = new AtomicBoolean();
+                Files.walk(root).forEach(new Consumer<Path>() {
+                    @Override
+                    public void accept(Path path) {
+                        if (path.toString().endsWith(".class")) {
+                            String key = root.relativize(path).toString().replace('\\\\', '/');
+                            classes.put(key, path);
+                            if (bytecodeTransformers
+                                    .containsKey(key.substring(0, key.length() - ".class".length()).replace("/", "."))) {
+                                transform.set(true);
+                            }
+                        }
+                    }
+                });
+                if (transform.get()) {
+                    applicationClasses.putAll(classes);
+                }
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     @Override
     public void writeResource(String name, byte[] data) throws IOException {
         resources.put(name, data);
diff --git a/core/deployment/src/main/java/io/quarkus/runner/RuntimeRunner.java b/core/deployment/src/main/java/io/quarkus/runner/RuntimeRunner.java
index 943c803aefd..be9b0d74d32 100644
--- a/core/deployment/src/main/java/io/quarkus/runner/RuntimeRunner.java
+++ b/core/deployment/src/main/java/io/quarkus/runner/RuntimeRunner.java
@@ -17,13 +17,16 @@
 import java.util.function.BiFunction;
 import java.util.function.Consumer;
 import java.util.logging.Handler;
+import java.util.stream.Collectors;
 
 import org.objectweb.asm.ClassVisitor;
 
 import io.quarkus.builder.BuildChainBuilder;
 import io.quarkus.builder.BuildResult;
+import io.quarkus.deployment.ApplicationArchive;
 import io.quarkus.deployment.ClassOutput;
 import io.quarkus.deployment.QuarkusAugmentor;
+import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
 import io.quarkus.deployment.builditem.ApplicationClassNameBuildItem;
 import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
 import io.quarkus.deployment.builditem.LiveReloadBuildItem;
@@ -115,6 +118,11 @@ public void run() {
 
                 transformerTarget.setTransformers(functions);
             }
+            if (loader instanceof RuntimeClassLoader) {
+                ApplicationArchivesBuildItem archives = result.consume(ApplicationArchivesBuildItem.class);
+                ((RuntimeClassLoader) loader).setApplicationArchives(archives.getApplicationArchives().stream()
+                        .map(ApplicationArchive::getArchiveRoot).collect(Collectors.toList()));
+            }
 
             final Application application;
             Class<? extends Application> appClass = loader