java

how to generically compare entire java beans?

Hi, I've been trying to grok the org.apache.commons.beanutils library for a method/idiom to evaluate for equality all properties between 2 instances i.e. a generic equals() method for beans. Is there a simple way to do this usnig this library? Or am I going about this the wrong way? Thanks. ...

How to give dynamic filepath in appender tag in log4j_config.xml?

Hi I am using log4j api to log the informations. I have used log4j_conffig.xml file for creating the log files. I have given the absolute path for each log file in param tag value. eg : appender name="GPREPROCESSOR_DEBUG" class="org.apache.log4j.DailyRollingFileAppender"> param name="DatePattern" value="'_'yyyyMMdd"/> param n...

Problem with JAAS and DatabaseServerLoginModule

hello: I have a problem with jaas and jboss. I try to authenticate users against a database using form based method but jboss tells me the password are wrong (no, the password is correct), but if i use UsersRolesLoginModule with properties files, no problem. In the pg database in debug mode the query that JBoss does seems ok, The passwo...

Use Bundle-NativeCode on Linux does not work

Hi, i creat a plugin wich includes the folder structure src native/so/libsystemcommand.so META-INF/MANIFEST.MF The manifest include the command Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Commands Plug-in Bundle-SymbolicName: de.system.commands;singleton:=true Bundle-Version: 1.0.0 Bundle-Activator: de.system.comm...

Place MySQL connector JAR in WEB-INF/lib of my WAR instead of in $CATALINA_HOME/common/lib?

I'm about to use MySQL with Hibernate on a Tomcat 5.5.x server. Do I have to put mysql-connector-java-[version]-bin.jar in $CATALINA_HOME/common/lib/ or could I place it in WEB-INF/lib inside my WAR file with my other library dependencies? It would be easier to have it in my WAR in WEB-INF/lib, as I could get it using the Maven reposit...

Java WebServices with Spring and OAS/OC4J

I'm having problems deploying a simple WebServices app (like "Hello World" simple) to OC4J. The same code works fine under Jetty, but breaks in OC4J, and I'm wondering if anyone else has faced the same issue. I'm using Enterprise Manager to deploy the app, but the deployment fails with this message: [Jan 23, 2009 8:46:20 AM] Binding...

Video training program

Hi, I am looking to create a video training program which records videos - via webcam, user screen capture and captures sound. Now the main problem is that I need a cross-platform (mac and windows) solutions. I know its possible to use flash to record webcam + audio. But its not possible to record the user's screen via flash. So am w...

Recurring "PermGen" in Tomcat 6

I keep getting a "PermGen" error on my Tomcat 6 server. I know what application is causing the problem, but I am not sure why it is doing so. The application is using MySQL 5 and running on JDK 6. Are there any tools/suggestions to diagnosis or analyze the underlying issue(s) with the specific application? Thanks ...

How can I change some existing Java XSLT code using Xalan to use Saxon and TinyTree

I have some existing Java code that does an XSLT transform programmatically - originally using Xalan. I have refactored it to be able to use another (externally configured) TransformerFactory. I have tried using the Saxon (v6.5.3 and v8.7) factory, but do not see any perfromance improvements - if anything Saxon is slower and uses more m...

Find a way in the java logging frameworks scene.

Hey to all Java has a lot of frameworks / APIs that help you do logging in your application: The Java API has java.util.logging package. Apache's Log4j. Apache's Commons Logging. SLF4J (logging Facade). jLo. and many many more... I've always used the log4j library, i found it sufficient most of the time, and extensible when i needed...

How to "hot" deploy war dependency in Jboss using Jboss Tools Eclipse plugin ?

Hello ! I'm using Jboss tools (3.0.0 alpha, on Eclipse 3.4) to hot deploy my war on Jboss 4.2.3. My war depends on another project (packed inside a jar) I 'm working on. But, when I save a file in this project(the jar project), Jboss Tools republish the compiled classes of the war project, but does not re deploy the classes changed in th...

Do you have any good examples of "architecture for architecture's sake"?

Just listening to this week's podcast and thought it would be nice to group together some of your experiences where you've seen the "architecture" side of design dominate things a little more than it should. Java often gets a bad press in this respect, and an increasingly bad press as the perceived complexity of JEE increases. My Java e...

In a multithreaded (Java or .Net) program, can I assume that copying a variable is atomic?

I was worrying about race conditions in an application I'm designing, when I was wondering about this question. Let's say I have a large array or collection of some sort that is managed by one component of my program, let's call that component Monitor. Its job is to regularly check if the collection is "dirty", i. e. has changed recentl...

Left padding integers with zeros in Java

How do you left pad an int with zeros in java when converting to a string? I'm basically looking to pad out integers up to 9999 with the leading zeros. E.g. 1 = "0001" I know this is probably simple and as a parallel task I'm googling it, but SO is super quick when it comes to inane questions I should know the answer to... ...

Locking a file while copying using Commons IO

I am using the Apache Commons IO: FileUtils.copyFileToDirectory(srcFile, destDir) How do I make Windows lock the destination file during copy? Windows locks the file correctly if I use: Runtime.getRuntime().exec( "cmd /c copy /Y \"" + srcFile.getCanonicalPath() + "\" \"" + destDir.getCanonicalPath() + "\"")...

Get name of currently executing test in JUnit 4

In JUnit 3, I could get the name of the currently running test like this: public class MyTest extends TestCase { public void testSomething() { System.out.println("Current test is " + getName()); ... } } which would print "Current test is testSomething". Is there any out-of-the-box or simple way to do this...

Java current machine name and logged in user?

Is is possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine. I assume it's just a property of some static environment class. I've found this for the user name com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSyst...

Correct way to use Actions to create menus, toolbars, and other components in Java

The naive way of writing building a menu in a Java Swing app is to do something like: JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open..."); openItem.addActionListener(new ActionListener() { /* action listener stuff */ } ) fileMenu.addMenuItem(openItem); A more experienced developer will recognize that acti...

JSTL and authenticated web services

Can I access an authenticated web service using JSTL? (Form-based authentication) If I can't do it using JSTL, is there any other way I do it from a JSP? Maybe I need to give a little more information. I'm using the core library: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> and the import tag, as in: <c:import ...

Effects of incorrect spring initialization

I'm working with an incorrectly built spring application. Rather than use IOC, objects that require references are pulling their references from the context: BeanFactory b = SingletonBeanFactoryLocator.getInstance(). useBeanFactory("factory").getFactory(); Bean foo = (FOO)beanFactory.getBean("foo"); Putting asid...