NetBeans to JDeveloper Part 1: A SessionEJB Maven Application

This entry demonstrates taking a NetBeans 6.8 SessionEJB application that uses Maven 2.2.1 and creating a JDeveloper project based on the POM.


Installing IDEs and Maven
Simply follow the wizards for each IDE and go with the defaults. You may want to change installation home directories.

For maven, unzip the archive to the directory of your choice. This entry assumes the following location:

C:\Program Files\Apache Software Foundation\apache-maven-2.2.1

Additional configuration is required for Maven as outlined here.

The Maven extensions will need to be downloaded and installed in JDeveloper. There are two extensions and within JDeveloper simply select Help | Check for Updates. Select the two extensions named & JDeveloper will restart to complete the installation.

Create an Enterprise Application Using Maven in NetBeans 6.8
After launching NetBeans some minor configuration is required to use Maven as follows:

  • Select Tools | Options | Miscellaneous | Maven

  • For "External Maven Home", browse to the Maven home for your installation. This entry assumes "C:\Program Files\Apache Software Foundation\apache-maven-2.2.1".

  • For "Local Repository", browse to the Maven repository for your installation. This entry assumes "C:\Documents and Settings\{user}\.m2"

Now you can proceed with the creation of the Application. Here are the steps.

  • Select File | New Project | Maven | Maven EJB Module

  • For "Project Name" enter mavenproject1 or whatever you prefer.

  • For "Java EE Version" select Java EE 5

  • For "Package" enter acme.ejb.session or whatever you prefer and select "Finish".

  • Right select the project mavenproject1 and Select New from context followed by Other | Java EE | Session Bean. Select Next.

  • Name the EJB HelloWorldSessionBean.

  • Select the package that you used when you created the project (acme.ejb.session).

  • Set "Session Type" to Stateful and "Create Interface" to Remote. Select "Finish"

  • Notice that you have created to java objects. One is the Session Bean itself and the other is the remote interface.

  • In the session bean add the following method.

  • public String sayHello (String name) {
    return "Hello " + name + ":)";

  • In the remote interface add the following reference.

  • String sayHello (String name);

  • Save the application. Once done, you can quit NetBeans and start JDeveloper if you haven't already done so.

  • The sample NetBeans application can be downloaded from here.

Create an Application Workspace in JDeveloper followed by a Maven Project from a POM
Here are the steps:

  • Select "New Application" and enter SessionEJB for the name. For the "Application Template" select Generic Application. Select Finish. This creates an application workspace and an empty project that won't be used in this instance.

  • Right select the SessionEJB workspace and select General | Maven | JDeveloper project from a POM.

  • Browse to the "Maven POM file" within the NetBeans project that was created earlier and select it. The location will be something like this: C:\NetBeansProjects\mavenproject1\pom.xml

  • Ensure your "Local Repository" is set correctly as follows: C:\Documents and Settings\{user}\.m2\repository

  • Select the "Settings File" for the version of Maven that you're using. In this case it is Maven version 2.2.1 and not 2.1.0 that comes with JDeveloper and should be something like the following: C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\conf\settings.xml. Select OK.

  • The Application Navigator should appear as follows:

  • mvn1.PNG

  • Right select mavenproject1 and select "Project Properties" from context.

  • Select "Libraries and Classpath" and add the following libraries: EJB 3.0 & WebLogic 10.3 Remote-Client.

  • Select "EJB Module" and select 3.0 for "EJB Version". Notice that your session bean will be added to the "Annotated EJB 3.0 Bean Classes" section.

  • Open your session bean for editing and add the following mapping at the end of the @Stateless annotation:

  • (name = "HelloWorldSession", mappedName = "SessionEJB-mavenproject1-HelloWorldSession")
  • Following the @ Stateless annotation add the @Remote annotation.

  • Right select HelloWorldSessionBean and select "New Sample Java Client" from context.

  • Set the "Client Class Name" as follows: acme.client.HelloWorldSessionBeanRemoteClient. Select OK.

  • Add the following line to your test client Right after HelloWorldSessionBeanRemote helloWorldSessionBeanRemote.......

  • System.out.println(helloWorldSessionBeanRemote.sayHello("World"));

  • Save your application and right select on the HelloWorldSessionBean and select run from context.

  • Once this has successfully compiled and deployed to the integrated WebLogic server, right select on the test client and select run from context. The indication that the integrated server is running is as follows: "[Server Instance IntegratedWebLogicServer has been started]".

  • Results of running the test client.

  • mvn2.PNG

This entry has demonstrated creating a simple HelloWorld Session EJB using Maven with the NetBeans IDE. I then created a project from a POM in JDeveloper using the NetBeans project followed by successfully running the application.

For more information on Maven integration within JDeveloper 11g please review the How-To "Working With Maven Projects In Oracle JDeveloper 11g".


Post a Comment:
  • HTML Syntax: NOT allowed

I'm a Principal Product Manager in the JDeveloper/ADF product management team. I've been working with JDeveloper since 2004.


« February 2016