Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3849 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

(Apologies if this is made clear somewhere else, I can not seem to find an answer here or anywhere)

 

Thank you for looking at this and for any feedback. I am not sure if my issue is a bug or a feature...

 

I have just created my first plugin. It requires 2 jar files which are not included with SM.

It seems the function will not work unless I have the 2 jar files in a directory where java expects to find jar files (by default, or some other location which has been added to the path file). This is not an issue on my development machine, but my intention is to make this portable.

 

So the question at hand is this:

Does ScriptMaster, and/or plugins generated with SMA, completely handle the loading of jars? or do I need to have the jars located in a folder where java expects to find them?

 

I have:

  • Added the jars to SM using the 'add' button on the Jar Libraries layout, in the ScriptMaster File
  • Associated the jars to the script via the checkboxes in the 'Jars' tab of the Edit Script Layout
  • Verified the Jars are loaded using SMGetLoadedJars
  • Successfully tested the function with the 'Run Script' Button on the Edit Script Layout
  • Registered the Function (and set it to register on startup)
  • Successfully tested the function in the FM solution I intend to use it with

 

Everything works until I remove the jars from /Library/Java/Extensions (on osx).

Then, after restarting FM, my function returns an error indicating it can not find the class it needs (which is to say, it cant find the jar). I have tested this thoroughly.

 

Is this the way it is supposed to work?

 

Please let me know if I can provide more info to help troubleshoot this.

 

My sincerest thanks to anyone who can point me in the right direction,

-Jim

java version "1.6.0_65"
Java SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot 64-Bit Server VM (build 20.65-b04-462, mixed mode)

 

Posted

Why not load them on the fly from a container as in the documentation??

 

Assuming the jar files are held in a repeating global container, loop through the number of filled reps and test

SMLoadJar( GetRepetition ( Globals::g_JAR ; $i ) )

 

this then loads the files to the JVM as you might expect, until removed by closing FMP or calling SMReset

Posted

Thank you John for taking the time to help.

 

I had assumed that the calls you suggested, were already happening within the ScriptMaster File when I did the following...


I have:

  • Added the jars to SM using the 'add' button on the Jar Libraries layout, in the ScriptMaster File
  • Associated the jars to the script via the checkboxes in the 'Jars' tab of the Edit Script Layout
  • Verified the Jars are loaded using SMGetLoadedJars
  • Successfully tested the function with the 'Run Script' Button on the Edit Script Layout
  • Registered the Function (and set it to register on startup)
  • Successfully tested the function in the FM solution I intend to use it with

 

going on that assumption, I had planed to write those calls into my Open Script.

 

but we all know what happens when I assume, so I am going to test those calls a little later tonight.

I will let you know (I'm sure your on the edge of your seat and cant wait to hear :cofeebrake:  )

 

thanks,

-Jim

Posted

Thank you again John,

 

It seems your suggested approach is exactly what takes place when you run the Load All Jars script found in the ScriptMaster file. (which is what I assumed, and why I did not test it myself)

 

However, never to take things at face value, I implemented the procedure in my own file. I wrote a script using the following calls:

SMLoadJar

loading my jar (turns out I only need one: mysql-connector-java-5.1.30-bin.jar)

SMGetLoadedJars

confirming my jars are loaded

RegisterGroovy

initializing my function for use

After this, the new function is available as an external function and, as I said, the jar is loaded.

But no joy.

 

So I quit FM, place the jars in the java extensions folder, then start FM again. BAM! works perfectly.

 

I then tested this thoroughly and am back to this:

  1. Despite the fact that the jar is loaded and the function is registered, the function wont work unless the jar is located where java expects to find it, in the default path (or - I'm assuming, I haven't tried yet) a path named in the java path file.
     
  2. I have now discovered that I need not even use SMLoadJar, as long as the jar is in the path where java expects to find it, the function works in the ScriptMaster file, and, when Registered, any file, even the data viewer.

 

Since this works for you, my problem could be attributed to my environment.

Can you tell me the name of a class you use (a class not included in the standard SM jars)? so I can write a little groovy script using that class, and then test if loading that jar works for me, as it does for you.

 

(if you want to be a real hero, you can try using the jar and class I am using. The jar is attached, just call "import groovy.sql.Sql". The function I use is 'rows')

 

Of course, any additional suggestions you may have are most gratefully welcome,

-Jim

mysql-connector-java-5.1.30-bin.jar.zip

Posted

Thanks for the info

 

This is one of the few instances where you CANT load that jar on the fly as outlined above

it needs to sit in the ~root/Library/Java/Extensions folder

 

The groovy SQL is not calling the connector as far as I know, it is just explicitly extending the Groovy to allow use of the classes

 

a line something like

sql = Sql.newInstance('jdbc:mysql://100.100.100.100/sqlTable', 'user', 'password', 'com.mysql.jdbc.Driver')

 

is what connects the Groovy to the correct connector to the table - and it is the com.mysql.jdbc.Driver class which can not be loaded dynamically from the .jar file - which is why it needs to be in the path.

 

I am using this successfully in all kinds of applications....

 

 

john

  • Like 1

This topic is 3849 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.