java

Implementing a virtual list in Java

I need to fetch many records from an RDBMS in Java (10-20k) my target system expects them to be available as Java List. So I want to implement my code as "Virtual list" where I actually only fetch the records I actually need. I expect SQL like SELECT * FROM CUSTOMER WHERE COUNTRY="Moldovia" as parameter and just return what is requeste...

Problem, when compiling .jrxml to.jasper files

I have a well working program, which uses JasperReports. It uses JRBeanCollectionDataSource(List items); to populate the rows with data, but if I compile the .jrxml file either with JasperCompileManager.compileToFile() or with iReports I see only parameters populated without rows. Does anyone have had such a problem. I don't recieive any...

What memory types does Tomcat use and how can it be controlled

Hi, I know there are several memory types that Tomcat uses when running. The only I have ever used - java heap. It can be controlled through JAVA_OPTS env property with something like '-Xmx128M -Xms64M' I have found that there is also -XX:MaxPermSize, -XX:MaxNewSize and etc. The reason I'm asking is that I'm trying to launch Tomcat5....

Retrying container managed transactions from an EJB on JBoss AS

Hi, I am attempting to retry a container managed transaction from an EJB, in JBoss. I have tried creating a retry handler and I am currently getting the below error. 11:35:02,765 INFO [EARDeployer] Init J2EE application: file:/E:/Jboss/jboss-4.2.2.GA/server/default/deploy/RetryTest.ear 11:35:02,984 WARN [ServiceController] Problem cr...

hibernate sql query

hi, i have a strange problem with a hibernate sql query: The db relations are like follows: registration has one invoicerecipient registration has many attendees i have the persid of an invoicerecipient, so I should get in both following cases the associated registration, but only the second case works. Does anybody know why the firs...

How to detect dataloss with Java sockets?

I have the following situation: using a "classical" Java server (using ServerSocket) I would like to detect (as rapidly as possible) when the connection with the client failed unexpectedly (ie. non-gracefully / without a FIN packet). The way I'm simulating this is as follows: I'm running the server on a Linux box I connect with telnet...

Can we run Java applictions on iPhone?

Hi All, Can we run or develop apps for iPhone in Java? Actually I am a bit confused... Please bear with me,have a look to these links and answer:- LINK 1 LINK 2 LINK 3 This is an Open discussion. All ideas are appreciated. Thank You All. ...

Java: date & time relative to current (server) time

We're using MySQL to store some dates. I'm looking to show these as relative time periods in the user interface: 2 hours ago, 3 days ago etc. (Like Twitter does for the updates for example) Is there a well-known way to accomplish this, or should I get creative with it? Just to be clear, I want to transform: 07/26/2009 12:20 -> '2 days ...

Custom java serialization of message

Hi, While writing a message on wire, I want to write down the number of bytes in the data followed by the data. Message format: {num of bytes in data}{data} I can do this by writing the data to a temporary byteArrayOutput stream and then obtaining the byte array size from it, writing the size followed by the byte array. This approac...

How to create a BMP file from raw byte[] in Java

I have a C++ application which communicates with a camera and fetches raw image-data. I then have a Byte[] in C++, which i want to send to Java with JNI. However, i need to convert the raw Byte[] to an real file format(.bmp was my first choice). I can easily do this if i write it from C++ to an file on the hard-drive, using BITMAPFILEI...

Java Metric Unit Conversion Library?

I have an application that will need to perform a number of unit conversions (metric to Imperial, Imperial to metric). Is there an existing Java library that does this? Or will I need to roll my own? (My initial Google searches proved moderately useless.) ...

Can jconsole data be retrieved from the command line?

I currently use jconsole to monitor performance metrics of my Java application and would like to script this data acquisition. Is there a way to retrieve these VM metrics (heap memory usage, thread count, cpu usage, etc) to STDOUT? The data in "top -p PID -b -n 1" doesn't quite cut it. Thanks ...

Idempotency Barrier for messaging

A recent presentation I saw regarding RabbitMQ mentioned the use of something called an "idempotency barrier" for message de-duplication. Is this just a fancy name for a message conflator or is it something more specific. If so, what exactly is it? A google search yielded results which are mostly related to RabbitMQ, with little explanat...

JAR file folder for eclipse projects

I'm trying to create a centralized folder (in some kind of a "meta project" in my eclipse workspace) for commonly used JAR files for referenced projects in this workspace. It should work similar to the WEB-INF/lib folder for web projects but also apply to non web projects, and automatically scan and add all jar files in this folder. I t...

Singleton in Cluster environment

What is the best strategy to refactor a Singleton object to a cluster environment? We use Singleton to cache some custom information from Database. Its mostly read-only but gets refreshed when some particular event occurs. Now our application needs to be deployed in a Clustered environment. By definition, each JVM will have its own Si...

Which Java Web-Framework is better suited to be used together with Scala?

Hi! I have a personal project - a web mashup which uses multiple REST-Apis and Webservices, which I would like to program using scala, mostly because I would like to use it as a pet project for learning this language. However, it is possible that the project grows and that other java programmers contribute to it. Furthermore, I would li...

Is it safe to extend classes generated from an XML schema?

Suppose I have this (outrageously) simplified XML schema: <xsd:complexType name="Person"> <xsd:sequence> <xsd:element ref="FirstName"/> <xsd:element ref="FamilyName"/> </xsd:sequence> </xsd:complexType> If I generate a Java class from it I get something like this: public class Person { protected FirstName firstName; p...

tomcat background threads

Hi, I have a tomcat 6.20 instance running, and would like to send an email via a background thread to prevent the email sending function from blocking the request. Is there any way I can execute the thread in the background, while still allowing normal page flow to occur. The application is written in ICEfaces. Thanks. ...

How can I block HTTP session timeouts in my Seam applications?

We have a rather restrictive architecture where we have a portal-like Seam application which launches further 'child' Seam applications inside an iFrame. We have a problem where the portal application's HTTP session times out even though the 'child' applications are still being used. We need to keep the HTTP session timeouts to keep th...

Spring HTTP invoker returns a null proxy, need debugging help

Hey all I've followed the spring http proxying tutorial as closely as possibly, but I still can't get it to work at runtime (my configuration is largely identical, so unless I've missed a typo there is no need to post it). The Client starts up fine, as does the server (and I've verified that the object on the server is instantiated), ...