java

Problem with synchronized collections of Java when doing equals() in the reverse order from multiple threads

Example scenario: Create two SynchronizedSets (s1 and s2) Pass them to two threads (T1 and T2) Start the threads T1's run() : while (forever) s1.equals(s2) T2's run() : while (forever) s2.equals(s1) What happens? - SynchronizedSet's equals acquires lock on itself It computes the length of the param that's passed in an...

What is xmlns in my xml file?

First of all please don't close this question as duplicate of http://stackoverflow.com/questions/1181888/what-does-xmlns-in-xml-mean, Actually, i am having an entry in my servlet.xml, xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr Now what i think is, dwr is the prefix we are going to use, like <dwr:configuration> ...

How to declare and consume events in Java

I have a simple class - will call it Animal. I'd like to fire off an event in the Animal class and have it handled in the class where I instantiated the Animal class. In the event handler, I want to pass an Integer value How do I pull off something simple like that? ...

iText encoding problem

I have encoding problem with iText (http://www.lowagie.com/iText/). I load data from database and insert it as html to pdf with iText, for some reason my non-english (Finnish ä,ö etc) characters don't show up correctly. Following example shows how insert text to html: text = "<p>" + data + "</p>"; HTMLWorker htmlWorker = new HTMLWorke...

Extract first valid line of string from byte array

Hi all, I am writing a utility in Java that reads a stream which may contain both text and binary data. I want to avoid having I/O wait. To do that I create a thread to keep reading the data (and wait for it) putting it into a buffer, so the clients can check avialability and terminate the waiting whenever they want (by closing the inpu...

Sqlite Closable excpetion Android

Hi , I am getting SQLite closable exception I am calling deactivate and close on cursor still i am getting the same exception . can any one tell me what i am doing wrong? ...

compute child table values in formula field of hiberntate

I am facing a problem in hibernate property formula field. Not able to combine both table columns. shift_id column belongs to parent table of job_card and duration column belongs to child table of job_card_idle_time. but it consider both columns are belongs to parent table of job_card. <property name="utilization" f...

Accessing a Queue from standalone code

I have a Queue configured in the Rational Application Developer for WebSphere, using a "V5 default messaging provider" and a Websphere6.1 I now try to access it using a standalone app (JUnit Test), in order to put some messages in it. I currently use the following code: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTE...

Cannot run/debug Java applications in Eclipse (JavaTimeZone issue)

I'm trying to get started with Eclipse/Java/Scala on a MacBook. The installed JDK was 1.5. The SDT plugin for Scala requires 1.6 which was included in an OS update, but I also manually installed a package from Apple to update 1.6. The problem is that I cannot run anything from Eclipse. I always get the following error: An internal erro...

Sending estimate HTTP Content-Length from Servlet etc

I often need to generate content dynamically from a servlet / restlet or whatever, and don't know the length ahead of time. If the client is a browser, the progress bar doesn't work properly, because I haven't set the Content-Length header. Is there any way of setting an estimated content length, so the progress bar works "more or less"?...

Java Classloader - how to reference different versions of a jar

Hi All, This is a common problem. I'm using 2 libraries A.jar and B.jar and these depend on different versions of the same jar. Let's say that at runtime I need THIS.x.x.x.jar MY.jar -> A.jar -> THIS.1.0.0.jar -> B.jar -> C.jar -> THIS.5.0.0.jar I can compile the specific jar (A.jar/B.jar) against its dependency but at r...

A "Portlet-Like" java technolgy for a Web app

Hi, Do you know a technology which can provide me a portlet-like interface? But I do not want to use JSR 168/268 portlet specifications and a portlet container. The reason is: My web app is a product which can be installed on the client's server (it can be weblogic/websphere/tomcat). Packing the portlets container along with my applica...

How to control the memory usage of processes spawned by a JVM

I am coding an application that creates JVMs and needs to control the memory usage of the processes spawned by the JVM. ...

Creating your own Validators in JSF 1.2 with Facelets 1.1.12

I was reviewing the following link and found out that javax.faces.webapp.ValidatorTag is deprecated and replaced by ValidatorELTag, however I can't seem to find any good information about this. I want to create a Regular Expression Validator which takes input: regex and error message. Meaning I would want to have a control like this: ...

How to interpret the these time stamps?

I'm trying to parse the time stamps written in some xml files. Most to the time time stamps are something like 2009-07-22-07:00 but some times I find them something like 2009-07-22Z or 2009-07-22z. Kindly help me how to interpret these Zs and how to parse them. I thing these z or Z is related to the time zone. Any workarounds to parse th...

Is the Lucene 2.9 TokenStream API faster than the old one?

I have been looking at upgrading from 2.4 to 2.9 and noticed all the contrived code that handles attributes. Just wondering if anyone has any opinions if this will change given its a .9 and things will change when 3.0 is out. I am confused how creating attributes by reflection and stashing attributes in a map can be as performant as jus...

java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for

Why may this happen? The thing is that monitor object is not null for sure, but still we get this exception quite often: java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for (tIdx=60) at java.lang.Object.wait(Object.java:474) at ... The code that provokes this is a simple pool solution: publi...

Is there any difference between class imports and package imports in Java?

This is probably a dumb question but thought to ask it. In java we can either import single classes as well as the whole set of classes (a package). As an example import java.util.* includes import java.util.ArrayList; import java.util.Date; import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; import ...

How to call WSDL2JAVA from ant with whitespaces in my path

HI guys! I try to call Axis2 WSDL2JAVA in my ant file to create a WSDL client. But it's broken because I have whitespaces in my path (I'm on Windows...). This is my ant <property name="wsdl.file" location="C:\path with whitespaces\project\subdir\my.wsdl"/> ... <target name="generate.client" depends="Clean.Client"> <java classname=...

Encapsulate menuItem with taglib, jsp, JS?

How could I encapsulate the authentication logic, the URL and the label of a Menu item when I make use of e.g. a Dojo MenuItem widget? What I currently have is this: <auth:isRole role="admin"> <div dojoType="widget.Menu.MenuItem"> <a href="<html:rewrite page="... complicated url ..."/>"> <bean:message key="label.goes.here"...