Showing posts with label glassfish. Show all posts
Showing posts with label glassfish. Show all posts

Friday, February 5, 2016

ADF Essentials 12.2.1 NoClassDefFoundError: org/antlr/runtime/RecognitionException

Hello all, just wanted to share the following regarding to ADF Essentials 12.2.1.

I configured Glassfish to support ADF applications and was able to deploy a demo application. However, when loading the just deployed application I got:

java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException

FindJar.com says that class is inside antlr-runtime*.jar So I searched inside Glassfish looking for that file but, of course, it wasn't there. Did a quick search in maven and downloaded the file to:

{GLASSFISH_HOME}/glassfish/domains/domain1/lib

Restarted Glassfish and it's working now. However, why is this library not documented as needed in ADF Essentials documentation or Glassfish Configuration? I posted this question on oracle forums.

Hope it helps.

Monday, February 24, 2014

GlassFish Extension for JDeveloper 12c Go live!

Hi all, I just wanted to share with you that the Glassfish Extension for JDeveloper 12c is available now. As noted in my previous post, this extension is based on the source code provided by Shay Shmeltzer. You can learn more about his GlassFish Extension for JDeveloper 11g in the following post:


The source code for the extension can be found at the ADF-EMG GitHub repository, so you can help to enhance the extension and further develop it.
While the extension is deployed and hosted on Oracle's servers, so you can download it via JDeveloper's menu: help->check for updates, you can follow these steps in order to do a manual installation:
  1. Download the extension here: Glassfish Extension for JDeveloper

  2. Open JDeveloper and go to: Help->check for updates


  3. Select Install From Local File and browse for the file that you downloaded in step 1 (a .zip file)


  4. JDeveloper will show you a summary before installation, press the Finish button and will restart itself to complete the installation


  5. Once the installation is complete, yo can find a new section in the toolbar and inside the Run menu with the Glassfish Extension buttons




  6. Before you can use the extension, you should configure the paths to your Glassfish server installation, you do that in: Tools->Preferences->Glassfish Preferences




That's it, now you can control your GlassFish server from inside JDeveloper 12c.

see ya!

Thursday, January 23, 2014

GlassFish Extension for JDeveloper 12c

Hi all, I just wanted to share with you that I'm working on a GlassFish extension that works with the new JDeveloper 12c. This extension will be based on the source code provided by Shay Shmeltzer. You ca learn more about his GlassFish Extension for JDeveloper 11g in the following post:


The 12c extension is in its early testing phase, I'll do tests on OpenSuse, Ubuntu 13.10, Windows Vista and Mac OSX (Mavericks). Once the test phase is complete I will release the extension so you can download it using JDeveloper's menu: help->check for updates. Also, the source code will be uploaded to the Oracle JDeveloper 3rd Party Extensions project at java.net.


see ya!

Tuesday, November 5, 2013

Book Review: Developing Web Applications with Oracle ADF Essentials

Book cover from
http://www.packtpub.com
Oracle ADF is a framework for building Rich Web applications with Java which is built on top of Java EE. So if you have previous experience in building Web applications using JSF you are likely to start developing with Oracle ADF pretty fast. On the contrary, if you are just beginning with Web development, the visual and declarative development that this framework offers will let you build your applications in a fast pace.

In this post, I'll be reviewing the book "Developing Web Applications with Oracle ADF Essentials" written by Sten E. Vesterli and published by PACKT. Although this book covers the 11.1.2.4.0 version, the concepts are the same as of the latest version (12.1.2.0.0 released a couple of months ago), it is a great book to get you started with Oracle ADF Essentials. The chapters are easy to read, they follow a tutorial approach and a summary at the end. You will learn what you need in order to build a Web application using a "free software" stack: JDeveloper IDE, ADF Essentials, Glassfish application server and MySQL database. This is an introductory book, so you won't find what every single property of the framework means, but it does have advance topics such as: how to configure ADF applications to be developed as shared libraries, how to implement security for an ADF Essentials application (remember ADF security is not part of ADF Essentials), among others.

IMHO when you are using ADF Essentials with other databases rather than Oracle DB you won't be able to use the full power of ADF (or ADF Essentials) and sometimes you'll find yourself looking for workarounds in order to achieve some behavior that with Oracle DB you get out-of-the-box.

