java

Are java annotation lists supposed to allow an extra comma after the last entry?

I accidentally left an extra comma at the end of one of my annotation lists, but it compiled fine on my machine. For example: @NamedQueries({ @NamedQuery(name="name1",query="FROM Foo"), @NamedQuery(name="name2",query="FROM Bar"), }) Notice the extra comma after the second @NamedQuery. It seems to compile fine on my ...

Obtain Session List from Web Application Server

Some one at work found out about the: com.ibm.ws.webcontainer.httpsession.IBMTrackerDebug servlet. Which can be invoked like this: http://localhost:9080/servlet/com.ibm.ws.webcontainer.httpsession.IBMTrackerDebug Now, a "manager" wants me to make a similar servlet, that list the current active sessions in the a web aplication. I've tr...

Using XSLT to output multiple files

I'm trying to get an example that I found for using XSLT 2.0 to output multiple files working. Using Saxon B 9.7.0.1 with Java 1.6, I get this error: C:\Documents and Settings\Administrator\Desktop\saxon>java -jar saxon9.jar -s:input.xml -xsl:transform.xml Error on line 15 of transform.xml: java.net.URISyntaxException: Illegal charac...

Java Servlets: why is PrintWriter.flush() not flushing?

I am currently writing a Comet application which requires me to send chunks of data at a time on a persistent connection. However, I'm having trouble flushing the message to the client before closing the connection. Is there any reason the PrintWriter.flush() method is not behaving like I think it should? This is my Tomcat Comet imple...

Java AffineTransform moving origin

I would like to move the origin from top left to bottom middle of the component? I have been playing with AffineTransform class could not get it to work? ...

Automatically reformat long-lined Java code to 80 columns and still compile?

My apologies if this is a duplicate, I've seen a couple threads on the subject of 80-column code, but didn't see an answer to this specific problem: My team is developing Java code in a couple different IDEs, with differing numbers of columns. It's worked well so far, but we've been asked to deliver compilable code to a partner with th...

Apache Commons FileUpload problem on Glassfish server

I have simple web app that just has one Servlet that accepts data file and saves it to the server. I'm using "apache commons FileUpload" library. File uploading work fine on my local server (I'm using Glassfish for my Dev and Prod server). I can upload any size files. Here is my memory info: -XX:MaxPermSize=512m -Xmx1024m Here is the ...

Unit testing with multiple collaborators

Today I ran into a very difficult TDD problem. I need to interact with a server through HTTP POSTs. I found the the Apache Commons HttpClient, which does what I need. However, I end up with a bunch of collaborating objects from Apache Commons: public void postMessage(String url, String message) throws Exception { PostMethod post =...

java.lang.IllegalCastException for GWT

Hey everyone, I'm getting an IllegalCastException on the following (see bold line): public void renderXML(final String xml) { final Document xmlDoc = XMLParser.parse(xml); final com.google.gwt.xml.client.Element root = xmlDoc.getDocumentElement(); XMLParser.removeWhitespace(xmlDoc); final NodeList collection = root.getElementsByTa...

Interpreting Java reflection performance: Why is it surprisingly very fast?

I've seen other threads saying java reflection performance is 10-100x slower than when using non-reflection calls. My tests in 1.6 have shown that this is not the case but I found some other interesting things that I need someone to explain to me. I have objects that implement my interface. I did three things 1) using a reference to a...

Google DataStore not storing child objects

I have an entity Course that has a key to another entity (Document) inside. @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class Course{ @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private Key document; public Document getDocume...

nullify object that is part of ArrayList java

Hello, I have an array list: private ArrayList<PerfStatBean> statFilterResults; I want to iterate through it like: Iterator<PerfStatBean> statsIterator = statFilterResults.iterator(); while(statsIterator.hasNext()){ i++; PerfStatBean perfBean = statsIterator.next(); ......... I would like to delete the bean from statFilterR...

Can't deploy GoogleAppEngine project!

Can't deploy anymore from eclipse plugin with the following error: Unable to upload: java.net.SocketException: Software caused connection abort: recv failed ... Caused by: java.net.SocketException: Software caused connection abort: recv failed I have absolutely no clue what this is about - it always worked before. Nothing changed in t...

Detect when Android software keyboard is hidden

I need to detect when the android software keyboard is hidden. My activity currently responds to when the hardware keyboard is hidden but the software keyboard looks like it can only be implied through a size changed event. Does anyone know of a way that a view or activity can receive a notification when the software keyboard is hidden ...

A class implementing an interface that takes an enum

So, say I have a simple enum and a class that uses it: enum ThingType { POTATO, BICYCLE }; class Thing { public void setValueType(ThingType value) { ... } public ThingType getValueType() { ... } } But, in reality, I have lots of different classes that implement setValueType, each with a different kind of enum. I want to make ...

QA to dev ratio

We have a pretty complex Java system which includes a few back-end tiers including a database and a proprietary Swing front-end. There are back-end APIs to which external parties can attach that mimic our front-end. There are approximately 5 silos within our org that share this system. In total there are around 15 developers maintainin...

Why is this being garbage collected

My developers and I are having an issue with objects being garbage collected in our application when we don't want them to be. We are using Java with Weblogic 10g3. We are programming a singleton pattern to handle all of our JMS connections. There are two classes involved: public class JMSObject { ... private MessageProducer _produce...

What are the differences between the two common implementations of a queue?

In Java, one of the implementations of queue is "circular array" and the other one is "linked list". What are their differences? ...

Specifying relative resource path via Spring XmlWebApplicationContext

The actual question is: Is there a way to get XmlWebApplicationContext to load resources using paths relative to the context location? For clarity's sake, let's say "context location" is the location of the first file specified via setConfigLocation() method. Detailed explanation is below: I'm using Spring MVC in web tier and Spring...

Do you memorize the tags in your XML configuration?

Do you guys memorize the tags in your XML configurations particularly in Java? Do you guys memorize the tags in web.xml, in your Ant configuration files, in your Spring configuration files? Also do you code them by hand or do you have an IDE and a reference with you? I'm a noob wanting to know how the pros do it :) ...