Archive

Archive for the ‘Web’ Category

Atmosphere : Resin and Websockets

August 10, 2010 Leave a comment

I want to let you know that since the release of Caucho Resin 4.0, Atmosphere applications can be deploy on Resin and will be supported natively. Resin 4.0 implements Servlet 3.0.

That’s really good. Another web server that is supported.

What about the Websocket’s Caucho implementation… nah ! There implementation is too buggy right now. I suppose the code it using a early release of the Websocket specs, and never updated it. Anyway, Websocket application won’t work on Resin 4.0 :(

We posted a thread on there forum here : http://forum.caucho.com/showthread.php?t=10680

but still didn’t received news from them. So until they fix it, I suggest that you try your Websocket application on another web server like Glassfish.

You can follow me on Twitter

Native Websphere support for Atmosphere not yet

August 9, 2010 Leave a comment

Just a little note that we try to add Websphere native support for Atmosphere. We work really hard to find an API that could allow us to do that, but is simply impossible.

We were able to get in touch with the dev team of Websphere and the dev team of WebSphere Application Server Feature Pack for Web 2.0. They have demo that used bayeux for comet application or JMS to simulate asynchronous connections, but it’s not a complete asynchronous solution.

Even with the addon WebSphere Application Server Feature Pack for Web 2.0, you can’t suspend and resume a connection. Websphere server doesn’t support that. It’s not supported in WAS 7.0, but in 8.0 alpha there should be Servlet 3.0 support.

Until IBM do something about that, or wait for WAS 8.0, you will still be able to deploy Atmosphere application on WAS but it will use BlockingIO (one blocking thread by connection).

If that is not enough for you, I suggest Glassfish as alternative. Of course, we will continue to monitor the situation. Maybe the community call could be enough to wakeup them :)

You can follow me on Twitter

Native Websphere support for Atmosphere not yet

August 9, 2010 Leave a comment

Just a little note that we try to add Websphere native support for Atmosphere. We work really hard to find an API that could allow us to do that, but is simply impossible.

We were able to get in touch with the dev team of Websphere and the dev team of WebSphere Application Server Feature Pack for Web 2.0. They have demo that used bayeux for comet application or JMS to simulate asynchronous connections, but it’s not a complete asynchronous solution.

Even with the addon WebSphere Application Server Feature Pack for Web 2.0, you can’t suspend and resume a connection. Websphere server doesn’t support that. It’s not supported in WAS 7.0, but in 8.0 alpha there should be Servlet 3.0 support.

Until IBM do something about that, or wait for WAS 8.0, you will still be able to deploy Atmosphere application on WAS but it will use BlockingIO (one blocking thread by connection).

If that is not enough for you, I suggest Glassfish as alternative. Of course, we will continue to monitor the situation. Maybe the community call could be enough to wakeup them :)

You can follow me on Twitter

Grizzly Deployer (1.9.19) new features

August 7, 2010 Leave a comment

It has been a while since a blog about Grizzly, I was too busy adding new features. The Grizzly Deployer’s community grows and requested theses new features.

Here a quick list of the changes :

  • Websockets support
  • Watch folder
  • Can starts without applications to deploy
  • Can be embedded and extended easily
  • and few bug fixes (thanks to the community)

A little overview or remainder of what is Grizzly Deployer

Grizzly Deployer is a bundle of Grizzly project that act as a web container. It will allow you to deploy applications (war, servlet).
Works fine for Comet, Atmosphere, JSP applications … For more details, I suggest this link Introduction to the first release of Grizzly Deployer

First, lets take a look at the command line parameters.


Usage: com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer

  -a, --application=[path]    Application(s) path(s).

                              Application(s) deployed can be :
                              Servlet(s), war(s) and expanded war folder(s).
                              To deploy multiple applications
                              use File.pathSeparator

                              Example : -a /app.war:/servlet/web.xml:/warfolder/

  -p, --port=[port]           Runs Servlet on the specified port.
                              Default: 8080

  -c, --context=[context]     Force the context for a servlet.
                              Only valid for servlet deployed using
                              -a [path]/[filename].xml

  --dontstart=[true/false]    Won't start the server.
                              You will need to call the start method.
                              Useful for Unit testing.
                              Default : false

  --libraryPath=[path]        Add a libraries folder to the classpath.
                              You can append multiple folders using
                              File.pathSeparator

                              Example : --libraryPath=/libs:/common_libs

  --autodeploy=[path]         AutoDeploy to each applications.
                              You could add JSP support.
                              Just add a web.xml that contains Jasper

                              Example : --autodeploy=/autodeploy

  --webdefault=[path]         webdefault to be used by all applications, can be file or dir with multipe web.xmls.
                              If you want to add only one webdefault point it to web.xml file,
                              If you want multiple files to be included put them in one dir and provide this location here.

                              Example : --webdefault=webdefault.xml

  --cometEnabled=[true/false] Starts the AsyncFilter for Comet.
                              You need to active this for comet applications.
                              Default : false

  --websocketsEnabled=[true/false] Starts the AsyncFilter for Websockets.
                              You need to active this for websockets applications.
                              Default : false

  --forceWar=[true/false]     Force war's deployment over a expanded folder.
                              Will deploy the war instead of the folder.
                              Default : false

  --ajpEnabled=[true/false]   Enable mod_jk.
                              Default : false

  --watchInterval=[seconds]   Watch interval to scan for new applications to deploy in work folder.
                              Default : -1 ; disabled

  --watchFolder=[path]        Folder to scan for new applications to deploy in work folder
                              Default : none

Websocket support

The first feature added was Websockets support. It can be enabled at command line by using the parameter --websocketEnabled=true . That will allow you to deploy Websocket applications.

Watch folder

This feature is interesting, because most of the web container have it. Grizzly Deployer will watch a specific folder to applications to deploy. When this feature was added, I remove the need to specify a application to deploy by command line.
To enable this feature you need to use the command line parameter --watchFolder=[path]. It can be used with this other parameter : --watchInterval=[seconds].

The parameter --watchInterval is used to create a watchdog that will monitor the watch folder. If the parameter --watchInterval is not present, when Grizzly Deployer starts, it will check
all applications that are in the watch folder at launch time and will deploy them, but it won't monitor the folder after that.

When both of theses parameters are used, it will create a watchdog that will deploy and undeploy application put in the watch folder, and remove from that folder. If you deploy an application at command line and put another application with the
same context name in the watch folder, the application in the watch folder won't be deploy twice.

Embedded Grizzly Deployer

Grizzly Deployer could already be embedded trough his API, but we got few feedback about to make it simplier. The problem wasn't the API, it just that most people will only use the main part of Grizzly Deployer : deploy a war.

So to make it easier and faster to implement, I did a little refactoring. We now have 2 main config classes we could use to launch an Embedded Grizzly Deployer : DeployerServerConfiguration and DeployableConfiguration.

DeployerServerConfiguration

That file is used to launch Grizzly Deployer. It contains the same command line parameters. In fact, at runtime, the command line parser use that classe.


    GrizzlyWebServerDeployer deployer = new GrizzlyWebServerDeployer();
    
    DeployerServerConfiguration conf = new DeployerServerConfiguration();
    conf.cometEnabled = true;
    conf.watchFolder="C:/temp/webapps/";
    conf.watchInterval=15;
    deployer.launch(conf);                             

Once grizzly Deployer is launched in your application, you can deploy a war later. For that, you use this class : DeployableConfiguration.


    DeployableConfiguration warConfig = new DeployableConfiguration();  
    warConfig.location = "C:/temp/webapps/grizzly-jmaki.war";
    
    deployer.deployApplication(warConfig);                           

You can follow me on Twitter.

Categories: Grizzly, Web Tags: , , ,

GWS Deployer 1.9.17 : Reloaded : New Features Part 3 : PHP Support

May 24, 2010 Leave a comment

In a previous post : PART2 I describe how to run JSP over Grizzly. Now I’ll show you how to run PHP over Grizzly.

here a sample web.xml file for PHP support. (I’m using Quercus, but you could use native PHP too).


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<description>Caucho Technology's PHP Implementation</description>

<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.php</welcome-file>
</welcome-file-list>

</web-app>

The last step is to put the required jars into the classpath.
You could put them in the command line with -cp or --classpath or you could use Deployer's param :

--libraryPath=[path]

Example : --libraryPath=/libs:/common_libs

With that you can have PHP support only if you want.

Follow us on Twitter

Categories: Grizzly, Web Tags: , , ,

GWS Deployer 1.9.17 : Reloaded : New Features Part 2 : JSP Support

May 24, 2010 Leave a comment

Grizzly Deployer got lot of activity recently over mailing list, so I took the time to give you a new feature
that been added to the release 1.9.17. The Autodeploy command.

You should see that option like a default web.xml config that will be append to all your webapps
that you will deploy. You can activate this feature by adding this param to the command line :

java -jar grizzly-http-servlet-deployer-1.9.18-SNAPSHOT.jar –autodeploy=[path]

Example : –autodeploy=/folder/autodeploy

You need to create one of more web.xml files that you will put in that folder. Each web.xml config will be append to all your webapps.

here a sample for JSP support using Jasper.


<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>

</web-app>

The last step is to put the required jars into the classpath.
You could put them in the command line with -cp or --classpath or you could use Deployer's param :

--libraryPath=[path]
Example : --libraryPath=/libs:/common_libs

With that you can have JSP support only if you want.

Follow us on Twitter

Categories: Grizzly, Web Tags: , , ,

