javaloader.ClassNotFoundException

Hello everyone,

I want to use cbjavaloader, I put the SAP Java connector (sapjco3.jar) in the lib directory but i getting the this error;

Type: javaloader.ClassNotFoundException
Messages: The requested class could not be found. The requested class ‘JCo’ could not be found in the loaded jars/directories.

my JavaLoader settings is;

javaloader = {
// The array paths to load
loadPaths = [’#controller.getAppRootPath()#/lib/sapjco3.jar’],
// Load ColdFusion classes with loader
loadColdFusionClassPath = false,
// Attach a custom class loader as a parent
parentClassLoader = “”,
// Directories that contain Java source code that are to be dynamically compiled
sourceDirectories = [],
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
compileDirectory = [’#controller.getAppRootPath()#/modules/cbjavaloader/models/javaloader/tmp’],
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
trustedSource = false
};

SAPAdapter.cfc default action is;

component extends=“coldbox.system.EventHandler”{

//property name=“JCo” inject=“javaloader:JCo”;
property name=“javaloader” inject=“loader@cbjavaloader”;

// Default Action
function Index(event,rc,prc){
if(Not Len(getInstance(“sessionStorage@cbstorages”).getVar(“userId”))){
relocate(“Main.Login”);
}
prc.hello = javaloader.create( “JCo” ).init().hello();
abort;
rc.title = getSetting(“appName”);
event.setView(“main/index”);
}

my coldbox version 5.0
if you want to java library i can mail to you.

may you help me?
thanks

Mahmut

Add this to your Application.cfc.

`
this.javaSettings.loadPaths = [ “.\lib” ];

`

For more details, see this thread: Google Groups

To be clear, Ancient Programmer’s suggestion is not to fix javaloader, but to not require java laoder at all by just using the built in CF engine’s ability to load jars. I’ve had to use that jar in the past and it was quite horrible but we got it working using this.javaSettings. I do recall having some issues on our Linux servers related to some C library that the jar tries to load.

Hi Brad,

I put the helloworld.jar from coldbox javaloader sample application to C:\ColdFusion2016\cfusion\lib directory.
I get the success result when I run the following code;

helloWorld = createObject('java','HelloWorld'); writeDump(helloWorld);

object of HelloWorld

Class Name HelloWorld
Methods
Method Return Type
hello() java.lang.String

When I put the helloworld.jar to my coldbox application lib folder, i get the same error
The requested class could not be found. The requested class ‘HelloWorld’ could not be found in the loaded jars/directories.

Thanks your support
Mahmut

6 Ağustos 2018 Pazartesi 20:46:51 UTC+3 tarihinde Brad Wood yazdı:

That’s not enough information for me to help you. Have you confirmed the this.java settings are present. Also note, depending on your engine, I’ve seen CF be picking about leading slashes and the direction of slashes in your javasettings. Might want to review those as well.

Hi Brad,

My Application.cfc javasettings are below, I didn’t change this settings after installation.
thank you for your support.

2018-09-10_14-34-20.jpg

8 Ağustos 2018 Çarşamba 19:36:48 UTC+3 tarihinde Brad Wood yazdı:

Hi,
I solved the problem, I change the javaloader class from version 1.2 to 1.0
my application is running now, hurrah :slight_smile:

10 Eylül 2018 Pazartesi 14:39:19 UTC+3 tarihinde Mahmut Çifçi yazdı: