spring

Best way to check whether a certain exception type was the cause (of a cause, etc ...) in a nested exception?

I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What's the best way to determine whether MyCustomException somehow caused the exc...

Searching for Generic Asynchronous Java Job Execution Framework / Library

I am looking for a generic asynchronous Java job execution framework that could handle Callables or Runnables. It would be similar to java.util.concurrent.ExecutorService, (and possibly wrap ExecutorService), but it would also have the following features: The ability to persist jobs to a database in case the application goes down while...

Would you use AOP for database transaction management?

A while back I wrote an application which used Spring AOP for defining which methods were transactional. I am now having second thoughts as to how much of a great idea this was; I have been hit a few times after a minor refactor (changing method signatures etc), which of course doesn't become apparent until something actually goes wrong ...

Client side object velocity

I would like to create an object client side and add it to another object. I'm using velocity and Spring. I form a command object and pass it to the view as a backing object. I want to create and add a new object to this command object without saving either object to the db. The reason for this is that I want to have some persistence...

Doesn't Spring's dependency injection break information hiding?

Coming from a C++ background I have to master the complexity of the Java world and its frameworks. Looking at the spring framework for DI I am finding it difficult to believe that I have to make each setter function which will be subject for DI public. Doesn't that requirement break the principle of information hiding? Of course I...

Spring vs Jboss

What are the advantages and disadvantages for Spring vs. Jboss for an enterprise web application. ...

JAAS for human beings

I am having a hard time understanding JAAS. It all seems more complicated than it should be (especially the Sun tutorials). I need a simple tutorial or example on how to implement security (authentication + authorization) in java application based on Struts + Spring + Hibernate with custom user repository. Can be implemented using ACEGI....

Spring Framework

What is Spring Framework? What's its contribution to Hibernate? ...

Spring Security: How to get the initial target url

I am using the spring security to restricted urls. I am trying to provide signup and login page, on the same page. On login spring security transfers to the restricted page. However i am trying to pass the target url to the signup process, so that after signup we can redirect to the restricted page. How to get the actual URL that user ...

Spring Controller destroy method?

Does Spring's Controller have any sort of destroy/cleanup method? I couldn't find anything in the JavaDocs for Controller and AbstractController. I'm looking for the equivalent of javax.servlet.Servlet's destroy() method. The reason for this is that I'm starting a thread in my Spring controller. I want the thread to terminate whenever t...

Why am I getting a Hibernate LazyInitializationException in this Spring MVC web application when the data displays correctly?

I am attempting to create a web application using Spring MVC, with Hibernate as its ORM layer. However, due to my inexperience with both frameworks I'm struggling. The following code will properly display all the records I am looking for but still throw a stack trace into my logs. I'm having trouble finding thorough documentation concer...

Spring @Autowired usage

What are the pros and cons of using @Autowired in a class that will be wired up by Spring? I probably just don't understand it, but to me it almost seems like an anti-pattern - your classes start to become aware that they are tied to a DI framework, rather than just being POJOs. Maybe I'm a glutton for punishment, but I like having t...

Creating a process from within an instance of Jetty that was launched from Maven

Hello, I'm looking to launch a separate Java process from within an instance of a Spring controlled bean that runs in a Jetty container. The Jetty instance was launched from mvn jetty:run This separate process communicates with the launching process via RMI and I'd like to be able to maintain a hook to the process's ID or Process objec...

Integrating Spring + Hibernate + Sql server with unicode support

How could I integrate Spring with Hibernate using sql server 2005 and have Unicode support. I tried many different ways but I just couldn't get it to work. Column in the table is nvarchar, character set in Spring is UTF-8. I can read Unicode text (which I added myself using the sql server management tool) just fine but writing doesn't w...

Does Acegi/Spring security support getUserPrincipal()?

I need to interface an existing application with Acegi/Spring security. In order to get started I am looking for one simple piece of information: in this context, will HttpServletRequest.getUserPrincipal() called from my application properly return the username obtained through Spring (as opposed to using Spring-specific objects)? I hav...

How do I write StoredProcedure sub-classes to call Oracle functions?

I've written the following Spring JDBC API StoredProcedure sub-class: class GetLdapPropertiesStoredProcedure extends StoredProcedure { protected GetLdapPropertiesStoredProcedure(JdbcTemplate jdbcTemplate) { super(jdbcTemplate, "get_ldap_properties"); setFunction(true); declareParameter(new SqlReturnResultSet("rs", new Produ...

Spring - best way to deal with binding to a list of beans in a simpleformcontroller

Hello, Without thinking about it too much, I've been doing something like the following: 1) building a list of SomeBean objects based on the results of a database call 2) putting that list in my command object 3) building a form based on that command object where users can modify attributes of the SomeBeans 4) extracting data out of...

Invalid scale size. Cannot be less than zero

I am using spring-2.5.6 to connect from a standalone application to an Oracle 10g database (ojdbc14.jar) using the org.apache.commons.dbcp.BasicDataSource. When I try to retrieve a SqlRowSet using the public SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException method I am getting an 'java.sql.SQLException: Inval...

How can I find all classes on the classpath that have a specific method annotation?

I want to implement an intialization mechanism that is annotation-based in Java. Specifically, I have an annotation I've defined: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Initialization { /** * If the eager initialization flag is set to <code>true</code> then the * initialized class will be i...

Best way to cache persistent data (e.g. code books) in Spring?

I have a series of code books in my database, and I am using plain JDBC calls to fetch them and store them in a collection. I would like to put these in some kind of a cache at application startup time in order to save time later. I don't need any fancy stuff like automatic object invalidation, TTL etc - the code books change rarely, so...