GWS Deployer 1.9.17 : Reloaded : New Features Part 1

May 24, 2010 Leave a comment

It has been a while since my last post, but I’m back :)

I worked hard on new features that will bring GWS Deployer to another level. You can check the features that were there before 1.9.17 in my previous post here

It will be easier to list the new features by looking at the command line parameters.


Usage: com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer

--application=[path]* Application(s) path(s).
--port=[port] Runs Servlet on the specified port.
--context=[context] Force the context for a servlet.
--dontstart=[true/false] Won't start the server.
--libraryPath=[path] Add a libraries folder to the classpath.
--autodeploy=[path] AutoDeploy to each applications
--cometEnabled Starts the AsyncFilter for Comet
--forceWar Force war's deployment over a expanded folder.
--ajpEnabled Enable mod_jk.
--help Show this help message.
--longhelp Show detailled help message.

* are mandatory

The first new parameter is : --longhelp

This parameter will give a better explanation and default values.

 
java -jar http-servlet-deployer-1.9.17-SNAPSHOT.jar --longhelp


Usage: com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer

-a, --application=[path]* Application(s) path(s).

Application(s) deployed can be :
Servlet(s), war(s) and expanded war folder(s).
To deploy multiple applications
use File.pathSeparator

Example : -a /app.war:/servlet/web.xml:/warfolder/


-p, --port=[port] Runs Servlet on the specified port.
Default: 8080

-c, --context=[context] Force the context for a servlet.
Only valid for servlet deployed using
-a [path]/[filename].xml

--dontstart=[true/false] Won't start the server.
You will need to call the start method.
Useful for Unit testing.
Default : false

--libraryPath=[path] Add a libraries folder to the classpath.
You can append multiple folders using
File.pathSeparator

Example : --libraryPath=/libs:/common_libs

--autodeploy=[path] AutoDeploy to each applications.
You could add JSP support.
Just add a web.xml that contains Jasper

Example : --autodeploy=/autodeploy

--cometEnabled=[true/false] Starts the AsyncFilter for Comet.
You need to active this for comet applications.
Default : false

--forceWar=[true/false] Force war's deployment over a expanded folder.
Will deploy the war instead of the folder.
Default : false

--ajpEnabled=[true/false] Enable mod_jk.
Default : false

Default values will be applied if invalid values are passed.

* are mandatory

Follow us on Twitter

Categories: Grizzly, Web Tags: ,

New Grizzly enhancement : Servlet AutoDeployer

May 24, 2010 Leave a comment

We got something really cool for Grizzly. It’s a Servlet AutoDeployer for GrizzlyWebServer.

Now that it said.. let’s talk more about that.

When you have servlets, you will need a AppServer or a WebServer to deploy your applications. Nothing new there.. it’s a been like that for years. Mostly you had to create a web.xml, put that in a war and deploy it.

There are others alternatives, like using GrizzlyWebServer, but you will have to put your web.xml into code.


GrizzlyWebServer ws = new GrizzlyWebServer(80);

try {
ServletAdapter sa = new ServletAdapter();
sa.setContextPath("/");

// need to load JspRuntimeContext
Class.forName("org.apache.jasper.compiler.JspRuntimeContext");

Servlet servlet = (Servlet)ClassLoaderUtil.load("ca.sebastiendionne.welcome_jsp");
sa.setServletInstance(servlet);

ws.addGrizzlyAdapter(sa, new String[]{});
ws.start();
} catch (Exception e){
s_logger.error("Error Launching GrizzlyWebServer",e);
}

What's wrong with that ?

In my point of view.. it's not efficient. I don't want to use a WebServer to deploy a simple servlet and I don't want code what I could simply extract from a config file.

That why a servlet autodeployer could be useful. Yes a WebServer or AppServer do that already, but like I said.. you can skip it and go for a smaller and faster solution.

The GrizzlyServletDeployer (or the super fast and super easy thing for GrizzlyWebServer) will do everything for you.

In one simple command line you can deploy multiple applications.

Let's take a look at the command line first.

java -jar grizzly-servlet-deployer-1.9.11-SNAPSHOT.jar [options]

where options are :

-p : the port [default 8080]
-a : applications to deploy (everything is done from that)

You can deploy many things from the option "-a" (servlets, war, multiple wars, expanded wars). Let's decribe what can be done.

Syntax examples :

# 1 : Deploy a war

java -jar grizzly-servlet-deployer-1.9.11-SNAPSHOT.jar -a c:/temp/hudson.war

That will deploy the war file. The same way a WebServer will deploy it. The web.xml will be read and the servlets will be deployed.

The context will be the war file. In this example : http://localhost:8080/hudson/

#2 - Deploy a expanded war.

java -jar grizzly-servlet-deployer-1.9.11-SNAPSHOT.jar -a c:/temp/hudson

