Can I Use WAR With Java EE 6 Full Profile?

Java EE 6 brings a lot new features. Among the others there is the concept of profiles. Java EE starts with the definition of two: Full and Web Profile. The idea is to create separate and more specialized set of services that better suits your job. E.g. if you only want to use Servlets, JSP and add some EJB’s – do you really need full-blown application server with JMS, JMX, CORBA, JAX-WS and a lot of other abbreviations?...

November 11, 2012 · 2 min

EJB 3.1 Interceptors -- Same Transaction, Same Principal

Few days ago I’ve created a simple interceptors spike-solution at Github. Its purpose was to show my colleagues that in the EJB’s interceptors you can implement a code that exists in the same transaction and the same security context as the called EJB business method. Moreover, you can benefit from all the dependency injection you need. This project uses the following resources injected by the Application Server: TransactionSynchronizationRegistry – used for getting current transaction key and checking if we’re in the same transaction (I’ve written about it e....

November 11, 2012 · 2 min

Save Connection Settings in Midnight Commander

In Midnight Commander when you press ctrl + \ you can access directory hotlist and you can quickly choose connection you want to establish. The problem is – you cannot by default save passwords, so every time you select this connection you need to input it. Sure, it’s safe to do so, but if using them in your desktop and you’re the only user of it – you can expect a bit more pragmatic approach....

November 10, 2012 · 2 min

Filtered Resources in Maven

Maven has some really great features. One of them is filtered resources. Basically, if you use Maven for some time, I’m sure you know what by default everything you put in src/main/resources will be added to the classpath in the resulting artifact (e.g. in the WEB-INF/classes for a *.war archive.) Putting resources in this location is a common way of adding Java properties file to your project. Now what is interesting: you can use Maven variables in those resource files and they can be swapped into final value during the process-resource phase....

October 14, 2012 · 2 min

New OCE WCD Exam Simulator

More than 18 months ago I’ve posted my mock exam for Oracle Certified Expert Web Component Developer certification. Until now it’s quite popular and useful (deducting from the comments) for many of you. What I dislike about this exam is that it’s published as a plain WordPress post and it’s rather awful to edit it and it’s not so easy to read as well. So, that’s the aim of my small side project: to create a basic platform for presenting exam questions and their answers....

October 9, 2012 · 2 min

FETCH JOIN is still a JOIN

JPA’s FETCH JOIN is useful in cases when you want to eagerly load some lazy loaded collection of your entity. By default all @OneToMany and @ManyToMany relationships are lazy loaded. There are some valid cases when (despite the settings in your mapped entity), you want to eagerly load the related entity. One of the way of doing it is to use JOIN FETCH JPQL clause. It’s worth remembering that JOIN FETCH is used mainly because of its side-effect of populating the pointed relationship – it’s still a JOIN and must be treated like it when it comes to the duplicated result set problem....

October 5, 2012 · 3 min

Creating Maven Repository on Shared Hosting

You can easily create a fully functional, basic Maven repository on your web hosting provider’s account. It will give others the possibility to access your released artifacts using clean URLs (like yoursite.com/maven or maven.yoursite.com) or use it as a repository straight from the Maven. To achieve it, you’ll need to: create Maven FTP user, create a subdomain (optional), add Maven server configuration, add distribution management to your pom.xml, add Maven FTP wagon provider, use your repository in client projects....

October 4, 2012 · 4 min

Enabling Java EE Security in OpenShift Application

By default few of the security features are turned off in OpenShift JBoss 7.1 cartridge. If you want to use the Java EE security features first you need to define your security roles and constraints in your deployment descriptor, e.g. web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app> // ... <security-role> <role-name>admin</role-name> </security-role> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/admin/login.xhtml</form-login-page> <form-error-page>/admin/login.xhtml?error=1</form-error-page> </form-login-config> </login-config> <security-constraint> <web-resource-collection> <web-resource-name>Modify questions section</web-resource-name> <url-pattern>/admin/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>admin</role-name> </auth-constraint> </security-constraint> </web-app> (I’ve omitted the logging form source code as it’s not the main point here....

September 29, 2012 · 2 min

After the Spring Core 3.0 Exam

Yesterday I took the SpringSource Certified Spring 3.0 Professional exam and passed it successfully with 94%. Below you can find some information about my preparation process, the exam form and the type of questions. So, here we go. Preparation I attended the Spring 3 Core training and described it here. This was the entry point for my learning process. I’ve done a lot of notes during the training, so even after three months, the slides + notes were pretty decent source of knowledge....

July 24, 2012 · 3 min

Inject Java Properties in Java EE Using CDI

The aim of this post is to show you how, using CDI, you can inject Java properties entries (those in *.properties files) directly into your Java class. This is somewhat similar to the Spring’s @Value annotation I needed in my plain Java EE project. The whole code can be found on GitHub so feel free to clone it, use it or make any changes you like. Context Ok, so basically in a Java EE environment we already have a way to define some properties that are deployment-specific – it’s the <env-entry> element in the descriptor....

June 17, 2012 · 12 min