java

xml namespace to java, how to model 'choice' ?

What is the best way to represent in java a "choice" namespace tag? ie. <xs:complexType name="MyType"> <xs:sequence> <!-- common elements here --> <xs:element type="xs:string" name="name" ... /> </xs:sequence> <xs:choice> <xs:element name="stringValue" type="xs:string"></xs:element> <xs:element name="intValue" type...

Detect changing value of object passed as parameter

I'm now working with code that looks like this public String getName(User user) { user.setSth(...); return user.getName(); } I think it's bad practice to change objects passed as parameters. Is there a tool that detects that kind of code? I looked at findbugs, pmd and checkstyle, but could not find any check for this. P.S....

JBoss target deploy

Hi, is there a way to point a maven target (with classess) path to jBoss instead of building .ear and deploying it everytime I edit some sources? Thanks in advance, Etam. ...

Java split() method strips empty strings at the end?

Check out the below program. public class test { /** * @param args */ public static void main(String[] args) { try { String data = null; // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new FileReader(new File("D:/sample.txt"))); while((data=br.readLine())!= null){ ...

JBoss WebServices and .NET mobile client

Hi. I have Web Service deployed to JBoss 4.2.2.GA environment and need to consume its methods from .NET application on WindowsCE 5.X. The problem is that I'm not able to consume service's methods when security is turned on (@SecurityDomain("java:/jaas/JBossWS") on class and @RolesAllowed(value={"friend"}) on method declaration. I tried ...

Calling System.exit() in Servlet's destroy() method

This is a follow up to my earlier question. Tomcat 5.0.28 had a bug where the Servlet's destroy() method was not being invoked by the container on a shutdown. This is fixed in Tomcat 5.0.30, but if the Servlet's destroy() method had a System.exit(), it would result in the Tomcat windows service throwing the Error 1053 and refusing to sh...

Floating Point errors in Colt Java matrix libraries

How do I avoid floating point errors in financial calculations performed with Colt matrix libraries? ...

Adding JTextField to a JPanel and showing them

I'm building a little app using Java and Swing in NetBeans. Using NetBeans design window, I created a JFrame with a JPanel inside. Now I want to dynamically add some jTextFields to the JPanel. I wrote something like that: Vector textFieldsVector = new Vector(); JTextField tf; int i = 0; while (i < 3) { tf = new JTextField(); te...

Mock Struts FormFile

I have an action class that expects a FormFile from a DynaActionForm. Typically in JMock, I'll just add request params to the struts mock, which will in turn populate the DynaActionForm. Obviously, the set request param is for strings only. So I'm unsure how to get or set the mock to use a multi-part request such that I can add the Fo...

UTF-8 text is garbled when form is posted as multipart/form-data

I'm uploading a file to the server. The file upload HTML form has 2 fields: File name - A HTML text box where the user can give a name in any language. File upload - A HTMl 'file' where user can specify a file from disk to upload. When the form is submitted, the file contents are received properly. However, when the file name (point ...

ACEGI Authentication available in tomcat 404 error handler.

I'm using spring and acegi in a webapp that's deployed in tomcat 5.5.26. I want to see if the user is logged in on the 404 page, so that we can show their name if they're logged in, and a login link otherwise. I have the HttpSessionContextIntegrationFilter, in the filters on the REQUEST dispatcher. I also have it in the ERROR dispatche...

Java logging configuration only partially taken into account

I've an issue with a project I try to deliver using the one-jar packager to simplify the deployment process. Without the packaging, everything works fine and the logging configuration is perfectly loaded, but within the packaging, only part of the configuration is appied. So, here is the logging.properties I use: handlers= java.util.lo...

java swing : custom everything - subclass jcomponent or jpanel or ... ?

Hiya - quick one - is there any harm / value in subclassing JComponent as compared to JPanel ? To me they pretty much look to be the same thing if I'm doing my own drawing & the object won't have any children, however there seems to be a pref for subclassing JPanel over JComponent - just looking for opinions on why this might be ... T...

What database development tool would you recommend to Eclipse Java developer?

I am an experienced Java developer, used to all the nice features that Eclipse provides for Java development (in particular Ctrl+T to open type, Ctrl+Click or F3 to open referenced declaration, outline, ...). I really like this degree of comfort. Now I have a project, where I need to do some changes in the existing database (stored proc...

Java Adding Image to BLOB datafield

For this university assignment that I have been assigned. I have to develop an application for use on a PDA which is running J2ME and Apache Derby in embedded mode. I would like to both import/export an image to the database. How would I do this? Also would storing the image as a blob be suitable? Thanks in advanced. ...

What are your experiences with development frameworks and tools for building web applications?

I've been building web sites off an on for about 10 years. 2 years ago I started using ASP.Net. I'm working on 2 projects right now, one using ASP.Net MVC and the other using Java / JSF / Spring / Hibernate. I've also used other frameworks (cgi/perl, php, ASP, jsp, jsf). What do you think is the most productive programming environment...

What is a valid content-type value for a .DM file type ( cellular phone DRM )

Obeying NDA restrictions I have to be vague. I've been tasked to evaluate the feasibility of forcing a .dm file from my client's system to a cellular device. So far I know I can send a smil payload with a txt & gif|jpg payload but not a .dm file. Inside of the DRM wrapper there is a header prefix before the payload starts. Content...

How to get shutdown hook to execute on a process launched from Eclipse

Hi all. I have a shutdown hook in my application (created using Runtime.getRuntime().addShutdownHook). However if I launch the application from within Eclipse, when it is shut-down the shutdown hook doesn't execute. I think this is because Eclipse sends the equivalent of a force-kill signal to the process, which doesn't cause the shut...

Firefox "ssl_error_no_cypher_overlap" error

My co-workers and I are having a problem using Firefox 3.0.6 to access a Java 1.6.0___11 web application we're developing. Everything works fine anywhere from 1-30 minutes into the session...but eventually, the connection fails and the following error appears: Secure Connection Failed An error occurred during a connection to 10.x.x.x...

Java library inspector?

I am currently working on a mantenance project that is written in Java. We are currently working to clean up the code some and try to provide a little more organization to the project overall. The list of libraries that are included in the build have grown long, and honestly no one remains that knows/remembers what each library is used ...