java

How to shut down all Executors when quitting an application?

According to Brian Goetz's Java Concurrency in Practice JVM can't exit until all the (nondaemon) threads have terminated, so failing to shut down an Executor could prevent the JVM from exiting. I.e. System.exit(0) doesn't necessarily work as expected if there are Executors around. It would seem necessary to put some kind of public voi...

What's the need of <security-role> element in DD

Hi, I don't understand what's the need to declare element of , or even itself in DD, because the Container can still create a mapping between role in tomcat-user.xml file and role declares in DD in auth-constraint element of a security-constraint for authenticating any client. I'm using Tomcat 5.5. Thanks in advance ...

How to rename a file in ftp server using java

Hi , I wanted know How to rename a file in ftp server using java. I am using java.net.URL to connect to the server Thanks ...

how to make a composite primary key (java persistence annotation)

how to make it so that the table user_roles defines the two columns (userID, roleID) as a composite primary key. should be easy, just can't remember/find. in userdao @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "user_roles") public List<RoleDAO> getRoles() { return roles; } @Id @GeneratedValue(strategy = ...

Checkstyle Error in Eclipse - Could not instantiate Tab character

Got this error today while trying to build a project with checkstyle. This works for other people in my office but I would rather not reinstall Eclipse yet again. Any idea what this error actually means? Errors occurred during the build. Errors running builder 'Checkstyle Builder' on project 'myproject'. cannot initialize module Tree...

Ordered List Map implementation in Java

I was wandering if there is a class out there that implements both Map and List interfaces in Java. I have a data structure that is primarily a Map. I map strings (IDs) to Images. But in a specific part of my code i need to present the user with all the available IDed Images. The only way to do that so far is to write this : for (Stri...

Concurrent and Blocking Queue in Java

Hello Everybody, I have the classic problem of a thread pushing events to the incoming queue of a second thread. Only this time, I am very interested about performance. What I want to achieve is: I want concurrent access to the queue, the producer pushing, the receiver poping. When the queue is empty, I wand the consumer to block to t...

Problem Shutting Down JBoss Instance

I currently have two separate instances of JBoss installed on a Linux server - v4.2.2 and v4.0.4. When I start v4.2.2, I use the command "sudo ./run.sh -b 0.0.0.0" so that it will listen on all ports. However, I only bind v4.0.4 to localhost when I start it up because I am only going to be using it for API calls. Both start fine, but ...

Struts for IBM Application Server Toolkit

I'm looking to build a Struts 1.2.x application for Websphere, using IBM's Application Server Toolkit. Are there any plugins available for this toolkit (it is a version of Eclipse) that are known to help with this type of development? I am new to Struts so I will also be learning about the technology as I go along, but I want to make it ...

In class without a property called "type" I get org.hibernate.PropertyNotFoundException: Could not find a setter for property type in class

Using JPA, and Hibernate as the provideer, I have a class defined like: @Entity @Table(name="partyrole") public class PartyRole extends BaseDateRangeModel { private static final long serialVersionUID = 1L; private Party roleFor; public void setRoleFor(Party roleFor) { this.roleFor = roleFor; } @ManyToOne public Party g...

Servlets: where to store uploaded files?

In the PHP world it's common to create a directory called 'uploads' or something similar in the application folder. All uploaded files are then stored there, the database containing the relative paths to those files. In the Java/servlet world however, I'm not sure what the common way to handle uploaded files is. Getting the path to a d...

Convert Byte Array to image in Java - without knowing the type

Sounds simple right? Use ImageIO.read(new ByteArrayInputStream(bytes)); Here's the wrinkle. For some reason it is detecting a jpeg as a bmp, and that is the first ImageReader returned when I call ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(bytes)); Iterator<ImageReader> readers=ImageIO.getImageRea...

Setting a Source per Item using Rome

I am using Rome to combine several feeds into one. It's largely based on this example on the Rome site. I'm creating a RSS 2.0 feed, which I save as a (W3C) Document then pass to a stylesheet to convert to HTML. One of my requirements is to display the source (link to and name of originating site) for each entry (as they can come from ...

Multithreading in JFrames

I want to display an image as welll as some text on my JFrame in a way that both get displayed simultaneously part by part. I have implemented it but not able to perform it the right way.Is there anyone who could help me in solving this problem such that after certain portion of image some text shoulg get displayed and then image then te...

Is Tomcat middleware?

So I have a client that needs to be running tomcat for various things (Solr and a webservice as well) and after having a meeting with him and another programmer on the project, I got a little confused. The other programmer was throwing around buzzwords and saying things like "We need to have middleware for tomcat." In response to this, m...

JNA - Access Violation, JVM terminats

Hi I am calling a DLL with passing a callback functio object to it. One of the functions is simple print. I have then, a loop of 100 iterations, just printing the index and a few prints after the loop. Here is the C code extern "C" int Start(void* callback(CString)) { for(int j=0; j<100; j++) callback(AConvertToString(j)); ...

Detect OS Sleep and Wake Up events in Java

Is there a way for a Java program to detect when the operating system is about to go to sleep, or failing that, at least detecting a wake up? The actual problem is that in a particular application a number of MySQL database operations are run in the background. In testing on a Windows machine these database transactions are interrupted ...

Receiving an array of Object from a web form using Spring framework

Hi, I have a form JSP web page, this form contains multiple instances of the same Java object, I am using Java Spring Framework to control the "communication" with the controller and the view. My problem is that i would like to be able to receive from the view a simple array containing the instances of my objects wich are currently on...

Axis loading modules - Creating tempfile and failing

We are using axis for webservice communication between different system in house. Every once in a while the axis calls fail with a: [org.apache.axis2.deployment.util.Utils] - Created temporary file : C:\WINDOWS\TEMP\_axis2\axis248890addressing-1.41.mar [org.apache.axis2.util.Loader] - java.lang.ClassNotFoundException: Class Not found : ...

example/tutorial for using TreeModel+AbstractTreeModel?

I have a database containing a hierarchy that I want to display within a JTree. Is there a good example/tutorial for TreeModel and/or AbstractTreeModel that explains how to implement a custom treemodel? I'm going through a lot of head-scratching and can't seem to find some code out there which is a good starting point. edit: I did find...