java

Removing the Apache TomCat runtime from a project in Eclipse?

I've got a project I've been building on Eclipse Ganymede targetted at tomcat 6.0, I've imported it into Europa and I need it to run on apache Tomcat 5.5 I can't find the reference to where the runtime is set to 6.0 to remove it. I've tried going to Windows > preferences > Server and I've installed the 5.5 runtime. I can't however seem...

Image not deleted even after file.delete() method!!!

Hi All : I have to send mail along with embedded image. Once the mail has been sent, image in the application server should be deleted immediately. Problem i am facing is, after mail sent the control goes method which contain File file = new File("../bar.jpeg") if(file.exists()){ file.delete(); System.out.println(...

Help with file upload in Java/J2EE

I need to upload a file using Apache fileupload with ProgressListener but alongwith that I also need to show the progressbar for the upload status. Actual requirement is I just need to parse a local XML file parse the xml into appropriate objects and put them in Database. Do I really need to upload the file to server to get it parsed. A...

Is javax.xml.soap better then apache cxf?

This week I had to look into a Java WebService project which was using SOAP packages javax.xml.soap.*. I have not used this before but the Apache CXF library to create a SOAP webservice. I have a question on javax.xml.soap.* Is it better then CXF in terms of performance? In terms of coding I see CXF is amazing as no need to worry a...

redirecting from own java server to tomcat

Hey everyone, I know my "problem" or the way I want this to work might not be a common approach, but I hope someone can point me in the right direction. I am still messing with a self written java server (let's call it "myserver"). But I kinda just want it to validate whether a user is allowed to access the servlet he is requesting. I am...

Encoding problems in Linux & MySQL

I have developed my Java/EE program in Windows machine and everything worked perfectly in Windows, but when I installed my WAR to Jboss in Linux machine I have encoding issues with MySQL when I import csv-files. Csv files are encoded as ISO-8859-1 and file I import is encoded as ISO-8859-1. MySQL doesn't seem to get Strings encoded as UT...

Javah error while using it in JNI?

javah -jni JavaHowTo error: cannot access JavaHowTo class file for JavaHowTo not found javadoc: error - Class JavaHowTo not found. Error: No classes were specified on the command line. Try -help. Hi guys, i have set the class path correctly. But still i am getting this javah error. Any solution for this will be much helpful. ...

Does a framework like Factory Girl exist for Java?

Factory Girl is a handy framework in rails for easily creating instances of models for testing. From the Factory Girl home page: factory_girl allows you to quickly define prototypes for each of your models and ask for instances with properties that are important to the test at hand. An example (also from the home page): Factory....

Replicating String.split with StringTokenizer

Encouraged by this, and the fact I have billions of string to parse, I tried to modify my code to accept StringTokenizer instead of String[] The only thing left between me and getting that delicious x2 performance boost is the fact that when you're doing "dog,,cat".split(",") //output: ["dog","","cat"] StringTokenizer("dog,,cat") // ...

How to regulate the amount of printouts generated by a logging instruction produces over time?

How can I limit a program log printouts to a maximum of X printouts within Y seconds? Programming server side with java.util.logging, my code has a lot of info, warning, and error statements like: s_logger.logp(Level.WARNING, myClassName, myMethodName, "msg.code.in.properties.file"); On the one hand, I do want to see the warning messa...

Dynamicly generate a JNLP file for a Java Web Start application?

I'm writing a servlet to return a JNLP file with several dynamically generated parameters to be passed to a web start program. Right now my code uses a stock template and token replacement, but I have to think there is a way to generate this file programmaticly within a servlet. Are there any tools available for this? ...

mysql java cant execute stored procedure

I am connecting to a mysql(5.08) db running on a linux machine from a web application running in tomcat. I get the following exception..when I try to execute a stored procedure.. com.hp.hpl.chaos.web.exception.DBException: getNextValue for operatorinstance[Additional Information from SQL Exception][SQLErrorCode: 0 SQLState: S1000 a...

In Java, is using throws Exception instead of throwing mulitple specific exceptions good practice?

While looking through the Spring MVC framework I noticed that, unless I misunderstand, its developers favor throws Exception instead of throwing multiple exceptions. I realize that at the core of this question is the checked versus unchecked exceptions debate, avoiding that religious war, is it a good practice to use throws generic exce...

Reference issue with tomcat?

I'm experiencing and issue with tomcat where if I try to deploy my code I get the following error: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375) org.apache.jasper.servlet.JspServlet.serv...

Process huge volume of data using Java

As part of the requirement we need to process nearly 3 million records and associate them with a bucket. This association is decided on a set of rules (comprising of 5-15 attributes, with single or range of values and precedence) which derive the bucket for a record. Sequential processing of such a big number is clearly out of scope. Can...

How to change image permission mode to 777 using java code?

Hi All : I want to give permissions mode value "777" to image file using java code. How can i give that using java?. Because i cant delete the image with default permission mode "664". Please help me ...

How do I use custom roles/authorities in Spring Security?

While migrating a legacy application to spring security I got the following exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxy': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_fil...

Best way to use contains in an ArrayList in Java?

Hello I have an ArrayList in Java which is made up of a type containing two strings and an integer. I can successfully test if one element of this ArrayList equals another but I find that the contains method fails. I believe this is due to the fact that my type is not primitive. Now I see two alternatives to this and I wonder which is ...

Experience with JDK 1.6.x G1 ("Garbage First")

I'd like to know what are the experiences with G1 garbage collector in newest JDK? I see NullPointerException thrown in my program, although code didn't change and behave correctly in earlier JDKs. ...

Max amount of memory per java process in windows?

This is a pretty simple question: What is the maximum heap size that you can allocate on 32-bit Windows for a Java process using -Xmx? I'm asking because I want to use the ETOPO1 data in OpenMap and the raw binary float file is about 910Mb. ...