java

Is there an open-source solution to XA-transactional file access in Java?

Hi, Is it possible to make XA-transactional access to the file system in Java? I want to manipulate files within the boundaries of a transaction and my transaction must participate in a distributed transaction via JTA (so I guess the file system needs to be accesses as a XAResource). I don't need support for fine-grained read/write fil...

How to protect a velocity template from tampering?

We have a Velocity template for a receipt. The template includes the Tax Identification Number, the value of which will be substituted at the time of receipt generation. This is to ensure the TIN of the real license holder is printed on the receipt. How can we prevent the end user from hardcoding the TIN number in the template itself? I...

Type safety: Unchecked cast between Class-Objects

I am quite comfortable with generics and such, but in this special case I have a question concerning the "Type safety: Unchecked cast from .. to .." warning. Basically I have a List of Class objects and now I want to get a subset of these that implement a special interface but the resulting List should also have that special Type: ... ...

Which languages have support for return value caching without boilerplate code?

For methods where ... there exists a static one-to-one mapping between the input and the output, and the cost of creating the output object is relatively high, and the method is called repeatedly with the same input ... there is a need for caching result values. In my code the following result value caching pattern is repeated a lot...

How to set a parameter in a HttpServletRequest?

I am using a javax.servlet.http.HttpServletRequest to implement a web application. I have no problem to get the parameter of a request using the getParameter method. However I don't know how to set a parameter in my request. ...

How to display Excel content from Struts portlet on Websphere Portal

Here is the code, it don't display the .csv file: public class ForwardAction extends MultiAction { private static final String FILE_ERROR = "<h3><center>INVALID FILE</center></h3>"; public ActionForward doVizualizare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exceptio...

What happened internally (JVM) when System.gc() or finalize() method called?

What happened internally (JVM) when System.gc() or finalize() method called? Is this really collect garbage or reduce performance ? ...

Help needed in java stored procedure with OUT parameter for MYSQL

I want to create a java program for connection with mysql database I want to use stored procedure with 1 out parameter and 1 in parameter How to retrieve result using java Is there any working example? Thanks, Deepak ...

Proper way to check Java Reflection Calls?

I posted a question last night about Java Reflection and am discovering compiler warnings this morning. C:\javasandbox\reflection>javac ReflectionTest.java Note: ReflectionTest.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. C:\javasandbox\reflection>javac -Xlint:unchecked ReflectionTest.jav...

How to immediately enable the authority after update user authority in spring security?

Hi, I'm using spring-security framework.When I update the permissions,It does not take effect immediately.I have to quit the current user(means logout), and then re-visit(means login) will be to update the user's permission. Is a way that immediately enable the authority after update user authority in spring security? ...

Enable Logging Log4j for certain users

Hi, In the log4j.properties file I've set the Level to ERROR. For certain users I need to set Level to DEBUG. I was able to change the Logging Level at run time; but this will be enabled for all the users accessing the application at the same time. Is there any other method by which we can enable logging for selected users? Any help will...

Unit testing DDL statements that need to be in a transaction

I am working on an application that uses Oracle's built in authentication mechanisms to manage user accounts and passwords. The application also uses row level security. Basically every user that registers through the application gets an Oracle username and password instead of the typical entry in a "USERS" table. The users also receive ...

Is defining a "ProbableBugException" code smell, paranoia or good practice?

In my Java code, I occasionally run into situations where I have to catch a checked exception from a library function that I'm pretty sure can't occur in my use case. Also, when coding, I sometimes notice that I'm relying on certain inputs from other modules (my own) to have or not have particular features. For example, I might expect a...

Blocking Queue - Need more information..

This question is related with one of my earlier questions.. Previous Post In there the blocking nature is mentioned as an advantage. I tried to develop some simple code to demonstrate the blocking nature but I got stuck. I just tried to make a BlockingQueue of size 4 and tried to add 5 elements and ended up with a java.lang.IllegalSta...

How does one manage object pooling in Spring?

It's my understanding that in Spring, all objects are treated by default as singletons. If singleton is set to false, then a new object will be served at each request. But what if I wanted to pool objects? Say set a range from a min of 1 to a max of 10 instances? Is this possible using Spring? ...

Critically efficient server

Hi, I am developing a client-server based application for financial alerts, where the client can set a value as the alert for a chosen financial instrument , and when this value will be reached the monitoring server will somehow alert the client (email, sms ... not important) .The server will monitor updates that come from a data genera...

Should an abstract class have a serialVersionUID

In java, if a class implements Serializable but is abstract, should it have a serialVersionUID long declared, or do the subclasses only require that? In this case it is indeed the intention that all the sub classes deal with serialization as the purpose of the type is to be used in RMI calls. ...

Handling overflowing components in swing

In my app I have some longish labels, on a chinese os the labels overflow and push out other components also. This has only been observed on a chinese os. How can I detect and handle overflowing components? ...

Why struts2 FilterDispatcher deprecated?

In API document I found this Since Struts 2.1.3, use StrutsPrepareAndExecuteFilter instead or StrutsPrepareFilter and StrutsExecuteFilter if needing using the ActionContextCleanUp filter in addition to this one. Why ? As I know that StrutsPrepareAndExecuteFilter have some problem in I18n. ...

illegal XML characters /Axis

Hello, I've developped a web service and deployed it with Axis. All is running very well but I've a problem when I consume the service using a String containing a non printable character (such as ETX, FS,..). I have the following error: exception: java.lang.IllegalArgumentException: The char '0x1c' after '....' is not a valid XML char...