java

How to do LDAP authentication and database Authorization in Spring security?

I'm new to Spring, so this question may look like so obvious. I'm trying to implement Spring security and my requirement is to authenticate the user name/password against a LDAP server and once the user is authenticated, I need to retrieve the user roles from a relational database. is it possible to do this in Spring security? ...

Remove unnessesary spaces from Swings Components

i have 3 JPanel, the first is the base panel and the other two are added to the first. I have realised that there is a lot of space that is not used, shown by the black color and the white color around components. How do you remove this space? ...

How do I return the last primary key of the last added item in java?

Hi all. Have a linking (or ref) table which has a dual primary key. Need to return the last primary key which was auto generated from the current connection in a selected table. This is in java. The database is in MS Access if that makes a difference. Sorry for the rushed description, but our team is working to a tight schedule. Any l...

Getting the last access time for a file in Java

I know that using File object we can get the last modified time for a File. But, my requirement is to get the last accessed time for a file in Java. How do I get it? ...

How to parse badly formed XML in Java?

I have XML that I need to parse but have no control over the creation of. Unfortunately it's not very strict XML and contains things like: <mytag>This won't parse & contains an ampersand.</mytag> The javax.xml.stream classes don't like this at all, and rightly error with: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[...

How to allow running only one instance of a Java program at a time?

I need to prevent users from starting my Java application (WebStart Swing app) multiple times. So if the application is already running it shouldn't be possible to start it again or show a warning / be closed again. Is there some convenient way to achieve this? I thought about blocking a port or write sth to a file. But hopefully you ca...

Applet (or WebStart application) calling a server : best practices ?

I'd like to write an applet (or a java Web start application) calling its server (servlet?) to invoke some methods and to send/retrieve data. What would be the best way/technology to send and to retrieve those message ? ...

Hibernate second-level cache in orm.xml?

Hello, Having been googling for hours, I realize that users can use either xml file(orm.xml, I suppose?) or annotations in JPA, or both of them at the same time. I'm i correct? So, My project use the second-level cache, which is not in the JPA specification. And I use annotations like: @org.hibernate.annotations.Cache(usage = org.hibern...

What is the best practice for debug statements which have string operations in them?

I often find myself adding either concatonated strings or using a string formatter in my debug statements in log4net and log4j should I surround these debug statements with an "if debug" block to stop myself from wasting resources by processing these parameters even though the debug statement will not be printed out? I would assume that...

Java Logger only to file, no screen output!

Hello there SO'ers, I got a quite simple problem but cant find a solution for it. I have a logger with a file handler added, but it still spams to hell out of my console. How could I get the logger to solely route all output to a file, with NO console outputs? Thanks a lot, cru ...

Liferay Cluster

Do you know any step by step tutorial about installing Liferay cluster in Glassfish ? ...

How do you obtain the value of struts.action.extension in a struts2 interceptor?

I need to access the struts.action.extension value in the struts.xml file from an interceptor. Any suggestions? ...

Java Class file from SVN to Tomcat on server: How to compile automatically?

I'm currently fixing a JSP project and it currently has a seemingly random collection of .class files in it's Tomcat's WEB-INF folder. As a way of simplifying this, I was planning to get .java files from these classes straight from SVN to WEB-INF folder on server and I got that to work but what would be the simplest way of compiling thes...

Geneva-based STS, Java interop

I'd like to test whether my Geneva-based fedearated security services can be consumed with NetBeans/WSIT. Is there something like step-by-step guide? Server side uses 'message credentials over HTTPS' security mode while all the examples I've seen rely on message-level encryption and focus on consuming .net STS from Java RP-service. ...

Custom joins entitys on Hibernate

We have a Hibernate based system with Annotations. Our entities have a custom property DELETED. We have to select non deleted entities with non deleted sub-entities. How can we can do it? Little sample for describe the situation: GenericEntity { ... @Basic @Column(name = DELETED) protected Boolean deleted = false; @...

What Happened to BufferedImage class in Java ME 6?

Hello good people! from my small knowlegde from java se i want to try a tutorial on Java ME. I have Netbeans 6.5.1(with mobility package) and have Java 6 update 13 installed on my windows xp sp2.I've arrived on a stage of the tutorials where they are using BufferedImage that seems not to be found either on java.io, java.nio.Buffer, javax...

Reading multiple xml documents from a socket in java

I'm writing a client which needs to read multiple consecutive small XML documents over a socket. I can assume that the encoding is always UTF-8 and that there is optionally delimiting whitespace between documents. The documents should ultimately go into DOM objects. What is the best way to accomplish this? The essense of the problem i...

Eclipse warning about synthetic accessor for private static nested classes in Java?!

My coworker suggested making several of the Eclipse code-formatting and warning settings to be more rigorous. The majority of these changes make sense, but I get this one weird warning in Java. Here's some test code to reproduce the "problem": package com.example.bugs; public class WeirdInnerClassJavaWarning { private static class ...

Hibernate - PropertyNotFoundException: Could not find a getter for ...

I have a class that looks like the following: public class MyClass { private String dPart1; public String getDPart1() { return dPart1; } public void setDPart1(String dPart1) { this.dPart1 = dPart1; } } My hibernate mapping file maps the property as follows: <property name="dPart1" not-null="true"/> I...

How to download and save a file from internet using Java

There is an online file (i.e. http://www.website.com/information.asp) I need to grab and save to a directory. I know there are several methods for grabbing and reading online files line-by-line (i.e. URL), but is there a way to just download and save the file using Java? ...