java

Django admin style application for Java

I'm looking for a web framework or an application in Java that does what Django admin does - provides a friendly user interface for editing data in a relational database. I know it's possible to run Django on Jython and that way achieve a somewhat Java-based solution, but I'd prefer something pure-Java to keep the higher-ups happy. ...

Use GZIP, JSON responses and JQuery

However, I want to compress my responses with GZIP wheren possible. I tried using the Compression filter code available for free download in the headfirst site. It works great for html, images, css and javascript. I post the filter next. It checks if GZIP is an accepted encoding and it adds gzip as Content-Encoding. See: wrappedResp.se...

Message Driven Bean Selectors (JMS)

I have recently discovered message selectors @ActivationConfigProperty( propertyName="messageSelector", propertyValue="Fragile IS TRUE") My Question is: How can I make the selector dynamic at runtime? Lets say a consumer decided they wanted only messages with the property "Fragile IS FALSE" Could the consumer change the s...

Java StreamCorruptedException

I have a client and server application that transfer message using serialization over TCP. I got the following error when deserializing an object: Any ideas to the cause or possible next steps in analyzing this problem? java.io.StreamCorruptedException: invalid stream header: 383D4649 at java.io.ObjectInputStream.readStreamHeader(...

Eclipse Servlets take a long time to update

I'm testing running a simple Servlet from within Eclipse. When I click 'Run', the console says it is starting TomCat, and then an internal browser launches within Eclipse which shows my code. However, if I make any changes in the servlet and click 'Refresh' in the browser, the changes don't show. Then, a few seconds later if i hit refre...

Equivalent of LastCall.IgnoreArguments in EasyMock

I have used Rhino.Mocks extensively currently writing some tests in Java using EasyMocks. However I was unable to pull out a LastCall.IgnoreArguments() Rhino.Mocks equivalent in EasyMocks. How do I use Easy Mocks to return a value irrespective of the arguments in the method. For example: public interface ISoothSayer { String SayS...

Which approach is better to load a JDBC driver?

There are two ways to load a driver: Class.forName() DriverManager.registerDriver() Method 1 internally also calls DriverManager.registerDriver and method 1 is the preferred way. But why? Is there any small difference or is performance etc. better? Any views are appreciated.. ...

Lossless JPEG Rotate (90/180/270 degrees) in Java?

Is there a Java library for rotating JPEG files (90/180/270 degrees) without quality degraded? ...

Can Java's Desktop library launch a URL in a new Browser Tab or Window?

I have a static method used to launch a browser with a given URL. When the browser is already open, this takes over the active browser window. This is a problem if the browser is in use for something else, such as data entry. Is there a way to open a URL in a new Browser window (or tab)? public static void openURL(String urlText) { ...

[Java] Ensuring method is called

I have this class: public abstract class AbstractIncomingCall { /* class properties */ public void changeStatus(/*some parameters*/){ //store parameters in class properties isValid(); } protected abstract boolean isValid(); } ...which is extended by this class: public class IncomingCallImpl ...

How do I copy a two dimensional array of strings?

EDIT: ah, there it is! Problem solved, thank you! (Bug was elsewhere, not in the copy function.) I'm working with a program that uses two-dimensional arrays of Strings (probably not that smart to begin with, but eh), and I'd like to write a function that takes one of these arrays (let's say array1), makes an independent copy, and retur...

Finishing details on a JUnit 4 dynamic suite

Hi – I wanted to automatically sweep JUnit tests into suites as part of my continuous builds, so I derived a runner from JUnit's Suite which finds all test classes in a package. The runner works just fine, but the results display is less than expected. I have one class in my testing support package with a @RunWith annotation for my runn...

Can I from a client detect which EJBs the current user is authorized to use?

I have various EJBs on a J2EE-server, with different security roles. Now, from a Java Swing client application, when I log the user on to the server, I would like to discover which of these EJBs that are accessible to the user, without actually trying to create them or invoke them. The reason I want to do this is to adjust the user int...

Unhandled exception on trying to create JAXBContext (Jaxb 2.0)

Hi, I am trying to get the code past this line: JAXBContext jaxbContext = JAXBContext.newInstance("foo.bar.package"); It throws an exception - heres the stack trace - any ideas folks? SEVERE: Unhandled exception or error intercepted java.lang.NoClassDefFoundError: javax/activation/DataSource at com.sun.xml.bind.v2.model.impl.Runtime...

Class Cast Exception when trying to unmarshall xml?

Hi, Trying to get past a class cast exception here: FooClass fooClass = (FooClass ) unmarshaller.unmarshal(inputStream); throws this exception: java.lang.ClassCastException: javax.xml.bind.JAXBElement I don't understand this - as the class was generated by the xjc.bat tool - and the classes it generated I have not altered at all -...

Tool to remove unnecessary dependencies in a Java project

I have a Java project that currently has a lot of JARs in its libraries directory, which are all included in the resulting package when building. I know, however, that some of these libs are never referenced in the project. Is there a tool that can search for libs that are not referenced within the project? I guess there must be somethi...

XML for Web Service: inline attachment

I have to invoke a web service with a single parameter, a String in XML format. I'm building this via an XSLT transformation. So far so good. The problem is with this XSD fragment: <xs:complexType name="Document"> <xs:sequence> <xs:element name="title" type="xs:string" minOccurs="1"/> <xs:element name="content" typ...

Shape at "Actual Size"

What's the easy way to render a shape in Java to its "actual size". For example, I have a tube with a diameter of 1" and I want to depict it on screen as the outline of a 1" circle. The Graphics2D method drawOval(int x, int y, int width, int height) takes a height and width in pixels. What are the steps to translate a pixel size into th...

Using NIO DatagramChannel will I need to handle partially read/written packets?

When using SocketChannel, you need to retain read and write buffers to handle partial writes and reads. I have a nagging suspicion that it might not be needed when using a DatagramChannel, but info is scarce. What is the story? Should I call (non-blocking) receive(ByteBuffer) repeatedly until I get a null back to read all waiting dat...

Simple Spring, use of ClasspathApplicationContext for standalone apps, how to reuse?

If I have a standalone main application. Say 20 classes. They all may need to interface with the beans defined by the spring configuration (ApplicationContext) at any time. I would boostrap the classpath application context at the main application entry point. But how do you reuse the already instantiated beans? For example, it seem...