Blogs by topic J2EE and user ss141213
| • Accessibility | • Ajax | • Blogging | • Business | • Community |
| • Databases | • Deployment | • Distributed | • Eclipse | • Education |
| • EJB | • Extreme Programming | • Games | • GlassFish | • Grid |
| • GUI | • IDE | • Instant Messaging | • J2EE | • J2ME |
| • J2SE | • Jakarta | • JavaFX | • JavaOne | • Jini |
| • JSP | • JSR | • JXTA | • LDAP | • Linux |
| • Mobility | • NetBeans | • Open Source | • OpenSolaris | • OSGi |
| • P2P | • Patterns | • Performance | • Porting | • Programming |
| • Research | • RMI | • RSS Feeds | • Search | • Security |
| • Servlets | • Struts | • Swing | • Testing | • Tools |
| • Virtual Machine | • Web Applications | • Web Design | • Web Development Tools | • Web Services and XML |
EJB

Here is an example of OSGi/JMS/MDB comprising of two OSGi bundles deployed in GlassFish:
a) A JMS message producer bundle
b) A JMS message consumer bundle

I will wrap up my experience at eclipsecon. I will also point to my slides and sample source code that shows how to develop EJBs as OSGi service.

As promised earlier, I am going to quickly go over the key points I gathered from the talks I attended at eclipsecon and I also want to brief you about my topic at the conference. Because of a migrane attack earlier today which I firmly believe was caused by severe jat lag, I could not attend as much on day #2 as I had earlier decided to, and that's the very reason why I will keep...
Web Services and XML

Recently a user in GlassFish forum asked about developing JAX-WS web service in an OSGi bundle. Here is a complete sample demonstrating the same. You can download it from here.
As the above diagram shows, we have three components, viz:
1) osgi-service.jar: This is an OSGi bundle which provides a service to other bundles. It contains two POJOs, viz:
a) an interface called sahoo.hybridapp.jaxws1.service.Watch
b) an implementation of the same interface called sahoo.hybridapp.jaxws1.service.WatchImpl.
This bundle also contains a bundle activator called sahoo.hybridapp.jaxws1.service.Activator, which is responsible for registering an instance of WatchImpl in OSGi service registry.
2) web-service.war: This is a Web Application Bundle. A Web Application Bundle is a hybrid application - it's both a Java EE archive as well as an OSGi bundle. In this case, it is a war file as well as an OSGi bundle. It's a war file, because it contains a Servlet based JAX-WS end point. It's an OSGi bundle, because we want to make use of OSGi service in the implementation of our web service. It contains a single class called sahoo.hybridapp.jaxws1.webservice.WatchWebService which is defined like this:
The MANIFEST.MF of web-service.war looks like this:
3) web-service-client.jar: This is a plain jar file which makes use of JAX-WS stack of Java SE environment to invoke our web service. It has a single class called sahoo.hybridapp.jaxws1.webserviceclient.Main. The rest of the classes that are part of this jar are generated by wsdl compiler as part of build.
How to build, deploy and test:
Step 1: Start GlassFish
Step 2: Build and deploy the service bundles
mvn clean install
This will produce two OSGi bundles called osgi-service/target/osgi-service.jar and web-service/target/web-service.war. Deploy these two OSGi bundles to GlassFish by simply copying them to domain1/autodeploy/bundles/ dir as shown below:
cp osgi-service/target/osgi-service.jar web-service/target/web-service.war $glassfish.home/domains/domain1/autodeploy/bundles/
GlassFish will automatically detect that web-service.war is a WAB and will perform necessary deployment of EE artifacts as a result of which a web service end point will be available. You can see something like this appearing in server.log:
WS00018: Webservice Endpoint deployed
WatchWebService listening at address at http://localhost:8080/hybridapp.jaxws1.web-service/WatchWebServiceService
Step 3: Build and run the client
Once the web service is available, run
mvn -f web-service-client/pom.xml
to build web-service-client.jar. This is because the WSDL url, as specified in web-service-client/pom.xml, is not available until the web service is deployed.
To test, simple run:
java -jar web-service-client.jar
You shall see it will print the current time as obtained from the web service which in turn obtrains it from the OSGi service.
Enjoy developing OSGi enabled Java EE applications in GlassFish.
Programming

