Mike London

Ranch Hand
+ Follow
since Jul 12, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Mike London


I created a SparkJava WAR file and deployed to Tomcat. Two of the methods there, in the required init() method, work fine. Yet, a third one I tried to add today to let me compute TimeZones, doesn't work if I pass a URL-encoded parameter.

So, if I send:


to a web service where I'm encoding the "Asia/Manila" parameter, it doesn't respond. In fact, the method never gets called.

If I take off the encoding portion, then the method does get called, but, of course, that's the wrong format.

The exact same method in a regular Spark Java application where I just run the executable JAR from the command line works fine.



The code is simple:


Any ideas why the exact same code wouldn't work as expected in the WAR file implementation as with the JAR file implementation?

Appreciate any suggestions.

- mike

1 week ago

Guillermo Gutierrez wrote:My first post since I found this friendly place around 2008

To load the WSDL, internally it uses the method getResource(string path) of the ClassLoader class (see http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/xml/internal/ws/transport/http/server/EndpointImpl.java, method  getPrimaryWsdl, lines 265-278). So, an option is to include the WSDL file (let's say its name is ImageWebService.wsdl) inside the package, for example inside the package com.mycompany.imagewebservice. Then, on the annotation, write:

@WebService(serviceName = "ImageWebService",

You can find more info about how ClassLoader works here: http://www.thinkplexx.com/learn/howto/java/system/java-resource-loading-explained-absolute-and-relative-names-difference-between-classloader-and-class-resource-loading

As I mentioned, I solved the issue, but thanks for your reply.

-- mike
1 week ago
Using the example at jwt.io, and related Java Postings, which (confusingly) don't use the same example data, I'm not able to create the same hashed value they have on their page.

This is the code I"m working with from that page:

But it doesn't generate the same value as shown there.

For me, using the code above, I get: "eyJhbGciOiJIUzI1NiJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJhZG1pbiI6IHRydWUKfQ.9kg87S4P-lGhcSpT5r-sQfSyxgD5GhwmnN4LFZjw8uI"

It's not clear if I need to specify the header or exactly how to do it if needed.

The examples I've found suffer from snippet-only presentation, but not a full working simple-to-understand example.

Would appreciate any suggestions how to get the same hashed value as shown on jwt.io.

I'm sure I'm missing something basic...


- mike

2 weeks ago

Stephan van Hulst wrote:The index file is used to speed up the process of finding class definitions. When the index file isn't correct, the runtime isn't going to find the classes involved, regardless of whether they are in the correct place.

JAR signing shouldn't have any relation to this problem. It's just that when you sign the JAR, you get a security exception when you alter any part of the JAR after you've created it, including deleting the index file. That's why you need to delete both the index and the signature files.

Mike, can you recreate the problem with a new project that doesn't contain proprietary data?

I will try to get you a sample, but the project, or one like it, uses two (commercial) third party JARs so I couldn't post them anyway.

Appreciate all your help.

- mike
1 month ago

Stephan van Hulst wrote:Apparently IntelliJ generates an index file for your application and signs the JAR.

You can Google how to disable signing in IntelliJ, but it doesn't explain why execution fails. I surmise it has to do with the generated index. Can you post the contents of the index file?

Didn't see anything online about disabling signing, only enabling (or wishing for) signing.

I could email you the file, but too proprietary to post.

Thanks Stephan.

- mike
1 month ago

Norm Radder wrote:Did you try this?

java -cp TheJarFileName.jar CopyFromAToB

If that worked it would say the class file was ok but maybe there was a problem with the manifest file.

Yeah, sorry, meant to say that didn't work either.

In any case, I seem to have found the "problem", but I don't understand what's going on.

In the META-INF folder, Intellij is putting a bunch of files there I have no idea why.

For example there is a benign LICENSE.TXT (apache) file, but also an INDEX.LIST file. If I tried to remove the INDEX.LIST file, I got a security exception. This is probably due to other files that I have no idea why they were in the META-INF folder: an RSA file and an "SF" file (extensions). There's also a LICENSE file with no extension. If I remove all these extra files in the META-INF folder, then everything works!

But, with the default build of the JAR file from Intellij, it can't find or load the main class!

I don't seem to be able to tell Intellij how to control this when creating a JAR artifact.

Maybe I should be doing an ant build instead? I don't recall if Ant will unpack JAR files into directories. Seems like a lot of work for what should be simple.

Would appreciate any comments.


-- mike

P.S. I certainly don't miss problems like this when I'm doing Python.
1 month ago

Carey Brown wrote:Yes, it may be in the root directory, but did you use "package" when you wrote the class? Something like

Sorry Carey that I wasn't totally complete in my posting.

Nope, there is no package statement at the top of the class.

Baffling, right?

- mike
1 month ago

Carey Brown wrote:Is CopyFromAToB in a package?

No, it's just in the root directory of the JAR file which seems to match the manifest.

Is a package an implicit requirement?

1 month ago

I have a simple executable Jar file.

My manifest says this:


The CopyFromAToB.class file is in the root directory of the JAR file.


Yet, when I try this:

I get this:

Could not find or load main class CopyFromAToB


What could possibly be wrong with this simple setup?

The code runs fine standalone -- that is, as the existing Java code inside the IDE.

Thanks in advance,

- mike

1 month ago

S Fox wrote:forgot to say, facebook also has an api.

I am very happy to say I've never used Facebook and never plan to.

- mike

S Fox wrote:I think that google and amazon both have an api for ai, but your program would have to connect to their server at runtime in order to use it. I didn't look into it beyond that because I have seen how in the past they allow free access to an api then shut it off to everyone until you pay a subscription fee, such as googles translate api. Also there's the question of them having access to your data... stealing your research is part of why it's "free". If there are any good self contained apis for AI in any language I would love to look into it.

Don't like those subscription models at all.

Pretty soon, I'll have to rent the fonts for every forum message like this one.

Appreciate your reply.

- mike

S Fox wrote:I think that google and amazon both have an api for ai, but your program would have to connect to their server at runtime in order to use it. I didn't look into it beyond that because I have seen how in the past they allow free access to an api then shut it off to everyone until you pay a subscription fee, such as googles translate api. Also there's the question of them having access to your data... stealing your research is part of why it's "free". If there are any good self contained apis for AI in any language I would love to look into it.

Very good info, thanks!

We had looked at WEKA but found it mostly unapproachable. To really use it, you need to dive in and learn the vast API. For simple things it might be OK, but I'm now finding that Python with Pandas and other libraries is much better and support is widely available (as opposed to the odd email-only list WEKA has). Python also excels with statistics.

Having been a Java dev for more than 15 years, I was dumbfounded that Java lacked these libraries.

The challenge I have learning ML is that all the Python books seem to use this (IMHO) weird Jupiter Notebook format. That format is OK for explaining something, but it's often difficult (I have given up more than once) to try to see where they populated X_train and y_train or to follow along typing in code. Other training courses like Coursera use the same notebook format making their courses also very difficult to follow along with (where are all the source code 'py' files for us IDE types?).

Although I realize I'm not really "late to the party" with ML, I do feel like a fish out of water.

Python itself is nice, but there are strange (to me) things like the zip command to combine tuples, and Python's ideas about "encapsulation" (not any, really).

Other concepts like Lambdas seem much simpler in Python than Java. No need to learn all the Consumer and other interfaces and how to apply them just to use a Lambda.

Sorry for the rambling. I really appreciate your posting.

- mike
As a long-time Java developer (and dreading having to learn yet another language), my client is convinced that Python has the better, more complete, libraries for machine learning.

Browsing Amazon, he seems to be correct as the Python machine learning books vastly outnumber the Java books. And, the Java books (mostly by Packt) don't let you really see what's in them (on the Amazon site) making it difficult to judge them.

My goal is to stick with Java, if possible, but I need a good Java ML Library that can do things like:

Support Vector Machines
Discriminant Analysis
Logistic Regression
and related.

To date, I cannot find a hands-on book, with a corresponding (approachable) library (or book) for Java that shows you step by step how to load data, train data, predict, etc..

There is a Java library called WEKA, but it's extremely complex and it doesn't handle things like box's M test so I'd have to code that externally somehow.

So, just wondering if anyone here is into ML and if you've found a good Java (or Python) library and would be willing to share your thoughts?

Is Python the better way to go due to existing libraries?

Thanks in advance,

- mike
2 months ago
Wow, those errors looks nasty.

I had lots of little problems initially getting things to work.

Hang in there...post back...

- mike
2 months ago

Piet Souris wrote:Hmmm, bad luck here.

First of all: I do not have the package '...REngine.Rserve'. Don't know how come.

I had a look at RForge and I saw Rserve in the jar-file 'RserveEngine.jar' that contained the Rserve package. I downloaded it and added it to my library.
So far so good.

But if I run this code:

I keep getting the error:
Exception in thread "main" org.rosuda.REngine.Rserve.RserveException: Cannot connect: Connection refused: connect
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:88)
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:60)
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:44)
at rjava.Piet.<init>(Piet.java:26)  // that's line 17 in the code above
at rjava.Piet.main(Piet.java:22)

I have R running with the package Rserve.
I have googled for the error, but so far no clear causes.

But my use is not setting variables in R from Java, but for instance to get samples from distributions back in Java, and that part works beautifully.


It sounds like you don't have the "Rserve" library installed in R?

Could that be the problem?

- mike
2 months ago