Where to put Java library in ColdFusion? - coldfusion

I have to put my Java Library in Coldfusion and my Coldfusion's Java Virtual Machine Path is C:/ColdFusion9/runtime/jre
In which location I should consider placing my Java Library ?
Coldfusion9/wwwroot/WEB-INF/lib
Coldfusion9/runtime/jre/lib
I can see .jar files at both of the above locations. Hence I'm wondering where should I put my downloaded .jar? I will be restarting CF9 after doing this.
More Info: The documentation here says that it should always be in the JVM's classpath as a rule. Could anyone tell me where, or what, is the rule ?

(This does sound like a duplicate, but my remarks are too long for comments)
Short answer:
The simple option is to place the .jar file in {web_root}/WEB-INF/lib and restart.
Longer answer:
The thread you referenced says that .jar files must be placed somewhere within the CF class path. In loose terms, "class path" just means a collection of paths that CF is going to search for jars/classes when the server starts.
Technically - you are free to place a jar file just about anywhere you want. As long as it is accessible to the CF Server and that path is included in the jvm.config file. However, there are certain locations which CF checks automatically. So you can just place a jar file in one of those directories and restart. No other changes are needed.
Two of the locations CF checks automatically are:
{web_root}/WEB-INF/lib/
{web_root}/WEB-INF/classes/
The comment about the "rule" refers to a convention for the /WEB-INF/ folder that specifies .jar files should be placed in WEB-INF/lib/ while individual *.class files (less common) should be placed in WEB-INF/classes/. Since you are using a jar, it would go in WEB-INF/lib/.
For more details about how and where CF searches for jars, see also
About ColdFusion and Java objects
The Definitive Guide to the ColdFusion Classpath (A bit dated, but most of it is still relevant).

Related

Regarding ColdFusion Mapping

I am rebuilding my directory structure. The old way had CFC folders in each sub-directory that was a nightmare. I went into ColdFusion administrator and set a mapping (which is actually outside my root). Now here is the confusing part.
My original structure looks similar to this.
\appRoot
\appRoot\cfc
\appRoot\modules
\appRoot\modules\cfc
I moved the files from the CFC directory inside of modules to the mapped location and all works great. Next I went to move the files from appRoot directory (which is one up from modules) and no matter what I do it will not find those in the mapped directory. It keeps insisting I put the files back in the CFC directory under appRoot.
So why would pages further down the directory structure see the new CFC mappings and not the pages above them?

Starting jetty outside of ${jetty.home} in Windows with logback

My goal is to set jetty to run as a service and figured I should have it run in command line first. My current aim is to be able to run jetty from root path. Once that's done, I can then set the same command to run as a service via https://nssm.cc/.
The issue
The webapp I am deploying in this Jetty instance uses logback to manage it's logging <file>logs/app.log</file>
This works as expected.
C:\jetty>java -jar start.jar
This does not C:\>java -jar C:\jetty\start.jar. (Note the different cmd path). Jetty can't figure out correct paths for log files. After some testing, I was able to rectify the path issue but still jetty is complaining about not being able to find the log file, even though I see it exists. So, permissions issue perhaps? I go ahead and give everyone full read and write access to the entire folder. No dice, still the same error.
Command I run now
C:\>java -Djetty.base=C:\jetty -Duser.dir=C:\jetty -jar C:\jetty\start.jar but the error persists.
....
12:11:51,095 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [logs/app.log]
12:11:51,111 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - Failed to create parent directories for [C:\jetty\logs\app.log]
12:11:51,111 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - openFile(logs/app.log,true) call failed. java.io.FileNotFoundException: logs\app.log (The system cannot find the path specified)
at java.io.FileNotFoundException: logs\app.log (The system cannot find the path specified)
....
Jetty version is 9.4.9.v20180320
Create a proper ${jetty.base} directory, outside of of the ${jetty.home} directory.
Next, get yourself a fresh copy of jetty-home (or the jetty-distribution which really only adds documentation, demos, and sample bases to jetty-home).
http://search.maven.org/#search|gav|1|g:"org.eclipse.jetty" AND a:"jetty-home"
Unpack that jetty-home artifact into a fresh directory.
Important:
Don't touch any content in jetty-home
Don't edit anything in jetty-home
Don't remove anything from jetty-home
Don't add anything into jetty-home
Leave jetty-home alone
Treat jetty-home as a read-only directory
All above bullets apply even if using jetty-distribution
Lastly, start jetty per the recommendations in the Jetty Documentation.
> cd \path\to\myjettybase
> java -jar \path\to\jetty-home\start.jar
Note the lack of declared system properties for -Djetty.home and -Djetty.base, this is important!
This will set up the following important directory properties.
jetty.base will be your CWD, or \path\to\myjettybase
jetty.home will be where your start.jar was found, aka \path\to\jetty-home\
user.dir will be your CWD and point to \path\to\myjettybase
What's important, for logging configurations like yours, is the user.dir system property. (aka the current working directory)
The technique you are using where you don't pay attention to the working directory and just attempt to force values into the JVM with system properties is only viable in the simplest of projects and usecases. (your requirements have outgrown that kind of setup)