Your application could be a expanded war, or have the same hierarchy.

That will give the same result as #1

#3 Deploy servlets

java -classpath myservlet.jar;.;grizzly-servlet-deployer-1.9.11-SNAPSHOT.jar com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer -a web.xml
You can skip the step to create a war file if you want. Simply declare a web.xml and put the jars into the classpath (in this case the servlet is in myservlet.jar)

The context will be the default "/"

http://localhost:8080/

#4 - Deploy multiples war in the same time.

This one is more advanced. It will deploy all the war files or expanded wars that are in a root folder.

java -jar grizzly-servlet-deployer-1.9.11-SNAPSHOT.jar -a /MultipleWarFolder

(yes it's the same syntax as #2)

Example :

Here what the folders will look like


...../MultipleWarFolder/
/freemarker
/WEB-INF
/classes/
/lib/
/templates/
/web.xml
hudson.war
struts2-showcase-2.0.12.war
cometd-demo.war
sebastiendionne-is-the-man.war

The folder /MultipleWarFolder contains 4 war files and 1 expanded folder.

Serlvet-Deployer will check all the folders in the root (/MultipleWarFolder) and check if it can apply #1 or #2.

If it find one that contains /WEB-INF/web.xml it will consider it as #2 (expanded war) and if it find a .war it will do #1 (war file).

The context for each application will be the folder name (freemarker) or the war file.

If you want to can use it in a testcase easily.


GrizzlyWebServerDeployer gws = new GrizzlyWebServerDeployer();

try {

args = new String[]{"-a","./web.xml"};

// ready to launch
gws.init(args);
gws.launch();

... launch your tests...

} catch (Exception e){
e.printStackTrace();
}

I think when you will start using that, you will love it :)

GrizzlyWebServer is really powerful and so small. It's a Asynchronous IO server that support multiples protocols : HTTP(s), Comet, PHP, JSP, Freemarker, AJP protocol (mod_jk) and more check (https://grizzly.dev.java.net/).

Categories: Grizzly, Web Tags: ,

Read web.xml with one line of code Part 2

May 24, 2010 Leave a comment

I did a <a href=”http://weblogs.java.net/blog/survivant/archive/2008/12/read_webxml_wit.html”>previous post</a> about how to do it with XMLBean or JABX, but it was more an example how to do it. This time is the real deal.

I used JABX to generate the java classes from the schemas and use that to parse the web.xml.

The result is a simple class : WebAppLoader that will load the web.xml.

Here a example :

WebappLoader webappLoader = new WebappLoader();
WebApp webapp = webappLoader.load(“/web-2.2.xml”);

The object WebApp contains all the infos extracted from the web.xml. The representation is based on webapp 3.0.

you can get the source code from my repository : <a href=”http://kenai.com/projects/sebastiendionne/sources/repository/show/dtd-schemas-generator”>http://kenai.com/projects/sebastiendionne/sources/repository/show/dtd-schemas-generator</a&gt;

Categories: Java Tools, Web Tags: , ,

JAXB : web.xml : dtd and xsd classes generator

May 24, 2010 Leave a comment

I created a little demo to show how easy it can be to create a kit of classes from DTD and XSD using Maven and JAXB.

To generate from XSD schemas

In your pom.xml, you will have to add this.


<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- if you want to put DTD somewhere else
<schemaDirectory>src/main/jaxb</schemaDirectory>
-->
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2-commons</groupId>
<artifactId>property-listener-injector</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

The important thing to know is that you have to generate your classes with one schema each time. If you put webapp schemas 2.2 and 2.3 in the same time,
you will obtain errors. Be sure to include all the files related to your webapp schema to generate your java classes.

Example : webapp 2.4 need
web-app_2_4.xsd
j2ee_1_4.xsd
jsp_2_0.xsd

You can even do some customization with a config file named : domain.jaxb (/src/main/resources).

To generate from DTD

In your pom.xml, you will have to add this.


<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- if you want to put DTD somewhere else
<schemaDirectory>src/main/jaxb</schemaDirectory>
-->
<extension>true</extension>
<schemaLanguage>DTD</schemaLanguage>
<schemaIncludes>
<schemaInclude>*.dtd</schemaInclude>
</schemaIncludes>
<bindingIncludes>
<bindingInclude>*.jaxb</bindingInclude>
</bindingIncludes>
<args>
<arg>-Xinject-listener-code</arg>
</args>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2-commons</groupId>
<artifactId>property-listener-injector</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

The DTD generation is the same pattern as XSD. The principal differences are in the pom.xml

You can download a complete project that use webapp xsd and dtd to parse any web.xml. It could be useful when you want to keep it simple :)

You can browse the code from : my Kenai repository

Categories: Java Tools, Web Tags: , ,
Follow

Get every new post delivered to your Inbox.