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.

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

Hello, welcome the part four of this tutorial. Today we will be adding Spring configuration to our application.
Start by creating the following packages: blog.dao and blog.service.
The next thing we will be doing is adding the Spring configuration file: add applicationContext.xml file to your WEB-INF folder.

The basic setup of this file should look like this:






This configures the namespaces we will be needing in our configuration. Next we will have a look to what we will need specifically.

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

Here we are for the third part of these tutorial series, we will now cover how to map create our JPA mappings.
This tutorial will be using a simple blog example from now on, using a simple mysql database.

Ok let's start by introducing our first entity "Post":

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

Hello again, in this tutorial we will continue our MavenWebapp project we made earlier.
This part will focus on configuring maven.

When opening the pom.xml you should now have the following code:

    4.0.0

    MavenWebapp
    MavenWebapp
    war
    1.0

    



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

Hello everyone, in this article i will you how to setup a web application with maven integration in Intellij.
I'm planning to make it a mutli-part tutorial on how to configure maven with spring and jpa. This is the first part in the tutorial, more coming soon.



  1. Open your Intellij, navigate to file -> new project and create a project from scratch -> next

Adding SyntaxHighlighter to Blogger

In this tutorial I will cover how to implement SyntaxHighlighter to your Blog. First of all... SyntaxHighlighter is a javascript based syntaxhighlighter which supports the most popular programming languages such as java, .NET, javascript, etc.

For more info please refer to http://alexgorbatchev.com/SyntaxHighlighter/. Implementing SyntaxHighlighter is very easy to use I will show you in a few steps how to add the hosted version to your blogspot blog.

Let's get started, the first thing to do is go to the Designer view.
Template -> Edit HTML -> proceed

Search for the <head> tag and paste the following code right under it: