Jump to content

NoSuchMethodError help (again)


Chicken Wing

Recommended Posts

Hi guys, I am trying to make a safe-cracker script, I was cleaning up my projects so I copied them all into one workspace for all my osbot stuff, ever since I get this error at runtime when I run my jar file (there are no compiler errors)

[ERROR][09/15 03:45:44 PM]: Uncaught exception!
java.lang.NoSuchMethodError: core.Task.<init>(Lcore/SafeCracker;)V
	at tasks.ClickSafe.<init>(ClickSafe.java:14)
	at core.SafeCracker.onStart(SafeCracker.java:59)
	at org.osbot.rs07.event.ScriptExecutor.onStart(lj:110)
	at org.osbot.rs07.event.ScriptExecutor.start(lj:194)
	at org.osbot.prN.run(cp:367)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Last time I fixed it by deleting everything and making a new project, but now even if I clean all the class files and rebuild the project I still get this error. 

 

Here is the src folder: http://www.mediafire.com/download/ljcgco1kwmro75z/New_Compressed_%28zipped%29_Folder.zip

 

Not sure what to do anymore :/

Link to comment
Share on other sites

It also shows you which lines:

at tasks.ClickSafe.<init>(ClickSafe.java:14)

at core.SafeCracker.onStart(SafeCracker.java:59)

What methods are you using on those lines?

13  public ClickSafe(SafeCracker sA) {
14		super(sA);
15  }
59  Collections.addAll(nodes, new ClickSafe(this), new EatFood(this), new CloseBank(this), 
60  new DepositGems(this), new OpenBank(this), new ReturnToCracking(this), new WithdrawFood(this));

I posted the src folder link btw

 

EDIT: btw if I remove the clicksafe object, the error will just show for EatFood instead at the same place

Edited by Chicken Wing
Link to comment
Share on other sites

I'm taking it that you didn't write that task system yourself? You might want to look into using enum states until you get a little more familiar with Java.

 

In the meantime check out some of this stuff:

https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

https://docs.oracle.com/javase/tutorial/java/IandI/super.html

https://docs.oracle.com/javase/tutorial/java/concepts/interface.html

  • Like 2
Link to comment
Share on other sites

I'm taking it that you didn't write that task system yourself?

 

Well, I used this tutorial to write it: http://osbot.org/forum/topic/48284-javatutorial-how-to-get-a-single-stage-node-framework-intermediate/ , and it works, I have a script on the sdn which uses it and it works fine, in fact the code was working fine before, its just when I copied it over from another project into a new eclipse project

 

The comparator stuff was just something I was trying out, Its not used 

re-create the project and move over the class files

 

Move which class files to where?

Link to comment
Share on other sites

You should show your workspace hierarchy.

When this happens due to relocating, there's a good chance another Task binary file is interfering (one which does not have that constructor, but maybe a constructor which accepts a different script or maybe has no parameters).

Since a ClassNotFoundException was not thrown, there is definitely a Task type, it just doesn't contain the constructor you need. Do you have any other Task files in the workspac/project that you moved the script to?

Edited by fixthissite
Link to comment
Share on other sites

You should show your workspace hierarchy.

When this happens due to relocating, there's a good chance another Task binary file is interfering (one which does not have that constructor, but maybe a constructor which accepts a different script or maybe has no parameters).

Since a ClassNotFoundException was not thrown, there is definitely a Task type, it just doesn't contain the constructor you need. Do you have any other Task files in the workspac/project that you moved the script to?

 

This is all thats in the workspace now and it still gives the error 

 

a1b7d0948c9f8600e389c8c436367b0a.png

I'm taking it that you didn't write that task system yourself? You might want to look into using enum states until you get a little more familiar with Java.

 

In the meantime check out some of this stuff:

https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

https://docs.oracle.com/javase/tutorial/java/IandI/super.html

https://docs.oracle.com/javase/tutorial/java/concepts/interface.html

 

 

I understand all those stuff, I understand how the task system works, not sure what you mean by enum states though so ill check that out, thank you for your help though I appreciate it smile.png

Edited by Chicken Wing
Link to comment
Share on other sites

That's really strange. I'm not sure how the client handles classloading for scripts, so this is a long shot, but:

Is this a local script?

Do you have other local scripts?

Do those other local scripts use the same package hierachy as this one, and possibly contain a core.Task?

Try temporarily removing any other local scripts you may have. This is just to make sure that in the case of the classloader loading types of other local scripts, none of those script's types conflict with the one you are testing.

It would also be helpful to elaborate more on the situation. Do you happen to run any other scripts before running this one? Has this happened to you before (your title says again, so...), and if so what was the issue and was it with this same script? It's easier to help if you give as much detail as possible

Link to comment
Share on other sites

That's really strange. I'm not sure how the client handles classloading for scripts, so this is a long shot, but:

Is this a local script?

Do you have other local scripts?

Do those other local scripts use the same package hierachy as this one, and possibly contain a core.Task?

Try temporarily removing any other local scripts you may have. This is just to make sure that in the case of the classloader loading types of other local scripts, none of those script's types conflict with the one you are testing.

It would also be helpful to elaborate more on the situation. Do you happen to run any other scripts before running this one? Has this happened to you before (your title says again, so...), and if so what was the issue and was it with this same script? It's easier to help if you give as much detail as possible

 

I have just fixed this whole problem by deleting all my workspaces (and projects), and re-downloading eclipse, the script runs fine now as it should...

 

But to answer your questions, it was a local script, and there were other scripts containing a core.task, but the other core.task's had different constructors

 

Ill see if adding more projects now breaks anything

 

EDIT: It doesnt. 

 

I don't know why this happened but its fixed now and I have no (exact) idea why

Edited by Chicken Wing
Link to comment
Share on other sites

I have just fixed this whole problem by deleting all my workspaces (and projects), and re-downloading eclipse, the script runs fine now as it should...

But to answer your questions, it was a local script, and there were other scripts containing a core.task, but the other core.task's had different constructors

Ill see if adding more projects now breaks anything

Yes, the other Tasks having different constructors could have caused the problem. If one of those tasks had higher priority in the classpath than the Task you wanted (assuming they were both loaded in for some reason), you would get that error, since they do not contain the constructor you want (instead, they contain one for a different script)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...