Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor instantiation failed because: No constructor matches the given number of parameters. #3

Closed
flaxel opened this issue Oct 20, 2020 · 6 comments
Assignees

Comments

@flaxel
Copy link

flaxel commented Oct 20, 2020

Describe the bug
We created a project with the vlingo-xoom-starter. Our project is an implementation for the vlingo-stock-trader. We adapt the generated project a little bit and we get an exception that the actor cannot be initialized because the constructors did not match the given number of parameters. The root cause is in the ActorFactory line 68-88.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the branch init_feedback_project of the stocktrader project
  2. Setup the postgres database: docker-compose up
  3. Execute the program with: mvn exec:exec
  4. See stacktrace

Expected behavior
The project is started and I can send the health request to the feedback project.

Stacktrace
This is the Stracktrace if I execute the program:

Exception in thread "main" java.lang.NullPointerException
	at io.vlingo.actors.Stage.actorFor(Stage.java:485)
	at io.vlingo.actors.Stage.actorFor(Stage.java:106)
	at io.vlingo.actors.Stage.actorFor(Stage.java:95)
	at io.vlingo.actors.World.actorFor(World.java:126)
	at io.vlingo.xoom.storage.DefaultJournalActorBuilder.build(DefaultJournalActorBuilder.java:22)
	at io.vlingo.xoom.storage.StoreActorBuilder.from(StoreActorBuilder.java:44)
	at com.whz.feedback.infrastructure.persistence.CommandModelJournalProvider.using(CommandModelJournalProvider.java:48)
	at com.whz.feedback.infrastructure.Bootstrap.<init>(Bootstrap.java:47)
	at com.whz.feedback.infrastructure.Bootstrap.main(Bootstrap.java:89)
15:24:23.957 [pool-2-thread-6] ERROR io.vlingo.actors.Logger - Actor instantiation failed because: No constructor matches the given number of parameters.
java.lang.IllegalArgumentException: No constructor matches the given number of parameters.
	at io.vlingo.actors.ActorFactory.actorFor(ActorFactory.java:88) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.createRawActor(Stage.java:761) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorProtocolFor(Stage.java:526) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:484) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:106) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:95) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.World.actorFor(World.java:126) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.xoom.storage.DefaultJournalActorBuilder.build(DefaultJournalActorBuilder.java:22) ~[vlingo-xoom-1.3.4-20201016.201022-62.jar:na]
	at io.vlingo.xoom.storage.StoreActorBuilder.from(StoreActorBuilder.java:44) ~[vlingo-xoom-1.3.4-20201016.201022-62.jar:na]
	at com.whz.feedback.infrastructure.persistence.CommandModelJournalProvider.using(CommandModelJournalProvider.java:48) ~[classes/:na]
	at com.whz.feedback.infrastructure.Bootstrap.<init>(Bootstrap.java:47) ~[classes/:na]
	at com.whz.feedback.infrastructure.Bootstrap.main(Bootstrap.java:89) ~[classes/:na]
15:24:23.959 [pool-2-thread-6] ERROR io.vlingo.actors.Logger - vlingo/actors: FAILED: Actor instantiation failed because: No constructor matches the given number of parameters.
java.lang.IllegalArgumentException: Actor instantiation failed because: No constructor matches the given number of parameters.
	at io.vlingo.actors.Stage.createRawActor(Stage.java:764) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorProtocolFor(Stage.java:526) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:484) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:106) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.actorFor(Stage.java:95) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.World.actorFor(World.java:126) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.xoom.storage.DefaultJournalActorBuilder.build(DefaultJournalActorBuilder.java:22) ~[vlingo-xoom-1.3.4-20201016.201022-62.jar:na]
	at io.vlingo.xoom.storage.StoreActorBuilder.from(StoreActorBuilder.java:44) ~[vlingo-xoom-1.3.4-20201016.201022-62.jar:na]
	at com.whz.feedback.infrastructure.persistence.CommandModelJournalProvider.using(CommandModelJournalProvider.java:48) ~[classes/:na]
	at com.whz.feedback.infrastructure.Bootstrap.<init>(Bootstrap.java:47) ~[classes/:na]
	at com.whz.feedback.infrastructure.Bootstrap.main(Bootstrap.java:89) ~[classes/:na]
