java

How to configure Log4J when deploying an OSGi app with the Equinox Servle Bridge to Tomcat?

When deploying my OSGi web application using the equinox servlet bridge i get the following: log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener). log4j:WARN Please initialize the log4j system properly. I tried several ways of supplying the necessary "log4j.prop...

Java heap space in netbeans.. but I've increased the heap size already!

I'm having an issue with netbeans and Java. My program needs to be able to cope with large files being uploaded via an arraylist. So I used -Xmx512m to increase the maximum heap size via the netbeans.conf file. I know that netbeans is catching the change, and I've restarted multiple times to make sure it is. Still, my program continues ...

Regular expression to allow a set of characters and disallow others

I want to restrict the users from entering the below special characters in a field: œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İťı —¿„”*@ Newline Carriage return A few more will be added to this list but I will have the complete restricted list eventually. But he can enter certain foreign characters like äöüÄÖÜÿï etc in addition to alphanumeric char...

ASP.NET/IIS equivalent of Java/WAS context-root

In Java on WebSphere Application Server if I want my servlets, etc., to start with a certain root path, I use the context-root property in the EAR deployment descriptor (application.xml). For example, my servlet is named GetData, but I want the URL to be www.mysite.com/secure/restricted/GetData, so I set the context-root to secure/restri...

HSQLDB Internals: Hibernate and Integer vs Long Ids

I am creating database Entities in my Java application and trying to rationalize between using an Integer or a Long as the class type of the "id" field. I am using Hibernate as my ORM which, in turn, will map this field to a column in the HSQLDB database. My struggle is this: a Long is obviously larger and will handle a greater number o...

How do I consume a web service protected with HTTP basic authentication using the CXF framework?

I tried to get it to work using the CXF User Guide, but I've had no luck. I'm trying to call the web service using java code. ...

How to install Web Platform Tools in Eclipse?

Which URL do I install this and any pre-reqs from, and how can I install them? Been struggling with this for the last 1 hour with no luck. ...

Attach UncaughtExceptionHandler to a TimerTask

Hi Is it possible to attach an UncaughtExceptionHandler to a TimerTask? (Other than by calling Thread.setDefaultUncaughtExceptionHandler()) Cheers Rich ...

Using threads and recursion in Java to calculate Fibonacci numbers

I'm relatively new in the Java world and I have a problem which I don't understand. I have a Class (to get the fibonacci row): class Fib { public static int f(int x){ if ( x < 2 ) return 1; else return f(x-1)+ f(x-2); } } The task now is to start f(x-1) and f(x-2) each in a separate Thread. One tim...

Replace JBoss error page with Axis2 fault XML response

I'm developing a webservice with Axis2 1.4.1 on JBoss 4.2.3/Tomcat 5.5.27 and Java 1.5.0 (15-b04). It works flawlessly but when an exception happens I get a JBoss error 500 HTML page instead of an Axis2 XML/SOAP fault. This behavoir is vexing, because it difficults to handle errors in the webservice client or in SoapUI while developing....

Is there an equivalent of BufferedReader.readLine() that lets me pick what my end of line characters are?

The Javadoc for BufferedReader.readLine() says: A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. I need slightly better control than this (e.g. I would like to be able to specify that an end of line is "\r\n", so that an "\n"...

Is QT Jambi dead?

I know they announced in February that it was going to transition to a community-developed model over the next year... but right now, I can't find it on their website, at all, let alone version 4.5 that was supposed to be released this month. I am about to embark on the GUI portion of a major project, and while I had considered using QT...

Eclipse keeps running my old web application

OMG - what is going on with Eclipse (3.3 Europa) - has anyone come accross this problem (bearing in mind I have been messing about with uninstalling different Tomat containers and installing others - but anyway thats another story) When I change a line of code or remove a class within my project - when I come to debug - it actually goes...

Java books for preparing for interviews

Hi all, Could you guys please recommend some good Java books which are good to read before you go to an interview. Ideally the book would cover a lot of core java, including tricky stuff. So books along the line of Java Puzzlers is what I am looking for. If you got any books to recommend for other areas like SQL, Design Patterns or any...

Java:Why http session is not destroyed when tab or browser is closed ?

Hello, I have the following implementation of HttpSessionlistener public class SessionListener implements HttpSessionAttributeListener, HttpSessionListener { public void attributeAdded(HttpSessionBindingEvent event) { ... } public void attributeRemoved(HttpSessionBindingEvent event) { ... } public void attributeReplaced(Ht...

Entitymanager causing memory leak?

I have a slow memory leak in my Java application. I was wondering if this could be caused by not always closing the Entitymanager when used. However using myeclipse to generate DB code, I'm getting methods like this: public Meit update(Meit entity) { logger.info("updating Meit instance"); try { Meit result = getEntityManager().merge...

Java: Determining Current Call Stack (For Diagnostic Purposes)

For diagnostic purposes I sometimes need to store the call stack that lead to a given state transition (such as granting a lock, committing a transaction, etc.) so that when something goes wrong later I can find out who originally triggered the state transition. Currently, the only way I am aware of to retrieve the call stack looks like...

How do you remove rows after changing the item in a JPA OneToOne relationship?

How do you get a OneToOne item to automatically remove with JPA/Hibernate? I would expect simply setting the OneToOne item to be null in the class that contains would be smart enough to allow Hibernate to delete it. Given a simple object, simplified: @Entity public class Container { private Item item; @OneToOne(cascade=Cascad...

Writing long test method names to describe tests vs using in code documentation

For writing unit tests, I know it's very popular to write test methods that look like public void Can_User_Authenticate_With_Bad_Password() { ... } While this makes it easy to see what the test is testing for, I think it looks ugly and it doesn't display well in auto-generated documentation (like sandcastle or javadoc). I'm interest...

How do I get dbunit to play nice with MySQL enum data types?

I'm trying to use dbunit to test some our database access code and I'm running into a problem. We are using MySQL 5 something or other as the database itself. I exported a small set of data to a FlatXmlDataSet and when I setup the test case, it throws an exception which says "Data truncated for column 'FHEIGHT_FLAG' at row 1". The colu...