JavaLoader: Can it add JARs to ColdFusion's "Java Class Path" ?

I want to integrate a Java-based Server Framework with ColdFusion; I
am running ColdFusion 9 in server configuration mode (using JRun).

One way for doing this integration is:
- Copying all JARs needed by the Java-based Server Framework into
'<ColdFusion9_HOME>\runtime\lib'
- In the ColdFusion Administrator, the 'Java Class Path' lists all the
copied 3rd party JARs
- All needed classes are found and the Java-based Server Framework
seems to function properly
- BUT: I am NOT at all sure if I can copy 3rd party JARs into
'<ColdFusion9_HOME>\runtime\lib' in Shared Hosting ...

Therefore, the JavaLoader came to my mind; so I have loaded all the
3rd party JARs via the JavaLoader; BUT: The Java-based Server
Framework cannot find its classes ... Is this perhaps a use case
JavaLoader does NOT address ? Is it only useful for creating classes
(and instances thereof) explicitly ? Or can it help in such an
important use case like this, too ? Perhaps by adding the loaded JARs
to ColdFusion's 'Java Class Path' ?

well, if you are class loading them, they should be found. Unless they are problems with dependencies in the core ColdFusion installation. What problems are you seeing at this point?

Luis F. Majano
President
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Currently I am using a slightly adapted version of Mark Mandel's
original JavaLoader.cfc; without using any ColdFusion Framework; this
is the code I use:

<cfscript>
  myLibPath = "c:\JARsDir";

  //create the loader
  javaLoader = createObject("component", "javaloader.JavaLoader");

  myJARs = arrayNew(1);
  myJARs = javaLoader.queryJars(myLibPath);

  javaLoader.init(myJARs);
</cfscript>

In the ColdBox JavaLoader Plugin Example it is written:

This is the code to load the plugin:
- application.myLoader = getPlugin("JavaLoader").setup("includes/
helloworld.jar");

This is the code to load a class and place it in the request
collection
- setvalue("HelloWorldObj",
application.myLoader.create("HelloWorld").init());

What do You mean by "Class Loading" ? Invoking the 'setup()' method of
the JavaLoader ? Or invoking the 'create()' method with a concrete
class name at hand ?

Perhaps the standalone JavaLoader.cfc does not work as the ColdBox
Plugin one ?

It works exactly the name we wrap it in our class to boot strap it into an application with some settings. But it is the same java loader core.

My question is, what is your problem? Do you get an error? What?

Luis F. Majano
President
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

The Class-Loading - as described above - and the Class-Using takes
place in one and the same template; and the problem is: The classes in
the Class-Loaded JARs are just not found; as opposed to when I load
the JARs statically at ColdFusion (9) server startup, by dropping them
into '<COLDFUSION9_HOME>\runtime\lib'

Can we see the code that you are using to load up the classes?

Are you trying to create the Java objects through createObject or JavaLoader?

Mark

I have outlined the code already above ...

So you did. So what is the exact error you are getting?

I’m guessing that there is a library that your framework needs hat is missing from the jars you have loaded.

Stupid question - if you are using straight JavaLoader, how come you didn’t ask this question on the JavaLoader mailing list?

Mark

Hello Mark !

1. Why the JavaLoader question in the ColdBox forum, not in the
JavaLoader forum: This probably happened by chance because I am also
testdriving ColdBox; and am aware that it has incorporated the
JavaLoader.cfc ... Next time I will ask questions in the JavaLoader
forum directly.

2. The list of JARs I have put into '<ColdFusion9_HOME>\runtime\lib'
is exactly the list of JARs I let JavaLoader digest; only that the
first approach works properly (please see the beginning of this
thread)

3. The erroneous behaviour: In the browser nothing is displayed; in
the logs I find the following error message:
      "com/isomorphic/taglib/LoadISCTag The specific sequence of files
included or processed is: K:\ColdFusion9\wwwroot\smartclient
\testAll.cfm, line: 2 "
java.lang.NoClassDefFoundError: com/isomorphic/taglib/LoadISCTag",
whereas 'LoadISCTag' is the class belonging to the custom JSP tag
'LoadISC' ...

Only putting the one JAR containing the classes for the custom JSP
tags into WEB-INF\lib (does not help) or \runtime\lib (ColdFusion9 is
disturbed) is not solution, too ...

Have You ever tried to let JavaLoader load the classes belonging to
custom JSP tags ? Perhaps this is what makes this scenario unique ...

Cheers and Tschüss

Kai

Hello Mark !

  1. The list of JARs I have put into ‘<ColdFusion9_HOME>\runtime\lib’
    is exactly the list of JARs I let JavaLoader digest; only that the
    first approach works properly (please see the beginning of this
    thread)

Yes, I read that - but there could be a dependency that is in the CF lib already, that you haven’t loaded up with JavaLoader, so it works in 1 and not the other.

  1. The erroneous behaviour: In the browser nothing is displayed; in
    the logs I find the following error message:
    “com/isomorphic/taglib/LoadISCTag The specific sequence of files
    included or processed is: K:\ColdFusion9\wwwroot\smartclient
    \testAll.cfm, line: 2 "
    java.lang.NoClassDefFoundError: com/isomorphic/taglib/LoadISCTag”,
    whereas ‘LoadISCTag’ is the class belonging to the custom JSP tag
    ‘LoadISC’ …

Is that class actually loaded? I.e. is it in a JAR file that you passed to JavaLoader?

Probably be good to see the whole error too - there may be a ‘Caused by’ clause that shows the ultimate error.

I find it’s good to wrap a try/catch around the erroring code, and dumping out the catch, as it can often give you the most detail.

Mark

Hello Mark !

A quick reply before I might go on with further investigation:
- Error is "Caused by: java.lang.ClassNotFoundException:
com.isomorphic.taglib.LoadISCTag"

- The code
    javaLoader.create("com.isomorphic.taglib.LoadISCTag");
  runs gracefully and tells me that the class
'com.isomorphic.taglib.LoadISCTag' IS actually loaded ...

- Your statement: "There could be a dependency that is in the CF lib
already, that you haven't loaded up with JavaLoader, so it works in 1
and not the other."

  Does this statement suggest that I should additionally reload all
the CF JARs with the JavaLoader ?

Cheers and Tschüss

Kai