Caused by: java.lang.IllegalArgumentException: No constructor matches the given number of parameters.
	at io.vlingo.actors.ActorFactory.actorFor(ActorFactory.java:88) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	at io.vlingo.actors.Stage.createRawActor(Stage.java:761) ~[vlingo-actors-1.3.4-20201016.200922-51.jar:na]
	... 10 common frames omitted

And this is the content of the definition if the error occurs:
Bildschirmfoto 2020-10-20 um 15 50 55

@VaughnVernon
Copy link
Contributor

@flaxel Please describe the storage choices (Event Sourcing vs Stateful) and any other details used in the Starter. Your issue states that the root cause is the ActorFactory but that's where the bug is manifest.

/cc @Florian-Schoenherr @danilo-ambrosio

@flaxel
Copy link
Author

flaxel commented Oct 20, 2020

Yes of course. 😄 We want to use event sourcing. Therefore we used the following property template to generate the project with xoom gen:

#Maven artifact version
version=1.0.0
#Maven project group id
group.id=com.whz
#Maven artifact version
artifact.id=<project_name>
#Base package name
package=com.whz.<project_name>
#Absolute path for the project parent folder
target.folder=<folder>
#vlingo xoom version
vlingo.xoom.server.version=1.3.4-SNAPSHOT
#Deployment Type (NONE, DOCKER, KUBERNETES)
deployment=DOCKER
#Docker Image name, required if deployment type is KUBERNETES or DOCKER
docker.image=<project_name>
#Published Docker Image, required if deployment type is KUBERNETES
k8s.image=xoom-application
#Kubernetes POD name, required if deployment type is KUBERNETES
k8s.pod.name=xoom-application
#Aggregate names (separated by semicolon)
aggregates=<aggregate_name>
#Domain Events (each events group should be preceded by Aggregate name and separated by semicolon)
events=<aggregate_name>, <event_name>
#Aggregate Rest Resources
rest.resources=<aggregate_name>
#Storage Type (STATE_STORE or JOURNAL)
storage.type=JOURNAL
#CQRS (true or false)
cqrs=true
#Projections Type (NONE, EVENT_BASED or OPERATION_BASED)
projections=EVENT_BASED
#Domain Model Database, required if CQRS is false (IN_MEMORY, POSTGRES, HSQLDB, MYSQL, YUGA_BYTE)
database=IN_MEMORY
#Command Model Database, required if CQRS is true or Storage Type is Journal (see database types above)
command.model.database=POSTGRES
#Query Model Database, required if CQRS is true or Storage Type is Journal (see database types above)
query.model.database=POSTGRES
#Use Xoom Annotations, when applicable
annotations=false

@Florian-Schoenherr
Copy link
Contributor

Guten Tag, Kommilitone!
Now I'll keep it english.

This seems to stem from some recent changes in the API, we will fix this as soon as possible!
See this issue.
Btw, you should be able to use logger() inside your FeedbackResource. (Maybe this is a nitpick 😄)

@VaughnVernon
Copy link
Contributor

VaughnVernon commented Oct 22, 2020

@flaxel @Florian-Schoenherr This was fixed by @danilo-ambrosio. Please review and test PR to confirm fix. I will merge following your ok.

vlingo/xoom-turbo@479d550

/cc @danilo-ambrosio

@flaxel
Copy link
Author

flaxel commented Oct 22, 2020

The solution is working perfectly. 👍 Thank you very much! 😁 I got only one little error and I guess it is a fast fix. If I want to get the defaultLogger from a RessourceHandler I get a NPE. I guess the reason is that the stage variable is never set therefore the value is null. My suggested solution would be a new constructor, which has to be called in the FeedbackResource, for example. Should I create a new issue for this task?

@VaughnVernon
Copy link
Contributor

VaughnVernon commented Oct 22, 2020

Thanks, @flaxel. I am closing this issue. Please create a new issue with your latest report, RE: ResourceHandler does not provide defaultLogger and include the following comment:

It's possible that extending ResourceHandler is improperly generated because that is only supported by "configuration resources" (declared in vlingo-http.properties). For dynamic resources handlers the Stage must be passed in via constructor. With the Stage the dynamic resources handlers can get to anything needed, including the Logger.

/cc @danilo-ambrosio @Florian-Schoenherr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants