Friday, March 30, 2007

Build EJB3 with Maven 2

I'm Maven newbie. I'm very happy that I have found a way to compile EJB 3 with Maven. Here is my recipe :) Actually it isn't mine (It is came from the book "POJO's in Action" source code example), but I hope that my post will be useful for somebody. Maven is complex and it is something like new religion ;)

I have JBoss EJB 3 embeddable alpha and want to built my EJBs with Maven 2. What should I do ? The way of adding some third-party jars is a kind of challenge :) Official docs is here. In practice it's looks like this :

set EJB3_LIB=C:\server\jboss-EJB-3.0_Embeddable_ALPHA\lib
call mvn install:install-file
-DgeneratePom=true
-Dfile=%EJB3_LIB%\antlr-2.7.5H3.jar
-DgroupId=jboss-ejb3-embeddable_alpha3
-DartifactId=antlr-2.7.5H3
-Dversion=1.0alpha3 -Dpackaging=jar
And then a lot of almost identical calls for every jar file in EJB3_LIB directory. Full *.cmd file is long and I don't want to list it here.

Resulting POM file is :
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.mycoolcompany</groupId>
<artifactId>Maven2-EJB3-Compile</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>EJB 3 Compile with Maven 2</name>
<url>http://localhost</url>
<dependencies>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>antlr-2.7.5H3</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>asm-attrs</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>asm</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>cglib-2.1.1</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>commons-collections</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>commons-logging-api</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>concurrent</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>dom4j</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>hibernate3</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>hsqldb</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>javassist</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-aop-jdk50</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-aspect-library-jdk50</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-common-jdbc-wrapper</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-common</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-container</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-dependency</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-ejb3</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-ejb3x</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-j2ee</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-j2se</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-jca</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-local-jdbc</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-microcontainer</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-remoting</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-system</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-transaction</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss-xa-jdbc</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jboss</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jbossmq</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jbosssx</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>jnpserver</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>log4j</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>resolver</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>trove</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>xercesImpl</artifactId>
<version>1.0alpha3</version>
</dependency>
<dependency>
<groupId>jboss-ejb3-embeddable_alpha3</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0alpha3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

Don't tell me that maven is easier than Ant... I hope that there is a more elegant
way to build EJBs with Maven.

UPD

Complete example with source code is here : http://code.google.com/p/ostas-blog-src/

Thursday, March 29, 2007

ASP.NET and Tomcat

Sometimes you can get a lot of fun even reading serious things like Tomcat user mailing list :) Here is example:

Q: Is it possible somehow for Tomcat to serve ASP.NET pages?
A: Easy to simulate, Add Thread.Sleep(10000) and then print a blue screen....

What I can say ? Just LOL ! :)

Tuesday, March 27, 2007

EJB3 : view from Ethereal

Exploring something new is exciting thing. How does EJB looks like from the view of networking ? Can I catch a result of remote EJB method invocation as plain String ? So, my experiment... Yep, it is dummy but I never tried it by myself.

I have 2 computers : A and B, both in the same sub net (192.168.3.*). There is some very-very simple stateless session bean deployed at machine A :

package com.mycoolcompany.Beans;

import javax.ejb.Stateless;
import com.mycoolcompany.Beans.MySession;

@Stateless
public class MySessionBean implements MySession {
public String someLogicForRemoteInterface()
{
return "This_is_a_string_to_catch";
};
}
Application server is jBoss- 4.0.4 GA. The EJB client is on B. Ethereal is also at B. It will be more interesting to place sniffer at 3-rd computer, but I haven't such ability.
Take a look at result :


So, as you can see "This_is_a_string_to_catch" has catched successfully.

Monday, March 26, 2007

AJAX Controls

AJAX is pretty nice thing ! Yet another site with AJAX controls is here. It is just controls... but I remember the time when I saw a bindows demo for a first time ;) Desktop application in FF ! :)

Sunday, March 25, 2007

3D Desktop

It seems to be that desktop of future will be 3D. XGL extensions for X server, Microsoft Vista, Mac... Another interesting idea is here.

Monday, March 12, 2007

Maven2 : to be or not to be ?

I'm using Ant as a build system and very happy :) But I see that more and more people switching to Maven 2. Maybe it is make sense to do such migration for a team of developers... but I'm not sure how about standalone developer (me). According to maven people, one of maven advantages is that pom.xml is rather shorter than equivalent build.xml. OK. But, friendly speaking, I haven't a lot of issues with dependencies and versions of third-party jars. I'm not sure that listing jars from a to z is easier than setting classpath in build.xml

But... declarative project management sounds cool. Reports, site generation, JUnit reports. I'll give it a try. Lets see how I can benefit from using "Convention Over Configuration" concept.

Tuesday, March 06, 2007

ASP.NET at Google

I don't believe my eyes ! :) Take a look here. survey.google.com, aspx... wow ! It is really IIS !
Http response looks like this

HTTP/1.1 200 OK
Cache-Control : no-cache
Content-Language : en
Content-Length : 37786
Content-Type : text/html; charset=iso-8859-1
Date : Tue, 06 Mar 2007 09:50:23 GMT
Expires : -1
Pragma : no-cache
Server : Microsoft-IIS/6.0
X-AspNet-Version : 2.0.50727
X-Powered-By : ASP.NET

Why not Python or something like that ?

Is AdSense so cool ?

Google AdSense seems to be the most profitable affiliate campaign for publisher. So profitable, that some people using AdWords campaign to promote their AdSense farm !

Of course I can be wrong, but how would you comment this ? www-Communications.com looks like
www.Communications.com. Text is "Everything You Need to Know About Covad Communications". I had missed it at the first time ! :)

I'm fan of Google, but in this case it sucks !