-
The LocalSessionFactoryBean is a convenient way to create and initialize a Hibernate SessionFactory instance in applications. It allows us to configure other objects and properties, such as DataSource, and other Hibernate properties that the SessionFactory instance depends on during initialization inside Spring’s context mechanism. We can easily configure other parts... [Read More]
-
Delegating Authentication to JAAS Module in Acegi Security
By Kenan SevindikWe are currently using Acegi Security in our web project. At the moment, we employ its form-based authentication. In the future, we have to integrate our web application with an environment in which JAAS-based single sign-on mechanism will be used for authentication. As a first step, we tried to delegate... [Read More] -
A Generic JRDataSource for JasperReports
By Kenan SevindikIt is possible to pass data to JasperReports templates via a custom data source, which implements the JRDataSource interface. The reporting engine iterates over the report data collection with the boolean next() method and evaluates field expressions by requesting values for them from the data source instance using the Object... [Read More] -
Experiences with JasperReports and iReport Designer
By Kenan SevindikJasperReports employs the concept of subreporting to handle complex report template requests, dividing the main part into logically related and more manageable smaller subreport chunks. For example, if a report includes a section where a list of data items appears as a data table, that section is a natural candidate... [Read More] -
A Small Silly Reminder For Unclosed Session Warning of Hibernate
By Kenan SevindikIf you suddenly receive a warning stating “unclosed connection, forgot to call close() on your Session” from Hibernate, and you are utilizing OpenSessionInViewFilter to manage your Hibernate sessions, it is crucial to verify that the filter mapping of OpenSessionInViewFilter in web.xml precedes any other filter mappings, such as Acegi Security... [Read More] -
Styling HTML Input File Elements
By Kenan SevindikIt is nearly impossible to ensure that HTML input file elements match the appearance of other parts of web applications. Browsers offer limited possibilities for styling them, if any at all. However, in newer browser versions, there are some tricks that can help alleviate this common styling problem, and one... [Read More] -
Switching Application Required System Properties According to Deployment Environment
By Kenan SevindikAny serious application depends on a number of configuration properties, such as JDBC connection properties and caching properties. These properties should change according to the target deployment environment. [Read More] -
Customizing JSF Required Field Messages per Component Instance
By Kenan SevindikJSF is advantageous in that it provides several useful built-in features for validating entered values or ensuring that required values are provided. However, it falls short in providing sufficient mechanisms for developers to customize these features at the level of each component instance. This is a common drawback of the... [Read More] -
Managing Dependencies With Ant
By Kenan SevindikEvery non-trivial Java application has many dependencies on other resources, especially JAR files. We must keep track of which JARs we are utilizing and their versions as the project develops. Systems may undergo several releases during their development lifecycle, and among those releases, dependency lists may change. New JARs may... [Read More] -
Mocking ResourceBundle
By Kenan SevindikIf you want to unit test a method that depends on java.util.ResourceBundle and you want to isolate bundle access code by mocking ResourceBundle, using, for example, the JMock Dynamic Mocking Library, you will face a restriction. Commonly used methods such as getString(key) are defined as final in the ResourceBundle class,... [Read More] -
Lookup Tables with Hibernate and JSF
By Kenan SevindikEvery project comprises several tables containing data mainly in the form of a code-name pair. These tables define states, types, or other similar values as codes, which will be referenced from other tables in the database. Furthermore, their name values are utilized in the GUI to provide users with an... [Read More] -
Enabling Acegi (1)
By Kenan SevindikWe have decided to use the Acegi Security Framework to implement security requirements in our web-based project. However, we might possibly have diverse security requirements beyond form-based authentication and role-based authorization. These could include remoting support, domain object security, run-as capability, single sign-on (SSO), after-invocation security, certificate-based authentication integrated with... [Read More] -
Cactus XOR Mocks or Cactus AND Mocks?
By Kenan SevindikWe employ both Spring and Hibernate to implement the business and data access layers in our current project. Our aim is to bring clear separation between those two layers. Beans in the business layer act as service entry points; they simply realize our use case scenarios. They are also good... [Read More] -
Why to use absolute paths to reference resources in login and error web pages
By Kenan SevindikI think it is a well-known practice to use absolute names to access resources in login and global error pages, but the reason behind it might not be so clear for some of us. The Servlet specification states that when a protected resource is accessed, the request should be directed... [Read More] -
Extending XDoclet Hibernate Module
By Kenan SevindikAs you may be aware, Hibernate’s bag collection type stores its elements unordered, unindexed, and may contain multiple copies of the same element instance. Since the Java Collection Framework does not inherently provide a concept of a bag, we typically use the available List type to implement bag semantics in... [Read More] -
Uncaught Exception Handling in Java Server Faces
By Kenan SevindikFirst, a brief flashback on how we can handle uncaught exceptions in web applications. As you’re likely aware, there’s a general exception/error trapping mechanism for servlet/JSP-based web applications. We simply add error-page definitions in the web.xml file for uncaught exceptions or HTTP status codes to display custom error pages to... [Read More] -
Extending XDoclet Spring Module
By Kenan SevindikXDoclet is a wonderful tool, and we extensively use it in our current project to generate Hibernate and Spring configuration files. Our aim is to maintain no configuration files apart from our source code. XDoclet’s help is invaluable in achieving this goal, but sometimes it requires modifications to align with... [Read More] -
Experiences with Audit Logging through Hibernate Interceptor
By Kenan SevindikIn our current project, we make use of the Hibernate Interceptor to perform auditing and track operations performed with our domain objects. Initially, we simply followed the instructions in the Hibernate In Action book. Basically, the steps are as follows: [Read More]