Adding a webclient to EJB project

This tutorial goes on where The previous tutorial stopped so please make sure to check it out before reading anay further!

Ok let's get going again, open the ejb project in your intellij IDE and follow these simple steps:

  • Click file -> new module 
  • Create new module from scratch -> next
  • name the module webclient -> next
  • create source directory src -> next
  • select application server and web application (should be checked when you check application server). Again make sure to select your jboss 6.1.0 final server.
  • Click finish

EJB Hello World project with Jboss server

Hi everyone, today i have experienced it can be rather challenging to setup a EJB (Enterprise Java Beans) project from scratch so i decided to make a little tutorial. To do this i will be using the Intellij IDE and Jboss as my server.IMPORTANT: DO NOT USE ANY SPACES IN YOUR PATHS! THE SERVER WILL HATE YOU FOR IT! :)


Prerequisites:
Create a new project from scratch:

  • In your Intellij IDE go to File -> new project
  • Create project from scratch -> next
  • name your project "ejb" and put it on c:\\ for example, as long as there are no spaces. Leave all other settings as they are (create java module checked) -> next
  • Create source directory src -> next
  • In the the current window you are able to select the facets you'd like to add to your module, select application server, enterprise javabeans (EJB) and javaEE application. make sure the EJB version is set to 3.1 and that you select your jboss 6.1.0 server for application server. note: uncheck Web application! as we only want to create the ejb side (backend in this tutorial)
  • click finish and intellij will download all needed jars for you! :) 

URISyntaxException Starting Jboss

I recently encountered the following error:
Failed to deploy: file:/C:/Documents and Settings/jbossSpaces/out/artifacts/jbossSpaces_ear_exploded.ear/: java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/jbossSpaces/out/artifacts/jbossSpaces_ear_exploded.ear/

Moving the project to c:\\ solved it for me.

Turns out that Jboss can't handle spaces in the path so always make sure that you use a path without any spaces!

Spring AopConfigException

Description:
org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
Spring is using cglib to create it's proxies, therefor you need to add the cglib jar to your classpath.


Solution: Add the following dependency to your pom.xml :
        
            cglib
            cglib
            2.2.2
        

Set up a maven web project in Intellij with Spring and JPA - Part Seven

Welcome to part Seven of this tutorial series! After configuring our Spring MVC setup in the last tutorial we will now implement it. First of all let's have a look at our index.jsp and change it to this:


We only need this one line of code here.



Now create PostController.java in the blog.controller.dao package and mark it with @Controller.

Set up a maven web project in Intellij with Spring and JPA - Part Six

Hello, welcome to part 6 of these series. Today we will be covering how to configure spring mvc in a web application.

First off all let's configure our web.xml which at this point should look something like this

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
           version="3.0">

</web-app>


In a web application you can tell Spring to load config files in the following way: If you would like to pass more config files just separate them with a comma.

Set up a maven web project in Intellij with Spring and JPA - Part Five

Here we go for part 5 of this tutorial series! This part will cover our Data Acces Object Layer (DAO).
We will be mainly talking about CRUD (create,update,delete) operations using JPA and Spring.


I should start by saying that we will use an Interface and an Implementation for each Entity.
This way we can easily switch database providers later if we would like to.

The PostDao interface:
package blog.dao;

import blog.domain.Post;
import java.util.List;

public interface PostDao {
    List<Post> findAllPosts();
    Post findPostByPostId(Long postId);

    void create(Post post);

    void remove(Post post);

    void update(Post post);

    List<Post> findMostRecentPosts();
}

note that we created crud methods and some other selection methods we'll need later.