d-led / hello_vlingo

trying out the vlingo platform
The Unlicense
2 stars 0 forks source link

running under gradle fails finding generated classes #1

Closed d-led closed 6 years ago

d-led commented 6 years ago

Solution proposal

https://github.com/vlingo/vlingo-actors/compare/auto_class_location#diff-71e561a2af5d9976ff569d6912379978R72

Problem

gradle run

vlingo/actors: Generating proxy for main: github.dled.demo.Greeter
vlingo/actors: Generating proxy for test: github.dled.demo.Greeter
playground: Actor instantiation failed because: Actor proxy github.dled.demo.Greeter not created for main or test: Actor proxy github.dled.demo.Greeter not created because: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
target/test-classes/github/dled/demo/Greeter.class
java.lang.IllegalArgumentException: Actor proxy github.dled.demo.Greeter not created for main or test: Actor proxy github.dled.demo.Greeter not created because: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
target/test-classes/github/dled/demo/Greeter.class
        at io.vlingo.actors.ActorProxy.tryGenerateCreate(ActorProxy.java:72)
        at io.vlingo.actors.ActorProxy.createFor(ActorProxy.java:36)
        at io.vlingo.actors.Stage.actorProxyFor(Stage.java:96)
        at io.vlingo.actors.Actor.selfAs(Actor.java:105)
        at github.dled.demo.ConsoleGreeter.<init>(ConsoleGreeter.java:15)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at java.lang.Class.newInstance(Class.java:442)
        at io.vlingo.actors.ActorFactory.actorFor(ActorFactory.java:39)
        at io.vlingo.actors.Stage.createRawActor(Stage.java:262)
        at io.vlingo.actors.Stage.actorFor(Stage.java:184)
        at io.vlingo.actors.Stage.actorFor(Stage.java:166)
        at io.vlingo.actors.Stage.actorFor(Stage.java:30)
        at io.vlingo.actors.World.actorFor(World.java:51)
        at github.dled.demo.App.main(App.java:14)
Caused by: java.lang.IllegalArgumentException: Actor proxy github.dled.demo.Greeter not created because: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
target/test-classes/github/dled/demo/Greeter.class
        at io.vlingo.actors.ActorProxy.tryGenerateCreate(ActorProxy.java:89)
        at io.vlingo.actors.ActorProxy.tryGenerateCreate(ActorProxy.java:70)
        ... 16 more
Caused by: java.lang.IllegalArgumentException: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
target/test-classes/github/dled/demo/Greeter.class
        at io.vlingo.actors.ProxyGenerator.generateFor(ProxyGenerator.java:86)
        at io.vlingo.actors.ActorProxy.tryGenerateCreate(ActorProxy.java:84)
        ... 17 more
java.lang.IllegalArgumentException: Actor instantiation failed because: Actor proxy github.dled.demo.Greeter not created for main or test: Actor proxy github.dled.demo.Greeter not created because: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
playground: vlingo/actors: FAILED: Actor instantiation failed because: Actor proxy github.dled.demo.Greeter not created for main or test: Actor proxy github.dled.demo.Greeter not created because: Cannot generate proxy class for github.dled.demo.Greeter because there is no corresponding:
target/test-classes/github/dled/demo/Greeter.class
        at io.vlingo.actors.Stage.createRawActor(Stage.java:266)
        at io.vlingo.actors.Stage.actorFor(Stage.java:184)

The exception hints at a location where class files are expected: target/test-classes/github/dled/demo/Greeter.class, which seems to be a maven convention, but it can't be expected in the general case. The implementation is here: DynaFile.java

files are there in this case:

$ find . | grep Greeter\.class
./out/production/classes/github/dled/demo/ConsoleGreeter.class
./out/production/classes/github/dled/demo/Greeter.class
./build/classes/java/main/github/dled/demo/ConsoleGreeter.class
./build/classes/java/main/github/dled/demo/Greeter.class

pre-creating the directories didn't help (in case the files could not be written).

Line:

    if (targetClassesRelativePathToClass.exists()) { //sure, class doesn't exist
      try {
       //...
    } else {
      throw new IllegalArgumentException("Cannot generate proxy class for " + actorProtocol + " because there is no corresponding:\n" + relativePathToClassFile);
    }
d-led commented 6 years ago

when the classes are pre-created by a maven run, surely, hello world runs fine

d-led commented 6 years ago

fixed via vlingo-actors 0.4.2