Ra Carter

Ranch Hand
+ Follow
since Jul 30, 2005
Merit badge: grant badges
For More
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 Ra Carter

I'm using the latest versions of Jersey and Guice but I'm see runtime errors when trying to return a collection or map. I thought Jackson could do that automatically?

Here's the exact error:

A message body writer for Java class java.util.ArrayList, and Java type java.util.Collection<java.lang.String>, and MIME media type application/json was not found.
The registered message body writers compatible with the MIME media type are:
application/json ->
*/* ->

To start, here is my guice module

My rest resource is very simple:

My Gradle build config file looks like this (I assume gradle is not relevant here but the deps defined may be?)

I'm actually running this through gradle, so my command looks something like gradle jettyRun and I should also note that I'm using java 1.8. I was assuming those things wouldn't matter here, but I'm sort of at a loss for explanations since I thought these frameworks would support json collections out of the box. Is that not the case?
10 years ago
Hi thank you very much for your help. Honestly I created the executor functions just to mess around with lamdas, but why wouldn't the executor shut down if there are no more open threads running in it?

edit: I totally agree things would be simpler with that stuff removed, but I was kind of doing things the hard way just to learn.
10 years ago
I'm really sorry if this is not the right way to ask this question, but I was horsing around with lamda functions and what not in java 1.8 and I found out that my simple program doesn't terminate. It prints all the expected results right to the last line of main, but I have to hit ctrl+c for the program to properly terminate. I don't see where I have any open threads still running. Here's the code: Output

Sequential manipulation completed in 511 milliseconds.
Parallel manipulation completed in 455 milliseconds.

10 years ago
I am trying to use Jetty with ant using these instructions: http://docs.codehaus.org/display/JETTY/Ant+Jetty+Plugin.

Jetty starts up ok but I still to make a few more adjustments:

* Increase JVM memory (set the -Xms, -Xmx, and -XX:MaxPermSize)
* Enable remote debugging

My ant task is defined as such:

target/myapp has everything it needs including the WEB-INF/lib and WEB-INF/classes folders.

So how can I increase memory and enable remote debugging with this set up?
12 years ago
Just to close the loop on my own thread; the problem was indeed how I configured the additional memory. Apparently --JvmMs, --JvmMx, and --JvmSs parameters to the tomcat7.exe windows service install program were not enough. I had to also specify the --JavaOptions parameters such that I could set the -Xmx and -Xms parameters explicitly.

For example:

(FYI: I am now using multiple tomcat instances in one single tomcat installation as opposed to several separate installations.)

I'm not exactly sure what the other tomcat7 Jvm parameters are used for. I'm still trying to figure that one out.
12 years ago
I am trying to run multiple tomcat servers on Windows. I have downloaded and installed the tomcat7 zip (not using the installer) to three different folders, and updated the port information so they do not conflict. Everything seems to work fine if I run all three manually using the service.bat script that comes with tomcat.

When executing service.bat manually, I updated the java memory parameters by modifying service.bat as such:

However strange things happen when I run it as a Windows service. I installed the services with the following commands:

When running these servers I'll see that my web applications stop responding. I don't see any error messages, it's just very slow to respond, and usually doesn't respond at all. Very strange.

Are there any issues with using tomcat7 services like this? Am I doing something crazy with setting the Jvm params in the service install? Any suggestions for how to find the root cause?

Also, is there any chance that are any conflicts with %CATALINA_HOME%? If so, how can I resolve that?
13 years ago
So the problem was with JBoss 4.2.3, which includes incompatible versions of hibernate in jboss/server/default/lib. Removing them resolved the issue.
I actually posted this same question on the hibernate forums, but also posting here in case someone here can help.

So I am trying to upgrade to Hibernate 3.6.0 (from 3.5.2). I'm using JBoss 4.2, Spring 2.1, and the code contains a combination of hbm files and annotations and makes reference to ehcache as well. I can upgrade spring by the way, but I'd prefer not to just yet if I didn't have to.

Anyway, I seem to be unable to find the right combination of hibernate jars right now. The closest I came was with these:I may not need all of those but JBoss seems to start without error with that combination. However my unit tests fail on save operations with this stack trace:At this point I started trying varying combinations of jars. Namely I tried upgrading to hibernate-validator-4.0.1.Final, but no matter what, I always seem to run into this error when starting up JBoss now:I have no idea where org.hibernate.validator.ClassValidator is nor do I know who is requiring it.

Currently I am at a loss. Is this a jar dependency issue? If so, what jars do I need? If not, should I make any code changes? Any help would be greatly appreciated on this issue.
When throwing an exception in one of my Axis service methods I notice that there is a detail section in the soap response. This is Axis 1.1 btw and the code looks like this:

which produces output like this:

I don't mind the detail section and I believe it is used for custom object properties, but is there any way to remove the hostname node or control the exception output? In this case I don't want to reveal my server host name.
13 years ago
The maven standard directory layout guidelines specify a src/main/config folder. However I notice that files included in this folder do not seem to end up in my jar file unless I specifically specify a sourceDirectory setting inside the build node of pom.xml.

Doesn't this defeat the point if I have to manually specify this folder? Is there a reason src/main/config is not treated as a source folder by default in maven? Should I be putting stuff in that folder (i.e. log4j.xml) at all? If so, what is appropriate to put there and how is it different than src/main/resources?
13 years ago
Currently I am using several file appenders in my log4j configuration. They are all the same except they are used by different loggers and write to a different file name. Is there a way to specify the file name as a parameter to the appender so I don't have to keep copying and pasting the same appender information?

An example for what I am looking for might look something like this:

Is it possible to do something like this with log4j?

Ulf Dittmer wrote:That assumes a Servlet 3.0 container, which are not widely used yet.

Yes, I'm using the 2.5 Java EE API where HttpServletResponse.getHeaders is not yet implemented.

It looks like 3.0 is still a draft specification? I don't think I am ready to adopt it yet.

Is there any other less obvious way to read the response headers?
13 years ago
Is there any way to read HTTP response headers with Servlets? HttpServletResponse does not seem to have anything that serves this purpose.

Also I'm using a JBoss server, so if there is no way to do this with the Servlet spec, is there some JBoss specific way of reading this information before it gets served?
13 years ago
I want to log HTTP Headers using Apache Axis 1.1 (may upgrade Axis2 eventually).

I am able to fetch the HttpServletRequest from the handler and log the request HTTP headers using that, but I cannot figure out how to access the response HTTP headers since HttpServletResponse does not seem to provide access to that information. Is there a way to get at this information with Axis?

My technique for getting the request HTTP headers is like this by the way:

Is there way to do something similar with the response?

Also is there a way to have my handler run last in Axis 1.1?
13 years ago
I have an object that will start reading and writing a bunch of files from and to disk. I would like to be able to test this without actually having to write out data though.

In my initial implementation I was just passing around input and output directory strings and letting my object do what it needed to from there, but I realize this is hard to test. I was thinking to use InputStream and OutputStream parameters instead which would let me use byte streams in testing, I suppose, but I don't think I can write new files with OutputStreams.

Now I'm thinking to make a factory object that I will mock out later and return byte streams instead of file output streams in testing but this seems less than ideal. I'd really like to mock File and Stream objects but I'm not sure what the best approach for that is. I will need things like File.isDirectory, File.mkdir, and new FileOutputStream(new File(directory, newFileToCreate)). Sorry if I haven't done a good job of explaining my issue, but can anyone recommend some best practices for testing things that use File I/O in Java?
13 years ago