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

NoSuchConstructorException #169

Open
e7 opened this issue Jun 24, 2020 · 1 comment
Open

NoSuchConstructorException #169

e7 opened this issue Jun 24, 2020 · 1 comment

Comments

@e7
Copy link

e7 commented Jun 24, 2020

net.greghaines.jesque.utils.NoSuchConstructorException: class=com.xxx.xxx.xxxx.TestAction args=[6]
	at net.greghaines.jesque.utils.ReflectionUtils.findConstructor(ReflectionUtils.java:205) ~[jesque-2.1.3.jar:na]
	at net.greghaines.jesque.utils.ReflectionUtils.createObject(ReflectionUtils.java:147) ~[jesque-2.1.3.jar:na]
	at net.greghaines.jesque.utils.JesqueUtils.materializeJob(JesqueUtils.java:415) ~[jesque-2.1.3.jar:na]
	at net.greghaines.jesque.worker.MapBasedJobFactory.materializeJob(MapBasedJobFactory.java:49) ~[jesque-2.1.3.jar:na]
	at net.greghaines.jesque.worker.WorkerImpl.process(WorkerImpl.java:605) [jesque-2.1.3.jar:na]
	at net.greghaines.jesque.worker.WorkerImpl.poll(WorkerImpl.java:449) [jesque-2.1.3.jar:na]
	at net.greghaines.jesque.worker.WorkerImpl.run(WorkerImpl.java:220) [jesque-2.1.3.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_221]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_221]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_221]

There is a public TestAction(long id); constructor there actually, so I track code into net.greghaines.jesque.utils.ReflectionUtils.findConstructor, and found this:

            if (typeDiffWeight < minTypeDiffWeight) { // right here, should be `<=` ?
                // Choose this constructor if it represents the closest match.
                constructorToUse = candidate;
                minTypeDiffWeight = typeDiffWeight;
                ambiguousConstructors = null;
            } else if (constructorToUse != null && typeDiffWeight == minTypeDiffWeight) {
                if (ambiguousConstructors == null) {
                    ambiguousConstructors = new LinkedHashSet<Constructor<?>>();
                    ambiguousConstructors.add(constructorToUse);
                }
                ambiguousConstructors.add(candidate);
            }
@lrajlich
Copy link

I ran into the same problem. This is because, it appears that Jesque is treating the argument as an int and looking for a constructor matching it, (in this case I could match it to a constructor with int as an argument type). I was able to work around the problem by making the constructor use java.lang.Number as constructor argument type and using longValue method to assign the class member.

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

2 participants