java

Observer Pattern Overload

I'm stuck with the following scenario. It has a code smell, that I'm not happy with, but resolutions to it seems to be as complex, but just in different ways. I have a scene graph representing business objects. I've designed it so that the business objects themselves are as simple as could be. They're practically POJOs. Now, 1 entity m...

Custom resource in @Resource annotations added at runtime

Hello, I want to be able to do something like this in a stateless Session Bean @Resource(name="mycustomthingie") private CustomClass stuff; The value injected is context (speak: Thread) dependant. I guess this would be possible if I bind an ObjectFactory into the JNDI Context that delivers the correct Object when requested. As I und...

advantage of creating a temporary buffer when iterating over and modifying a collection in java

I am iterating over, and modifying a map (which is created from an existing group of enum objects) like the following: public class Dispenser { private Map<Ingredient, Integer> availableIngredients = new EnumMap<Ingredient, Integer>(Ingredient.class); public void orderSandwich(SandwichType sandwichType) { Map<Ingre...

java stackoverflow error

Hey guys, I'm working on a program for a university course that uses a method called get_line() to recursively calculate a list of successive locations to get from one point on a grid to another. When I run it, I get a stack overflow at the line of the last return statement in the method. I was wondering if I could someone else to look o...

Not authorized to write to this feed

I am calling service.insert(new URL(getContentFeedUrl()), newAttachment); for Google sites file upload using MediaStreamSource in servlet and get following exception com.google.gdata.util.ServiceForbiddenException: OK Not authorized to write to this feed at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDat...

Client catching Web Service User Exceptions [Java 6.0.17]

I am trying to send an EXCEPTION from a Web Server to a Client using JAX-WS ... When the exception is thrown by the server the client does catch it ... but the contents are not the expected message... Server.java package pck; @WebService() public class Server { @WebMethod() public function() throws UserException { thro...

J2EE how to start? Am I doing it right?

Ok so lately I've been reading a bit bout J2EE and I'm really hyped up because of it and I'm even thinking about doing it professionally (I'm in my 4th year of university, out of 5, so I need to decide what I want to do I guess). So I was wondering what's the best way to get round to learning it? I'm getting a Head First JSP/Servlets bo...

Problem getting Java Streams in HP Tandem (Non-Stop)

Hi. We are porting a simple Java application between Tandem NonStop systems, from G-Series to H-Series. Java version is 1.5.0_02. When performing basic I/O tasks like getting output stream from or opening a client socket, we receive exceptions like java.io.IOException: Value out of range or java.net.SocketException: Value out of ra...

JBoss Web Services Behind IIS Through HTTPs

This is a tangled web that's woven, I suppose, but it really shouldn't be all that hard. Let me see if I can paint the picture: I have written a web service, starting with a WSDL, which is to run in JBoss. This is all fine and dandy when I run it on my local machine and point my Netbeans "client generator" (probably just using "wsimpo...

Can java transform and validate the input at the same time?

I know how to call a java Transform and have it validate the output against a schema. What I want to do is: Validate the input and Transform it via xsl. I could: Create a Validator Validate and have it output a DOMResponse Pass the DOM to a Transformer. What I really want to do is have this done in one step and not have to create ...

Which java web framework to choose for client side and server side validation?

We are currently searching for a java framework , that made validation easily on server side and both client side,Spring,Hibernate,Play are the framework choices that we are searching,we are using annotation based development and this framework will determine our javascript choice too.Which is better framework (architecturally) at valida...

Anonymous class question

Hi, I've a little doubt over this line: An anonymous class cannot define a constructor then, why we can also define an Anonymous class with the following syntax: new class-name ( [ argument-list ] ) { class-body } ...

How do I insert todays date in Seam?

I'm new to Seam and I've been searching the internet and the Seam in Action book for this, but I'm looking for way to insert today's date in a seam page (myReport.xhtml or myPdfReport.xhtml) ...

How to use implementation loaded with different Java classloader?

I am writing a library where I allow people to provide implementations of certain interfaces using a plugin framework (it's JPF if you're familiar). The plugins are not stored in the classpath. The framework gives me a ClassLoader for each plugin, so when implementation named "MyImpl" of interface "MyInterface" is requested, I can find...

Fastest way to pick a random element from a list that fulfills certain condition

I need to pick a random element from a list, that fulfills certain condition. The approach I've been using works, but I'm sure is not every efficient. What would be the most efficient way to do it? The following code is inside a while (true) loop, so obviously is not very efficient to shuffle the list on every iteration. Foo randomPick...

beginner question about exception in java

when an exception occurs that a method is unable to handle - does the program terminate and show the error number ? where does the error number and information about the error come from ? should the programmer while coding have an idea what kind of exception might occur. if so why does'nt he ensure that exception does not occur . ...

java.util.concurrent vs. Boost Threads library

Hi, How does the Boost Thread libraries compare against the java.util.concurrent libraries? Performance is critical and so I would prefer to stay with C++ (although Java is a lot faster these days). Given that I have to code in C++, what libraries exist to make threading easy and less error prone. I have heard recently that as of JDK...

Downloading JAR files at runtime in Java

I am wondering if it is possible to have a Java desktop application, on startup, look to some URL, to see if it needs an update, and if so download necessary JAR files, and add them to classpath for the running program. If the old jars are there, they shouldn't have been loaded into the classloader yet, at this point should they? Is ...

printing image in java server side. open source

I need to be able to print barcodes from a web service. The numbers are stored on the server and need to convert them into an image and then print a barcode strait onto the printer without sending a print command from the browser. How can i do this. Is there a open source software out there ...

Calling a Java program from Microsoft Access

I have two programs I need to integrate. One is a Microsoft Access program. The other is a Java program. No flexibility on choice of platform for either one here, these are existing complex programs. The Access program needs at some point to spit out one line of text which the Java program knows how to convert into a code (another line...