java

deploy struts app on jboss

I'm working through some struts tutorials, and here's one of the ones I'm using: http://www.vaannila.com/struts/struts-example/struts-login-page-example-1.html I downloaded the "source + lib" link at the bottom of that page, I copied the Example2 folder from the zip to my webapps folder under tomcat, and everything works as advertised. ...

PDF file generation from XML or HTML

Are there any API/solution to generate PDF report from XML file data and definition. For example the XML definition/data could be: <pdf> <paragraph font="Arial">Title of report</paragraph> </pdf> converting HTML to PDF will also a good solution I feel. Currently we write Java code using iText API. I want to externalize the code s...

How to prevent concurrency in web service API?

We have three web services (/a, /b, /c) where each service maps to a method (go()) in a separate Java class (ClassA, ClassB, ClassC). Only one service should run at the same time (ie: /b cannot run while /a is running). However as this is a REST API there is nothing to prevent clients from requesting the services run concurrently. W...

Is there a Java XML API that can parse a document without resolving character entities?

I have program that needs to parse XML that contains character entities. The program itself doesn't need to have them resolved, and the list of them is large and will change, so I want to avoid explicit support for these entities if I can. Here's a simple example: <?xml version="1.0" encoding="UTF-8"?> <xml>Hello there &something;</xm...

Java Exceptions, What to catch and what not to?

I keep getting the dreaded java.something.someException errors while running my java app. and I don't seem to be getting the hang of what exceptions to handle and what not to? When I read the api docs most of the functions throw exceptions like if I use I/O or use an Array... etc. How to make a decision about what exceptions to catch an...

struts2 application on jboss

This is a bit of a continuation of http://stackoverflow.com/questions/1777339/deploy-struts-app-on-jboss, but it's different enough that I felt it warranted a new question. In the other question, I was working with struts, but now I'm working with struts 2. The tutorials here are broken up into struts tutorials and struts2 tutorials. ...

Need to create PDF from bytearray (Java)

From a DB2 table I've got blob which I'm converting to a byte array so I can work with it. I need to take the byte array and create a PDF out of it. This is what I have: static void byteArrayToFile(byte[] bArray) { try { // Create file FileWriter fstream = new FileWriter("out.pdf"); Buffe...

Page redirect / refresh using ExtJS

Hi all, My Web application makes use of Ext JS & Java web technology. Due to the size and complexity of the application, I need to do a complete refresh of the page (load a different page) when user select some menu from the menu bar. What is the best what to redirect to the required page? For example, In my main menu, I have two...

Problem in TCP Program (Java)

Can anyone help me debug this program? The following is server code : package networking; import java.io.IOException; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Scanner; class TcpServer { public static void main(String[] args) throws IOException { ServerSocket server...

Takes the variable data from it's own class instead of it's child classes even when called from the child class

Okay, it's been a while, but I'm thinking about getting back into programming. Anyway, This code takes the variable data from it's own class instead of it's child classes even when called from the child class. How do i get it so it uses the child's variable data instead of it's own when called by the child? public class TestRPG1 { ...

JBoss MQ tutorial

I'm looking for a JBoss MQ tutorial (on JBoss Tools) so that I can write an MDB and a client. I can find only JBoss Messaging. ...

Lazy/Eager loading strategies in remoting cases (JPA)

I'm running into LazyLoading exceptions like the most people who try remoting with an ORM. In most cases switching to eager fetching solves the problem (Lazy Loading / Non atomic queries / Thread safety / n+1 problem ...). But eager fetching has also disadvantages if you are dealing with a really big object graph. Loading the whole ob...

Using Mockito's generic "any()" method

I have an interface with a method that expects an array of Foo: public interface IBar { void DoStuff(Foo[] arr); } I am mocking this interface using Mockito, and I'd like to assert that DoStuff() is called, but I don't want to validate what argument are passed - "don't care". How do I write the following code using any(), the gener...

What is the Class Of List<Foo> in Java?

Class c = List<Foo>.class doesn't seem to work. ...

How to use generic class (or interface) in another generic class (or interface) with the same data type parameters without casting

I need the Cache class that keep the <TKey key, TValue value> pairs. And it is desirable that TKey can be any class that supports Serializable interface and TValue can be any class that supports Serializable and my own ICacheable interfaces. There is another CacheItem class that keeps <TKey key, TValue value> pair. I want the Cache cla...

Is it possible to have more than 32 locks in ConcurrentHashMap

I read ConcurrentHashMap works better in multi threading than Hashtable due to having locks at bucket level rather than map wide lock. It is at max 32 locks possible per map. Want to know why 32 and why not more than 32 locks. ...

Sorting problem cannot instantiate abstract object overriding compareTo() Method.

I'm trying to establish a new sort criteria, in this case by name. I'm facing an error when I call the sort method... this is a separated class (SortByName) in package "package": -----------------------CLASS SortByName--------------------------- package package; import java.util.*; public abstract class SortByName implements Compara...

Spring vs EJB. Can Spring replace EJB?

Since Spring is able to use transactions just like EJB. For me, Spring is able to replace the requirement of using EJB. Can anyone tell me what are the extra advantages of using EJB? ...

Compiled OK but NoClassDefFoundError when running

Hello I'm trying to send an email using JavaMail API. I have jdk 1.5 installed in my home directory from self-extracting binary. I'm on Ubintu 9.10 I compile the program using the next command: ~/jdk1.5.0_22/bin/javac -classpath ~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar hw.java It co...

GWT 2.0 RC1 & GXT 2.0.1

Hi, I'm wondering if already someone tried to use this combination ( GWT 2.0 RC1 with GXT 2.0.1 or any other version) and if so, then how it actually works ? any pitfalls ? Thanks ...