From chapters 1 to 4 you will learn the basics of building an Orace ADF Essentials application and whenever there's a different behavior for using MySQL database, you'll get a tip or note clarifying this. You will also get several useful URLs pointing you to other sources of information. The chapters are tutorial like, you will be building an application with two use cases covering the core ADF Essentials technologies: Business Components for Java (BC4J) and ADF Faces.

On chapters 5 to 8 is where you get the advance training. Building enterprise like applications requires changes in your application structure and this book teaches you how to do it and what you need to have in mind when building such applications. Another important feature is debugging and ADF has its own way to deal with it, the book shows you the way you can configure your application in order to enable debugging at different levels. I really liked that chapter 7 is about securing your ADF Essentials application but it was not only limited to using JAAS, you will learn how to configure and use the Apache Shiro security framework in order to address the lack of the security mechanism in ADF Essentials. Last but not least, you'll see how to configure ANT in order to automate your building process, this is pretty useful when you are working on big projects.

Overall, I liked the book, learned new things and from now I'll try to blog about some ADF + MySQL workarounds that I have used in my projects.

For more information about this book go to:
http://www.packtpub.com/developing-web-applications-with-oracle-adf-essentials/book

See ya!

Thursday, March 28, 2013

Glassfish plugin for JDeveloper 11gR2

Hello, all. As some of you already know, ADF Essentials is a great framework for building web applications using java and it is free to develop and free to deploy. You deploy ADF Essentials applications on Glassfish (3.1+) server. Nevertheless, JDeveloper does not come with an embedded Glassfish server but with an embedded Weblogic server.

In this post, we are going to talk about when to use the integrated Weblogic server and when you should use an external Glassfish server during your ADF Essentials application development.

What you need

Once you have installed the above software, you may start creating your ADF Essentials applications. There are tons of documentation online: books, tutorials and videos to help you. My recommendation is try to use the integrated Weblogic server during development so you can debug and run your applications right from JDeveloper. When you finish developing some functionality, test your development on Glassfish server, at the end, if you are developing an ADF Essentials applications this is the application server you are most likely to use in a production environment. Make sure you have configured your Glassfish server for ADF Essentials applications as described here:


The version of JDeveloper you installed, comes with a built in functionality to deploy your applications to Glassfish server. However, you have to start the server before you can deploy your applications. One way to do it is to use the Glassfish server controls (they are installed once you install Glassfish) outside of JDeveloper.
My recommended way is to use the Glassfish plugin for JDeveloper so you can start/stop Glassfish server right from the IDE! The plugin was created by Shay Shmeltzer and the version 1.3 has been modified to run on Linux (thx to me, @aa_lopez) and to run on Mac (thx to David Aroca).

The plugin can be found at help->check for updates. More information here:
https://blogs.oracle.com/shay/entry/glassfish_extension_for_oracle_jdeveloper

If you want to make contributions to the source code, you can find the project at java.net:
http://java.net/projects/jdev-3rd-party-ext/sources/svn-repository/show

Once you have installed the plugin, your JDeveloper presents four new buttons:



From left to right:
  • The first one lets you start the Glassfish server.
  • The second one lets you stop Glassfish server.
  • The third one starts Glassfish server in debug mode.
  • The fourth one starts the Glassfish server web console app.

Before you can start using these new buttons, you have to configure the paths to the Glassfish server. To do this, go to Tools->Preferences and select the Glassfish Preferences:



The plugin comes with Windows OS paths by default. So if you are using Linux or Mac, you have to change these paths in order to have the plugin buttons working. In my case, I'm using Linux, so I changed the paths to match the paths where I installed my Glassfish server.
Note: I had to add the --verbose option to the start command, otherwise, Glassfish starts and stops immediately.

Glassfish Home Directory: /home/aalopez/development/glassfish-3.1.2.2/

Start Glassfish Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin start-domain --verbose domain1

Stop Glassfish Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin stop-domain domain1

Start Glassfish in Debug Mode Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin start-domain --debug=true

Glassfish Admin URL: http://localhost:4848

Once you finish the configuration, you are ready to start using Glassfish server from JDeveloper, just don't close the window that pops up when you hit the "Start Glassfish" button.


