1

I have beeen using JACOB in my java program to work but I run into an error everytime I try to get an ITTrack from an ITTrackCollection.

This is the line that gives the error:

a.add(t.getItem(1));

This is the error:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: com.jacob.com.Dispatch.call(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)Lcom/jacob/com/Variant;
    at com.dt.iTunesController.ITTrackCollection.getItem(ITTrackCollection.java:42)
    at iq.Main.addSong(Main.java:27)
    at iq.Main$listener.onHotKey(Main.java:70)
    at com.melloware.jintellitype.JIntellitype$1.run(JIntellitype.java:396)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
com.jacob.com.Dispatch.call(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)Lcom/jacob/com/Variant;

a is an arraylist of ITTrack and t is an ITTrack collection. t definitely has more than two ITTracks in it.

Thanks

Laurent Pireyn
  • 6,735
  • 1
  • 29
  • 39
Connor Pearson
  • 63,902
  • 28
  • 145
  • 142

1 Answers1

1

Your code is invoking a method which can not be found in the Dispatch class with the following signature:

Variant call(Dispatch dispatchTarget, String name, Object attributes)

Looking at the Jacob documentation, the following method from that class most closely matches that one:

Variant call(Dispatch dispatchTarget, String name, Object... attributes)

Note that the last parameter is different (vararg - an array of Object).

Did you compile your code against a different version of the library?

jackrabbit
  • 5,525
  • 1
  • 27
  • 38
  • I'm not sure. I haven't been using jacob directly. I've been using iTunes controller. http://www.dot-totally.co.uk/software/itunescon/ – Connor Pearson May 15 '11 at 21:15
  • Try using an older version of Jacob then. Perhaps they changed their API since the last release of iTunes controller. Assuming you're using something like Maven to resolve the Jacob dependency, it may not have a strict enough version specification. Perhaps ask around on the Jacob or iTunes controller mailing lists about versions. – jackrabbit May 16 '11 at 07:21
  • Looks to me like the Jacob 1.6 API was rather different. It has the following Dispatch method: Variant call(Object disp, String name, Object arg). Either use that version or recompile the iTunes controller library against the newer Jacob library. – jackrabbit May 16 '11 at 07:25
  • Thanks. Changing the library to 1.15 M2 did work for a while but now I'm getting this error: Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Dispatch not hooked to windows memory – Connor Pearson May 19 '11 at 21:41
  • Not a clue what that is about. It sounds to me like you still don't have the exact version against which iTunes Controller was developed. I suggest you ask on their mailing list or ask a new question here to attract more eyes. Since it is an entirely new topic and your original question was answered, perhaps you could accept my answer? – jackrabbit May 21 '11 at 07:09