Drupal8 Configuration directories error

I've installed Drupal8 locally using Acquia Dev Desktop interface.
I've got error as below in Reports/Status Report:
Configuration directories Not present
Your sites/drupal-8-2-6.dd/settings.php file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a sync key.
I also could not push to Cloud Dev(internet interface) because it shows error as below:
Requirement Problem:
Configuration directories Not present
Your /settings.php file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a sync key.
My setting.php is under ~/Documents/DRUPAL/drupal-8.2.6/sites/default/settings.php
Should I make changings in this file?
What changes need to make to get rid from error?
thanks.
Precise detailed steps for the user6781412 solution at:
https://www.drupal.org/node/2891394
===
#user6781412 : Thanks
I detailed your solution in precise detail for newbies like myself, but this bloody forum keeps regecting it on the grounds that "Your post appears to contain code, blah, blah, blah."
I gave up after about an additional half-hour trying to format my solution for this site, and have instead posted it at the above URL at drupal.org.
You da' one. Peace out.
"All the best; intended."
Christopher James Francis Rodgers
I've solved the problem and fixed error by creating sync dir. outside of my root. So in this case I've created sync.dir under ~/Documents/DRUPAL and left it empty.
Then I've created code that pointing to this dir as below:
$config_directories = array(
// REPLACE THIS PATH for your path
CONFIG_SYNC_DIRECTORY => '~/Documents/DRUPAL/drupal_sync',
);
This fixed error.
Short history of sync directory:
"Sync directory contains configuration files that help move your site from your local development machines to the production servers. In the past, all configuration was contained in the database and moving from development to production was very troublesome".

External jars with Dropwizard

I am trying to write a Dropwizard application and its doc tells me that I need to ship everything as an uber jar.
However, in my application I need to support multiple databases and this requires multiple database JDBC driver jars in my classpath, all of which are not expected to be shipped together with my application. Users are expected to place the corresponding JDBC jar like mysql-connector-java-5.1.39.jar in a particular folder by their own.
After reading Dropwizard's documentation I am not sure if this kind of usage is supported. Does anyone have experience making it to work this way?
Since java 6, you can wildcard classpaths.
Using the application plugin, the generated bin folder will have a start script that contains the classpath. What we want to do, is to instead of listing every possible jar in the bin folder, we simply include all of them.
Note: You can also do the same thing with different folders if you want the classpath in a different location.
This can be achieved (in a workaround manner since there are problems with this plugin in my version) in the easiest way as follows. In build.gradle you do:
startScripts {
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=\\$APP_HOME/lib/*')
unixScriptFile.text = unixScriptFile.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=\\$APP_HOME/lib/*')
}
}
This will wildcard your lib folder in the start scripts. When starting up, your classpath will simply be
lib/*
When you drop jars into that folder, they will automatically be picked up (on startup, not on runtime).
I hope this helps,
Artur

Pentaho DI / Kettle / Spoon Configuration with External Jars

I am deveoloping a custom plugin for Pentaho DI / Kettle 4.4 and use custom Validation and XSLT jars as part of it.
Those jars are referenced in plugin.xml along with the plugin's jar itself and deployed in the same location as the plugin's jar.
When I try to load this plugin in Spoon GUI, I can see and run the plugin fine till I reach the reference to the external jars and after that I get ClassNotFOund Exception.
I have tried following so far but has not worked :
Add the expernal Jars to libext folder and expect those to be picked up automatically. - Failed. Jars not loaded.
Add -cp command line option to Spoon.bat and specify the Jar files - Did not work.
Turned on -verbose option and search everywhere in the output but the Jars are ignored.
Deployed the Jars next to the plugin's Jar file in the plugin's folder. - Jars are not recognized.
From Within the plugin, if I dynamically load (using Reflection and URL Class Loader) I am able to force the loading of the Jars and it works that way but I would like a simpler classpath fix.
Any class that I reference in the Jar through XSL externsion (XALAN-J Java Extension) is still not recognized / loaded and XSL terminates at the beginning of Extension call.
Searched Google and this site for something similar but did not find specific answers on why SPoon behaves so differently and avoids external code and content.
A similar issue is reported here though its too old and has not shown final conclusive fix. I tried all that it said. http://forums.pentaho.com/archive/index.php/t-77190.html
Requesting someone to help me identify whats missing. Thanks in advance,
Thanks to this seemingly obscure website and it fixed all pain.
http://www.arulraj.net/2014/09/how-to-access-external-java-libraries-with-in-pentaho.html
Basically, go to the launcher folder and edit the launcher.properties file to include any path, library etc. and it fixes all the issues I reported above. Wish Kettle documentatation had answers like this.