Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Chris Creed

Ranch Hand
+ Follow
since Feb 27, 2009
Chris likes ...
IntelliJ IDE Spring BSD
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
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Creed

As someone that's looking for a book that explores features of Spring that would be considered intermediate/advanced skill wise, would your book be a good fit?
1 year ago
As someone that uses Batch for a fair amount of my spring usage, would there be a planned addendum for Batch topics, or failing that, any good resources that would compliment your book?
1 year ago
My current project has roughly seven years of csv files that were generated daily, and I've found out that as the years past, the column structure has changed. Every reader that I've done in the past has hard coded column names, so I'm wondering if there's a way to read the column names of the current file being written, and map it to a corresponding object for use later on for processing.
2 years ago

Ankit Garg wrote:As a quick check, can you put a println statement in the retrieveInterstepDataFromJobContext to make sure it is being called...

I made the following modification in the abstract class mentioned in the OP.

No output was seen in the console.
3 years ago
Been trying to get this to work for a few days, and after banging my head on it for a while, was wondering if anyone else more experienced with Spring could give a hand?

In a nutshell, what Im trying to do is to take a value that's obtained in a tasklet, and make it available in an abstract class. This abstract class is extended by child classes that would need this value to perform some operations in the steps that we perform. It should then reset once the current job is done and if not complete, move on to the next.

In the tasklet's execute method, I have the following line that assigned data to the StepContext.

then in the abstract class, I have the following

Now I've followed a few texts in trying to get this to work, such as this example at, although I'm not certain that I implemented it successfully (my project only uses java annotation). I've also verified that the value is being populated into the JobContext, it's just a matter of getting it out that seems to be the issue, as all attempts result in null.

For completeness, this is what I have in the InterstepDataRetriever interface mentioned above

For job listeners, the application is using a class that's extending JobExecutionListener (it does nothing right now other then extend JobListener, since using JobListener directly gave an error). For step, it's using a method that has the following code.

I've verified that this code is being seen and executed.

I've hopefully outlined successfully what is going on, what I've trying to do, and what I'm failing at. If not, please ask for clairafication. This is the second time I've performed this operation and I'm sure I've missed somthing important.
3 years ago

Junilu Lacar wrote:Since your description of the problem is vague, you're going to get a vague suggestion to fix it.

I would work on isolating the tests more and doing more localized setup. Also, what you've written may not actually be unit tests. See the criteria that Michael Feathers sets for unit tests.

Well that's the problem with working and needing advice. If you provide detailed answers, you wont' need them because you'll be fired within the week for letting out propitiatory secrets or whatever, hence vagueness.

Ya from a brief overview of the google search you provided it's looking not to be as there's multiple classes that are required in order to fully test properly. Of course that brings up the next question of what kind of testing do I need, or can I test this at all?
5 years ago
I currently have an intresting situation occuring with my code, and after hacking away at what turned out to be a dead end for the last two weeks, I'm here asking those smarter then I to educate me on where I went wrong, and how I can perform my intended task correctly.

The setup:

We have a set of classes that perform various tasks but do so on one object that they pass around. Actions are performed to this object in each class before finally being pocessed and then sent back to the display layer for front end processing. This is a brief description of how the process works.

A collection of users is submitted via front end form
The collection of users is processed into an object with various parameteres set within.
Multiple classes with various methods that process the object that was just created are executed one at a time. In each class, the object has various methods that perform tasks on certain actions, such as formulas, validation, etc...
the object is then sent to the front end for display of the processeed object.

The task:

I'm attempting to build JUnit tests to help automate testing for this group of classes. This is how i have it configured

testConfiguration - instead of a form submission, I create a collection of users in various configurations based upon what we need to do for testing

testMain - This is the "root" class. It takes a configuration from the testConfiguration class needed for the current test run, creates it into an object with various parameters based upon the users passed, and then passed into the various classes for furthur processing

testClassesProcess - various classes that take the processed object from testMain, perform variouos actions on it (mainly mathmatical type methods) and then retun.

The issues:

Ran into a few really. The first is that you can't pass parameteres to functions in JUnit tests, as it'll come up with initializeErrors. Also the @Autowired annootation in the classes being tested error out with nullpointerexception, turns out that if enter the classes being tested from the JUnit suite, they can't seem to resolve the variable that would be used with no issue when executed via the application normally.

WE currently use java 1.7 with hibernate, spring, and junit to help give a visual of our stack.

So I'm wondering if after describing my situation if I'm trying to make junit put a round peg in square hole, if I'm just using junit wrong, or if there's a better solution that I could use to test this setup.

EDIT: My apologies if this seems vague. It's a workplace issue so I try not to give away anything propriatory, and to make it so others could relate.
5 years ago
SO having some issues with trying to debug a program that I'm using, and wondered if anyone could help me out.

The current environment is I'm running Cassandra (v2), using cqlsh (v3) that comes with it. I'm making changes to some of it's functionality, and then using cqlsh to test commands to see if my changes are working as intended, or if not what the input looks like as I step through the program.
I start up a debugging session (either in eclipse of IntelJ, doesn't really matter), firing up the server code to accept connections/input.
I then load up cqlsh, and specify the keyspace that I want to use. This seems to work fine.
I then execute a line of cql to test my changes via command line. What I expect to see is the command line entry being caught by the debugger in my IDE, where I can see how the input is handled by my code changes. What I'm seeing is nothing happening at all, as if no command was submitted.

So my questions would be the following:

1) SHould I see anything in my debugging IDE when executing commands as described above?
2) If not, how would you debug a server based application that has this configuration, especially in the realm of handling user input?
3) If so, what settings should I check to see if I have set correctly, or what processes should be followed to view and debug said submissions?