How to deal with data sources between Weblogic and Glassfish servers?
When you are working with the integrated Weblogic server, JDeveloper creates a data source to access the database. This data source has the following structure:

java:comp/env/jdbc/DATASOURCE_NAME

Where DATASOURCE_NAME is the name you gave to the data source when configuring the connection to the data base. The problem is that Glassfish server uses another structure. When you define a data source in the Glassfish server web console app, you define it like this:

jdbc/DATASOURCE_NAME

If you keep running your application using Weblogic and Glassfish servers, I recommend the following configuration, so you don't have to manually change the data source structure every time you change the application server:

Define the resource at Web Content/WEB­INF/web.xml

<resource-ref>
   <res-ref-name>jdbc/DATASOURCE_NAME</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
   <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

As stated by the Java EE web-app deployment descriptor version 2.5:

The res-ref-name element specifies the name of a
resource manager connection factory reference.  The name
is a JNDI name relative to the java:comp/env context.
The name must be unique within a web application.

So we are not defining what to do with jdbc/DATASOURCE_NAME but we are actually defining   java:comp/env/jdbc/DATASOURCE_NAME which matches exactly the data source structure configured in the application and used by Weblogic server.

This is actually a good practice, since at development time you don't have to worry about what is going to be the structure or name of the data source at deployment time. You just define, in the web.xml deployment descriptor, the structure or name of the data source and the deployer (yes, the person who makes the deployment) can map that structure or name to something else. This is done in a container-specific configuration file, as we shall see next.

Create the glassfish-web.xml configuration file. Right click on the Web Content/WEB-INF folder and select the New... option:




A window pops up, select the General category and then choose the File option:



Enter the name of the file as glassfish-web.xml and make sure the path to this new file is inside the WEB-INF folder:



Once the file is created, open it and enter the following code:

<?xml version="1.0" encoding="UTF-8" ?>
<glassfish-web-app>
    <context-root>YOUR_APP_NAME</context-root>
    <property name="useBundledJsf" value="true"/>
    <class-loader delegate="false"/>
    <resource-ref>
        <res-ref-name>java:comp/env/jdbc/DATASOURCE_NAME</res-ref-name>
        <jndi-name>jdbc/DATASOURCE_NAME_AT_GLASSFISH</jndi-name>
    </resource-ref>
</glassfish-web-app>

Here I copied the configuration that JDeveloper adds to the glassfish-web.xml file at deployment time. I also added the configuration that let us map the data sources. The resource-ref element is what we are going to focus on this post.
Change DATASOURCE_NAME for the name you defined for your data source in the web.xml deployment descriptor and DATASOURCE_NAME_AT_GLASSFISH for the name you defined in the Glassfish Web console app.

How it works:
  1. We defined the data source as a resource in the web.xml deployment descriptor. Remember that we are using the structure jdbc/DATASOURCE_NAME but what it really means is that we are using java:comp/env/jdbc/DATASOURCE_NAME
  2. We created the glassfish-web.xml deployment descriptor. This is a container-specific configuration file and is created automatically by JDeveloper when you deploy to a Glassfish server. However, if the file already exists it is not overridden  Here we mapped the data sources definitions so we are telling Glassfish that when we are looking for java:comp/env/jdbc/DATASOURCE_NAME in our application, what we really mean is that we are looking for jdbc/DATASOURCE_NAME in the Glassfish server.

That's it. With this configuration you don't have to worry about the data source configuration differences between Weblogic and Glassfish servers. Happy ADF Essentials coding.

see ya!


References:

Oracle ADF Essentials. Oracle [online].
Available on Internet: http://www.oracle.com/technetwork/developer-tools/adf/overview/adfessentials-1719844.html
[accessed on March 24 2013].

Deploying ADF Applications to GlassFish. Oracle [online].
Available on Internet: http://docs.oracle.com/cd/E35521_01/web.111230/e16182/appendix_glassfish.htm#CEGDIGEE
[accessed on March 28 2013].

Java EE: XML Schemas for Java EE Deployment Descriptors. Oracle [online].
Available on Internet: http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html#5
[accessed on March 28 2013].

What is resource-ref in web.xml used for?. Oracle [online].
Available on Internet: http://stackoverflow.com/questions/2887967/what-is-resource-ref-in-web-xml-used-for/2888169#2888169
[accessed on March 28 2013].