Montag Nov 17, 2008
Ubuntu - MySQL - Glassfish
To install MySQL on Ubuntu to be used in a Glassfish JEE App is very easy.
You can download and install MySQL Server using the Synaptic Tool in Ubuntu. During Setup you will be asked for a root password. this is a password for the user "root" inside the mySQL Server. So its not your Linux root password.
After intalling mysql server you can easily start and stop it with
> sudo /etc/init.d/mysql start
> sudo /etc/init.d/mysql stop
To get into the mysql console use
>mysql -u root -p
There you will be ask for the mysql root password.
To create a new database use the following command form the mysql console:
mysql> create database my_database;
Now you can setup the JDBC Pool inside Glassfish server.
First download the JDBC Driver form mysql download page and put the 'mysql-connecto-java-5.1.x.jar' into glassfish/domains/domain1/lib/ext
use the following Class Name to configure you JDBC Pool: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Use the additional params:
- databaseName : [you_database_name]
- user: root
- password : [you mysql admin password]
Samstag Nov 08, 2008
OpenID Authentification Modul for Glassfish
In the OpenSSO Project on dev.java.net you can find an extension for OpenID. With this OpenID Module which is based on jsr-196 it is easy to use OpenID authentification in a JEE Application running on Glassfish. Additional Informations about the JSR-196 can be found here.
To build the Sources of hte OpenID Authentification Module is very easy as the project is based on maven. So first check out the sources form the jsr-196 project inside cvs code repository
https://opensso.dev.java.net/source/browse/opensso/extensions/jsr196/
The hostname for the cvs repository is : cvs.dev.java.net
Repoistory path is : /cvs
Connection type is: pserver
You just need to check out the jsr-196 project which is found under /opensso/extensions
After you have checked out the sources you can run a maven install directly to build the libary. Information about Maven you find here .
After you run the maven install you have a library called
sam.openid-x.x.x.jar
Copy this jar into your glassfish/lib folder. Thats it.
You can now configure a new HTTP Messaging Provider as described here. The provider class name for the OpenID Autentification Module is : com.sun.security.sam.openid.OpenIDServerAuthModule
Sonntag Okt 12, 2008
Glassfish and OpenID
Currently I am working on a solution to authenticate users with an OpenID in a JEE Application running on Glassfish. I need this Integration for a Workflow Application using the IX JEE Worklfow.
After searching for java based OpenID Solutions for Web applications I come to the end that the JRS-196, Java Authentication Service Provider Interface
for Containers is one of the most auspicious solutions for JEE and Glassfish. But its not easy in the moment to find a running modul on this technologie. There is a very important blog about the concepts behind JRS-196 from Ron Monzillo. And also there I started a discussion in the java.net forum about the best way of integration. I will update my results in this blog the next time.
Sonntag Sep 14, 2008
Debugging Glassfish with Eclipse
To use remote debugging in eclipse in conjunction with Glassfish there only two configuration steps necessary:
1.) enable the Debugging in the Glassfish Server Configuration
- Open the Web Console and choose menu "Application Server".
- go to the Tab "JVM Settings"
- enable the Debug mode
2.) In your Eclipse you need a extra Debug Program Configuration
- Choose in your Eclipse the Menu "Run -> Debug..."
- create a new "Remote Java Application" for example "Glassfish Debuger"
there you cann edit the Projekt and also the remote Port of the System. you need to change form 8000 to 9009.
Now you can start the Debug Mode from your eclipse by running "Debug->Glassfish Debugger"
See also the following blog
http://www.diotalevi.com/weblog/2007/02/17/debugging-glassfish-with-eclipse-reloaded/
Sonntag Jul 06, 2008
using JNDI MailSession in Glassfish
Today I played around a long time figuring out how to lookup a Java Mail Session out of a EJB from Glassfish. This is the link which finaly helps me through:
http://forums.java.net/jive/thread.jspa?messageID=260133𿠥
before I read a lot of pages like:
https://glassfish.dev.java.net/javaee5/docs/DG/beaow.html
http://forums.java.net/jive/thread.jspa?messageID=265263񀰯
The problem for me was the lookup like thisone:
Context ic = new InitialContext();
Session session = (Session)ic.lookup("java:comp/env/mail/testSession");
To avoid a :
javax.naming.NameNotFoundException: No object bound to name java:comp/env/mail/testSession
it is importend to add the right name mapping to the ejb-jar.xml and also to the sun-ejb-jar.xml
to the ejb-jar.xml add the following code to that EJB which makes the lookup:
<resource-ref>
<res-ref-name>mail/testSession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
And to the sun-ejb-jar.xml file add the following to the same EJB
<resource-ref>
<res-ref-name>mail/testSession</res-ref-name>
<jndi-name>testSession</jndi-name>
</resource-ref>
Notice that this is only necessary to perform a jndi lookup. I think you can save oneself this using dependency injection using annotations (@ressource)