ColdFusion/Java - Class not found: org.apache.ws.security.WSConstants - java

The following code throws an error "Class not found: org.apache.ws.security.WSConstants"
<cfset variables.WSConstantsObj = CreateObject("Java","org.apache.ws.security.WSConstants")>
I'm not sure if this should just work out of the box or whether there is something else I need to do to instantiate this java object.
Can anyone help?

I appear to have figured it out.
Needed a couple of other jar files loaded first, in my particular instance.
variables.paths = arrayNew(1);
variables.paths[1] = getDirectoryFromPath(getCurrentTemplatePath()) & "lib\wss4j-1.5.8.jar";
variables.paths[2] = getDirectoryFromPath(getCurrentTemplatePath()) & "lib\xmlsec-1.4.2.jar";
variables.loader = createObject("component","lib.javaloader.JavaLoader").init(loadPaths=variables.paths,loadColdFusionClassPath=true);
variables.WSConstantsObj = loader.create("org.apache.ws.security.WSConstants");

Related

How to split the string using comma delimiter in Jenkins Groovy script?

I have tried to get all the solution files(*.sln) in a given path and print it individually by split the string(each solution file path) using comma delimiter. Programming script language am using is Jenkins Groovy. Am getting the below specified error when build the Jenkins job. Any one please look into this and guide me to proceed in a right way.
def finder = new FileNameFinder()
def files = finder.getFileNames 'D:\jobs', '**/*.sln'
def resultList = files.tokenize(",")
for(i=0; i<resultList.size();i++)
{
println resultList[i]
}
Error Details:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.tokenize() is applicable for argument types: (java.lang.String) values: [,]
Possible solutions: toUnique(), toUnique(), toUnique(java.util.Comparator), takeWhile(groovy.lang.Closure), toUnique(groovy.lang.Closure), toUnique(java.util.Comparator)
Thanks in advance!!
Myself itself found an answer for my above problem. Please find below the modified working code.
def finder = new FileNameFinder()
def files = finder.getFileNames 'D:\jobs', '**/*.sln'
assert files instanceof List
println files.size()+" solution files found in the given path. Below are the found solution files details. \n"
for(i=0;i<files.size();i++)
{
println files[i];
}
Thanks

not enough java heap space' r programming

I am out of my R depth. I defined a function nGrams (using RWeka) that worked fine when I tried it out, and sometimes it still does. I do not know how to figure out what environment it works in, what environment I am in when I want to use it, etc. Any quick tips or can you point me to a webpage that could help? If I have to put in a change environment command every time I use it, that is just fine. I really do not understand the issue.
here is what I see in my console.
blog2gramfreq <- nGrams(cleanblogs100000, 2)
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
Called from: top level
Called from: top level
Browse[1]>
structure(function (this, private = FALSE, ...)
{
envir <- attr(this, ".env")
ls(envir = envir, all.names = private)
}, export = FALSE, S3class = "Object", modifiers = "public")
I do see nGrams in my Global Environment window.
This was something that came up in a Coursera class blog that i did not find an answer to, at least for R. Here is an answer that worked for me when I received the "'OutOfMemoryError : not enough java heap space" error in R programming.
options(java.parameters="-Xmx4000m")

Using meta learning in RWeka

I used RWeka to call Weka functions directly in R.
I tried using meta learning (bagging) but failed.
My code is Bagging(classLabel ~ ., data = train, control = Weka_control(W = J48))
However, the following error pops up:
Error in Bagging(classLabel ~ ., data = train, control = Weka_control(W = J48)) :
unused argument(s) (data = train, control = Weka_control(W = J48))
I also tried several different base learners but always met such error.
If you successfully used meta learning in RWeka before, please let me know.
Just tried another writing:
optns <- Weka_control(W = "weka.classifiers.trees.REPTree") Bagging <- make_Weka_classifier("weka/classifiers/meta/Bagging") model <- Bagging(classLabel ~ ., data=dat, control = optns)
Surprisingly the R code works now.
-Credit Leo5188

Javac AST Symbol Resolving for JavacTask.parse()

As I posted on the official Java support forum several days ago, I want to know, if JCTree Symbols can be resolved from own code with the original javac implementation.
http://forums.oracle.com/forums/thread.jspa?threadID=1774807&tstart=0
JCMethodInvocation object1 = (JCMethodInvocation) objectRef.ref;
Resolve resolve = Resolve.instance(javacTaskImpl.getContext());
ListBuffer<Type> argtypeListBuffer = new ListBuffer<Type>();
AttrContext attrContext = new AttrContext();
Env<AttrContext> env = new Env<AttrContext>((JCTree) objectRef.ref, attrContext);
System.out.println(type);
System.out.println(type.tsym);
resolve.resolveInternalMethod(object1.pos(), env, type, name, argtypeListBuffer.toList(), null);`
I recommend you to investigate how com.sun.tools.javac.main.JavaCompiler do symbol resolving. I think it is inside #enterTrees(List)
Also you may be interested in projects http://bitbucket.org/amelentev/juast/ and projectlombok.org

What's a java equivalent for std::round(double)?

In cpp file I have std::round(double)
Please can I know the equivalent code in Java
Edit: I am already using java.lang.Math.round(double) and getting match in 99% cases. But in some places iam getting mismatch. For example:
std::round(4816.5058) = 4816 and Math.round(4816.5058) = 4817
std::round(4466.49996) = 4467 and Math.round(4466.49997) = 4466
java.lang.Math.round(double)

Categories

Resources