I was at an OSGi event last week and got to meet a number of OSGi experts. I will share my experience here. I will also brief about the kind of support we have in GlassFish for enterprise OSGi users. Check out our talk on this subject at eclipsecon 2010.

Since GlassFish v3 is built on top of OSGi, it is already capable of being embedded in an existing OSGi runtime. The bootstrapping code was slightly complicated IMO. Recently when Apache Camel committer Charles Moulliard asked me some questions around embedding GlassFish v3 in an OSGi runtime, I decided to revisit the bootstrap module in order to simplify it so that I had less explaining to do. I recently did exactly that. In this blog, I show how using a simple BundleActivator, one can embed GlassFish in an OSGi runtime.
J2EE

autodpeloy-bundles directory has been moved to autodeploy/bundles. In my earlier blog titled Using filesystem operations to manage OSGi bundles in GlassFish, I had mentioned the directory name to be ${domain_dir}/autodeploy-bundles/. Based on feedback from co-developers and users, I have moved it to ${domain_dir}/autodeploy/bundles/. As you may be knowing, ${domain_dir}/autodeploy is already...

Learn how you can use REST APIs to administer OSGi runtime in GlassFish.

In this short article, I will tell you how we found framework extension bundle a useful concept while developing GlassFish V3 to run on OSGi.

Java Persistence API specification requires its users to not only provide a persistence.xml file but also enumerate managed persistence class names in that file. In this article, I talk about a Java compiler plugin that can create the persistence.xml file for you automatically during normal course of Java code compilation and show how easy it is to use in your existing build scripts - be it maven or ant or shell script.

FOSS.IN is one of the world's largest and most focussed FOSS events, held annually in India. GlassFish team of Sun Microsystems, which participate in one of the most important open source efforts initiated by Sun Microsystems, will not only talk about GlassFish & Java EE platform, but will also have a live demo running at their booth. This blog gives details about the demo that's going to be shown their.

While using Java Persistence API in an enterprise application, there is often a need to access access entities in the same persistence context in different components involved in a particular request. Using a very simple Java EE application, this article shows how to achieve this in an elegant and portable way. The technique described here is completely portable across any Java EE 5 compatible application server because it uses a standard feature called *persistence context propagation*.

Pluggability of third party Java Persistence API providers into a Java EE container offers Java EE users exciting combinations to use. Earlier we had shown how to use Hibernate and Kodo in GlassFish. Now it's time for OpenJPA. I thought I shall give a try using it in GlassFish. This blog reinforces the fact that it could not be easier to plug in a third-party persistence provider in GlassFish.

Pluggability of third party Java Persistence API providers into a Java EE container offers Java EE users exciting combinations to use. Earlier we had shown how to use Hibernate in GlassFish. Now it's time for Kodo, which is another high performance & popular O/R mapping solution. Recently Kodo 4.0GA was released and it supports Java Persistence API. So, I thought I shall give a try using it in GlassFish.

Some of the recent postings in the GlassFish forum suggest that there is some confusion in the GlassFish user community about which GlassFish build to use. This is largely because of activities happening in more than one branch in CVS. I will try to respond to the confusion here.

The Java Persistence API is the standard API for the management of persistence and object/relational mapping in Java EE 5 platform. It can be used in three types of containers, viz: ejb container, web container and application client container. In this blog, we will talk about using this API in application clients. We also discuss two different way of packaging the application.

A number of folks have asked me question about using Hibernate in GlassFish. Read on to know the state of things...

In this article we will talk about developing and using JSP tags to access database using Java Persistence API in a web application. It includes a complete sample as well as a tag library with a handful of ready to use custom tags. It also shows how to inject persistence context into JSPs.

It's a common mistake to inject an EntityManager into a web application that uses Java Persistence API. Let's discuss why?

It's a walk through for using Java Persistence API in a multi-tier (web->ejb->db and appclient->ejb->db) Java EE application in a portable way. This example also shows how simple it is to write web applications and application clients that invoke EJBs in Java EE 5 platform. More over this article also talks about a portable way to package common classes using the new library directory facility of Java EE 5 platform.



