[Coldbx 4.1.0+00002][CBJavaloader] Mapping to the classpath

I’m finishing up an update to the CBMongoDB module which removes the outdated CFMongoDB library dependency and uses the 3.1 driver (with async driver options coming in the near future).

I’m running in to a problem using the CBJavaloader where, when it creates the object with the correct Java classes, instantiation on any com.mongo.* objects which instantiate using the classes in the driver fail.

The error reflects that the correct class types are being passed in, but there seems to be some conversion in the Javaloader that throws a type error when I attempt to instatiate. You can see the usage in the connect() method here: https://github.com/jclausen/cbmongodb/blob/development/models/Mongo/Client.cfc and in models/Mongo/Config.cfc

When I add the 'modules/cbmongodb/lib' directory to the Application.cfc javaSettings paths, everything works, though. It appears that I’ll have to have the driver classes available in the class path.

Rather than having to add that instruction to modify Application.cfc, I’d like users to be able run box install cbmongodb and go. Any thoughts on how I could use CBJavaloader to accomplish this?

Thanks much,

Jon

Jon,

Few observations

https://github.com/jclausen/cbmongodb/blob/development/ModuleConfig.cfc#L42-L45

You don’t need to map javaloader again. You can get an instance of it and append paths instead.

wirebox.getInstance( "loader@cbjavaloader” ).appendPaths( dirPath );

You also, need to get access to “loader@cbjavaloader”. If not, you might be accessing invalid scopes. Try it and let me know

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Thanks, Luis. I’ve got some code smells to clean up, I was trying some different things early on when converting over to use the native driver, so thanks for pointing that one out.

I’ve tried using "loader@cbjavaloader” but couldn’t seem to gain any traction there. I’ll play with it again, though. I may just have to add a note in the directions to append the Application javaSettings array or package a different JavaLoader that makes those available on the class path.

Shouln’t it be something like:

`
javaloader.create(“com.mongodb.MongoClient”);

`

I have a similar problem, not sure if it’s a javaloader bug or whatelse.

I hae this component:

`

component accessors=“true” singleton{

property name=“javaloader” inject=“loader@cbjavaloader”;
property name=“token”;
property name=“expire”;
property name=“scope”;

GaService function init(serviceAccountId,pathToKeyFile,analyticsAppName) onDIComplete{
variables.serviceAccountId = arguments.serviceAccountId;
variables.pathToKeyFile = arguments.pathToKeyFile;
variables.analyticsAppName = arguments.analyticsAppName;
return this;
}

public function loadAnalytics(){

variables.HTTP_Transport = javaloader.create(“com.google.api.client.http.javanet.NetHttpTransport”).init();
variables.JSON_Factory = javaloader.create(“com.google.api.client.json.jackson2.JacksonFactory”).init();
variables.HTTP_Request_Initializer = javaloader.create(“com.google.api.client.http.HttpRequestInitializer”);
variables.Credential_Builder = javaloader.create(“com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder”);

variables.Collections = javaloader.create(“java.util.Collections”);
variables.File_Obj = javaloader.create(“java.io.File”);

variables.credential = Credential_Builder
.setTransport(variables.HTTP_Transport)
.setJsonFactory(variables.JSON_Factory)
.setServiceAccountId(variables.serviceAccountId)
.setServiceAccountScopes(Collections.singleton(“https://www.googleapis.com/auth/analytics.readonly”))
.setServiceAccountPrivateKeyFromP12File(variables.File_Obj.Init(variables.pathToKeyFile))
.build();
}

public function getToken(){

if(isNull(variables.token) OR isExpiredToken()){
generateToken();
}

return variables.token;

}

public function generateToken(){

variables.credential.refreshToken();
var access_token = variables.credential.getAccessToken();
setToken(access_token);
setExpire(DateAdd(“n”,45,Now()));

}

public function isExpiredToken(){

var diff = DateDiff(“n”, Now(), variables.expire)
return diff LTE 1 ? true : false;

}

}

`

If I try to load a class with javaloader on the init method I got this error:

`

Type: Builder.BuildCFCDependencyException
Messages: Error building: GaService@cbseo -> variable [javaloader] doesn’t exist with constructor arguments: {} Mapping: {metadata={{inheritancetrail={[modules.contentbox.modules_user.cbSeo.models.GaService, lucee.Component]}, hint={This is the Base Component}, remoteAddress={http://127.0.0.1:50048/cbapp/modules/contentbox/modules_user/cbSeo/models/GaService.cfc?wsdl}, singleton={}, path={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, displayname={Component}, synchronized={false}, fullname={modules.contentbox.modules_user.cbSeo.models.GaService}, properties={[{name={expire}, type={any}}, {inject={loader@cbjavaloader}, name={javaloader}, type={any}}, {name={scope}, type={any}}, {name={token}, type={any}}]}, name={modules.contentbox.modules_user.cbSeo.models.GaService}, accessors={true}, type={component}, persistent={false}, functions={[{access={public}, returnFormat={wddx}, returntype={GaService}, output={true}, closure={false}, parameters={[{required={false}, name={serviceAccountId}, type={any}}, {required={false}, name={pathToKeyFile}, type={any}}, {required={false}, name={analyticsAppName}, type={any}}]}, ondicomplete={}, name={init}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={true}, closure={false}, parameters={[]}, name={loadAnalytics}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={true}, closure={false}, parameters={[]}, name={getToken}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={true}, closure={false}, parameters={[]}, name={generateToken}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={true}, closure={false}, parameters={[]}, name={isExpiredToken}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={false}, closure={false}, parameters={[{required={true}, name={scope}, type={any}}]}, name={setScope}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={false}, closure={false}, parameters={[{required={true}, name={token}, type={any}}]}, name={setToken}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={false}, closure={false}, parameters={[{required={true}, name={expire}, type={any}}]}, name={setExpire}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={any}, output={false}, closure={false}, parameters={[{required={true}, name={javaloader}, type={any}}]}, name={setJavaloader}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={string}, output={false}, closure={false}, parameters={[]}, name={getScope}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={string}, output={false}, closure={false}, parameters={[]}, name={getExpire}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}, {access={public}, returnFormat={wddx}, returntype={string}, output={false}, closure={false}, parameters={[]}, name={getJavaloader}, owner={E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc}, description={}}]}, hashCode={10647019}}}, mixins={[]}, autoAspectBinding={true}, cache={{provider={}, key={}, lastAccessTimeout={}, timeout={}}}, constructor={init}, DIProperties={[{ref={null}, required={true}, argName={}, dsl={loader@cbjavaloader}, javaCast={null}, name={javaloader}, type={any}, value={null}, scope={variables}}]}, onDIComplete={[init]}, name={GaService@cbseo}, scope={singleton}, value={}, extraAttributes={{}}, method={}, autoWire={true}, providerMethods={[]}, DIMethodArgs={[]}, threadSafe={false}, alias={[GaService@cbseo]}, autoInit={true}, path={modules.contentbox.modules_user.cbSeo.models.GaService}, virtualInheritance={}, eagerInit={false}, dsl={}, DISetters={[]}, type={cfc}, DIConstructorArgs={[]}, discovered={true}, aspect={false}}, Stacktrace: variable [javaloader] doesn’t exist at lucee.runtime.type.scope.UndefinedImpl.getCollection(UndefinedImpl.java:404):404 at modules.contentbox.modules_user.cbseo.models.gaservice_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\modules\contentbox\modules_user\cbSeo\models\GaService.cfc:12):12 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1773):1773 at lucee.runtime.tag.Invoke.doComponent(Invoke.java:221):221 at lucee.runtime.tag.Invoke.doEndTag(Invoke.java:194):194 at system.ioc.builder_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc:127):127 at system.ioc.builder_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.injector_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc:288):288 at system.ioc.injector_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.scopes.singleton_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\scopes\Singleton.cfc:49):49 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.injector_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc:261):261 at system.ioc.injector_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.builder_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc:471):471 at system.ioc.builder_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.ioc.builder_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc:346):346 at system.ioc.builder_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1777):1777 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.ioc.injector_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc:603):603 at system.ioc.injector_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.injector_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc:490):490 at system.ioc.injector_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1777):1777 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.ioc.scopes.noscope_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\scopes\NoScope.cfc:33):33 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.ioc.injector_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc:261):261 at system.ioc.injector_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.web.services.handlerservice_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\services\HandlerService.cfc:120):120 at system.web.services.handlerservice_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\services\HandlerService.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.web.services.handlerservice_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\services\HandlerService.cfc:141):141 at system.web.services.handlerservice_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\services\HandlerService.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at system.web.controller_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc:502):502 at system.web.controller_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.web.controller_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc:425):425 at system.web.controller_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1777):1777 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.frameworksupertype_cfc$cf.udfCall3(E:\ColdfusionBuilder\ContentBox\coldbox\system\FrameworkSupertype.cfc:355):355 at system.frameworksupertype_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\FrameworkSupertype.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at modules.contentbox_admin495.handlers.modules_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\modules\contentbox-admin\handlers\modules.cfc:60):60 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.eventhandler_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\EventHandler.cfc:78):78 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1777):1777 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.web.controller_cfc$cf.udfCall3(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc:761):761 at system.web.controller_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.web.controller_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc:599):599 at system.web.controller_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at system.web.controller_cfc$cf.udfCall2(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc:425):425 at system.web.controller_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\web\Controller.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1777):1777 at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:773):773 at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1599):1599 at coldbox.system.bootstrap_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\Bootstrap.cfc:197):197 at coldbox.system.bootstrap_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\Bootstrap.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at coldbox.system.bootstrap_cfc$cf.udfCall1(E:\ColdfusionBuilder\ContentBox\coldbox\system\Bootstrap.cfc:353):353 at coldbox.system.bootstrap_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\coldbox\system\Bootstrap.cfc):-1 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1589):1589 at application_cfc$cf.udfCall(E:\ColdfusionBuilder\ContentBox\Application.cfc:87):87 at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111 at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328 at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:641):641 at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524 at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1760):1760 at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:405):405 at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:131):131 at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:35):35 at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2257):2257 at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2224):2224 at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:456):456 at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:47):47 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790):790 at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85):85 at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:82):82 at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61):61 at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36):36 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43 at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249):249 at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:192):192 at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:160):160 at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213):213 at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171):171 at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145):145 at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92):92 at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389):389 at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60):60 at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132):132 at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85):85 at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61):61 at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36):36 at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131):131 at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56):56 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43 at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45):45 at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63):63 at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58):58 at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70):70 at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76):76 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43 at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43 at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261):261 at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247):247 at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76):76 at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166):166 at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197):197 at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759):759 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source):-1 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1 at java.lang.Thread.run(Unknown Source):-1

Tag Context:

Template: E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Builder.cfc
LINE: 131: <cfthrow message="Error building: #thisMap.getName()# -> #cfcatch.message# #cfcatch.detail# with constructor arguments: #constructorArgs.toString()#"
132: detail="Mapping: #thisMap.getMemento().toString()#, Stacktrace: #cfcatch.stacktrace#"
133: type=“Builder.BuildCFCDependencyException”>
134:
135:
Template: E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc
LINE: 286: switch( thisMap.getType() ){
287: case “cfc” : {
288: oModel = instance.builder.buildCFC( thisMap, arguments.initArguments ); break;
289: }
290: case “java” : {
Template: E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\scopes\Singleton.cfc
LINE: 47:
48: // construct the singleton object
49: tmpSingleton = instance.injector.buildInstance( arguments.mapping, arguments.initArguments);
50:
51: // If not in wiring thread safety, store in singleton cache to satisfy circular dependencies
Template: E:\ColdfusionBuilder\ContentBox\coldbox\system\ioc\Injector.cfc
LINE: 259:
260: // Request object from scope now, we now have it from the scope created, initialized and wired
261: target = instance.scopes[ mapping.getScope() ].getFromScope( mapping, arguments.initArguments );
262:
263: // Announce creation, initialization and DI magicfinicitation!

`

In my moduleConfig I append paths:

`

function onLoad(){
// Let’s add ourselves to the main menu in the Modules section
var menuService = controller.getWireBox().getInstance(“AdminMenuService@cb”);
// Add Menu Contribution
menuService.addSubMenu(topMenu=menuService.MODULES,name=“cbSeo”,label=“Seo”,href="#menuService.buildModuleLink(‘cbSeo’,‘main’)#");
controller.getWireBox().getInstance( “loader@cbjavaloader” ).appendPaths( settings.libPath );
}

`

And if I try to instantiate something inside the ModuleConfig onload method it works:

`

function onLoad(){
// Let’s add ourselves to the main menu in the Modules section
var menuService = controller.getWireBox().getInstance(“AdminMenuService@cb”);
// Add Menu Contribution
menuService.addSubMenu(topMenu=menuService.MODULES,name=“cbSeo”,label=“Seo”,href="#menuService.buildModuleLink(‘cbSeo’,‘main’)#");
controller.getWireBox().getInstance( “loader@cbjavaloader” ).appendPaths( settings.libPath );
dump(controller.getWireBox().getInstance( “loader@cbjavaloader” ).create(“com.google.api.client.http.javanet.NetHttpTransport”));abort; //THIS LOAD CORRECTLY CLASS
}

`

This one I can probably help with. “loader@cbjavaloader” requires an init argument of Coldbox, which is handled on Module registration. Something’s off in your Wirebox config or in the order that your injection is taking place with regard to module registration.

Jon

Jon, could you give me some input?

What should I put in wirebox config? If I load those java class in an onDIComplete it works.

Correct. That has been my implementation, but I was having difficulties instantiating Mongo through the JavaLoader.

I have it all working beautifully within the Coldbox app context now, though my test suite for that module is still messed up. Luis noticed the problem: the separate mapping for the javaloader was causing scope issues. Remove that mapping and adding an appendPaths() in the module load fixes the issue: https://github.com/jclausen/cbmongodb/blob/development/ModuleConfig.cfc

I needed to update that test suite anyway. When I created that module, it was the first time I used the BDD tests and, early on in development, I was using a separate Application scope and a custom Wirebox config instance to run the tests. The module needs to be tested within the framework context anyway, though, so I’m going to update those today and, hopefully, merge development to master.

Thanks,

Jon

You shouldn’t need any config for the javaloader in your Wirebox config. Those mappings are taken care of by the module. As long as the module is registered, you should be able to inject loader@cbjavaloader and begin working.

The appendPaths() function ads a new directory of *.jars, and is the missing link there. I you look at the onLoad() function for the cbmongodb module, you can see the usage:
https://github.com/jclausen/cbmongodb/blob/development/ModuleConfig.cfc

Once that module is registered, the javaloader is able to be injected and any of the “com.mongo.” or “org.son.” types used in the driver.

Thanks Jon,

but in my module config I have alreadyappendPaths:

`

function onLoad(){
// Let’s add ourselves to the main menu in the Modules section
var menuService = controller.getWireBox().getInstance(“AdminMenuService@cb”);
// Add Menu Contribution
menuService.addSubMenu(topMenu=menuService.MODULES,name=“cbSeo”,label=“Seo”,href="#menuService.buildModuleLink(‘cbSeo’,‘main’)#");
controller.getWireBox().getInstance( “loader@cbjavaloader” ).appendPaths( settings.libPath );
}

`

Forget to mentions that this is a contentbox module. However onDIComplete solve my problem, but I’m just curious what’s wrong here…

Do you have a dependency specified for cbjavaloader in your module config? If not, the module probably isn’t loaded before your module. Adding that as a dependency should fix the issue:

// Module Dependencies to be loaded in order
this.dependencies       = ['cbjavaloader'];

That said, I can’t remember how the load order of ContentBox modules is handled compared to Coldbox modules. Luis or Brad might be able to weigh in, if the above doesn’t work.