I figure there has to be a better way then having 50,000 System.out.println() all over the place (assuming they'd even work), or at least, I hope there is.

Thanks for anyone that reads this. Any questions (which I'm sure there may be since I'm probably not using the right descriptors) please ask away.
6 years ago
I posted this here as it's not really a specific subsection of Java, but utilizes a few different techs, and it's IMO a bit more advanced for the beginner section.

I've created a java application, utilizing JavaFX, FXML, DigestUtils for the app itself, and using launch4j to convert it to an executable format. Now on my system it works as intended, a splash screen that I specified appears, then the app loads.

However, we tried this on a machine that doesnt' have admin rights set on it, and when the application is executed, the splash screen appears....and then thats it. When processes are viewed, the application process is closed after the splash screen disappears.

Is there anything that could prevent the application from opening that would require admin level privileges? To my knowledge nothing in my codebase needs anything admin level like network or file I/O access, and no errors appeared to assist in debugging (that I know of). The operating system that this application would be utilized for is Windows Xp and Windows 7.
6 years ago
I'm currently working on a desktop app using javafx. IN the introductory screen, I have a form where the user would fill in various information, and then submit the form contents to a new screen, discarding the old screen as the user would not be heading back there in the application logic flow. However I'm at a loss as to how this would be done. I was thinking it would be like Android where I could call a get new screen function, calling the class for the new screen's constructor and it'd pass over to there, but when trying that, it just created a new window, which obviously isn't what I'm after. Was wondering if anyone knew of a better way that I could move the application to a new screen, and still easily pass the form information over to that screen for further processing.
6 years ago
I'm working on a way to parse JSON files and collect their contents for use elsewhere. I currently have a working example that is as follows:

I'm using the json.simple library.

Here's a sample string from the parsed file.

What my question is about is how to take this code, and have the put method be able to assign to the corresponding Map dynamically. This is what I currently have:

The ??? part is where I'm stumped. Getting the values of the current JSON line is easy enough. But how to get the property eludes me. Is there a method that I can call on this object that I'm not familiar with? A different and better way to itenerate through this? Or am I doing this completely assbackwards right from the get go?

Stephan van Hulst wrote:Never had much problems with it myself. I have some experience with Jackson and GSON. Can you show what you have tried so far, and what problems you're experiencing?

Well Finally got some time to give some more kicks at the can and after some more wall bashing, finally got something to work, albeit very simple. JSON simple out of everything ended up working to at least take a string of parse it as JSON. Here's what I have so far.

Basically sample.txt is a file filled with random data I created. Everyline has a random string such as {"foo":"bar"} (the example I had I was still treating JSON like a PHP array...old habits die hard I guess).

Running into some odds issues like it looping if I have multiple JSON enteries on one line (eg {"fooA":"barA","fooB":"barB","fooC":"barC","fooD":"barD"}) and it puking on evey new line character, but I'm chalking it more to my ignorance of java then the parser itself.
7 years ago
After digging around on le internet, trying out various libraries (Jackson, GSON, json-lib, json-simple), tutorials, and stackoverflow, along with coderanch, I'm at a loss as to how this can be done, and why it's so difficult (to me at least).

What am I trying to do?

I'm attempting to parse a string formatted as JSON. Nothing crazy complex, jsut this:

Now my thinking would be to take that string, parse it through a JSON library that you'd add to your project, and loop through the returned object (or array, either or) and display its' contents. Seemed simple. But I can't get any of the code or tutorials i've found to work at all. Unknown types, constructors that dont' take arguments even though every tutorial says they do, deprecated methods, and classes that in sample code are supposed to exist with libraries but don't.

So I'm the heck do you do something that in other languages is basically throw a string into a method and handle the results? It can't be as hard as I'm experiencing....right?
7 years ago

Jeff Verdegan wrote:

Chris Creed wrote:

Jeff Verdegan wrote:What do you mean "none that are native"?

Perhaps I'm using the wrong term. What I mean is that I can't type in say JSONParser parser = new JSONParser(); into Eclipse an it'll say "hey you're missing Want me to add that for you?", but instead it seems that a 3rd party choice is needed to be added.

Ah, okay. What you mean then is that it's not in the core API.

I guess what I'm after is out of the plethora of options out there, which ones would be considered industry standard?

I don't believe one has emerged as the de facto standard yet. Your best be it probably to do a Google search and see what people are saying about the various options, pick 2 or 3 candidates, and see how they work for you.

Seems there's about five that I found tutorials and postings for on stackoverflow, and they all seem to be broken in various amounts. Incredible that a language like PHP can parse JSON easier then Java can, really needs to have something standardized. maybe in v8
7 years ago

Jeff Verdegan wrote:What do you mean "none that are native"?

Perhaps I'm using the wrong term. What I mean is that I can't type in say JSONParser parser = new JSONParser(); into Eclipse an it'll say "hey you're missing Want me to add that for you?", but instead it seems that a 3rd party choice is needed to be added. I guess what I'm after is out of the plethora of options out there, which ones would be considered industry standard?
7 years ago