Blog

[Lab-Analysis] Deploying a Bottum-up SOAP Web Service in Glassfish Server from Eclipse

We will quickly review the results of the lab @ http://javajee.com/lab-deploying-a-simple-soap-web-service-in-glassfish-....

 

The Web Service

We had deployed the below simple web service in Glassfish server using eclipse and all it took was to use an annotation @WebService to make it a web service. 

package com.javajee.webservices.soap;

[Lab] Deploying a Bottum-up SOAP Web Service in Glassfish Server from Eclipse

Prerequisites

Before trying out this example, you will need to download and install Java EE 7 SDK which comes with GlassFish Open Source Edition 4 (currently 4.1.1) and then configure eclipse to deploy Java EE applications directly to GlassFish Server.

For details, refer to http://www.javajee.com/configuring-glassfish-server-4-with-eclipse-to-bu....

 

Configuring Glassfish Server 4 with Eclipse to Build, Test, and Deploy Java EE 7 Applications

We will download and install Java EE 7 SDK which comes with GlassFish Open Source Edition 4 (currently 4.1.1)and then configure eclipse to deploy Java EE applications directly to GlassFish Server. You can download the latest Java EE 7 SDK from http://www.oracle.com/technetwork/java/javaee/downloads/index.html. You can also directly download the latest commercially supported GlassFish Server distribution (currently 3.1.2.2) from the same link.

Handling Exceptions in Java

We can handle exceptions using the try-catch-finally construct or explicitly tell as being handled elsewhere through the use of throws clause in that method signature.

The try-catch-finally block will look as below:

try{

//Some code that can throw IOException

}

catch(Exception ex)

{

//do some workaround.

Java 7 New Exception Features - Multicatch Exceptions and Try with Resources

Java 7 introduces few new features to the exception handling mechanism. We will discuss them quickly here.

 

Java 7 Multi-Catch Exceptions

With java 7, you can catch multiple exceptions using a single catch block as:

    try {

      File file = new File("filename.txt");

      Scanner sc = new Scanner(file);

      throw new SQLException();

    }

    catch (FileNotFoundException | SQLException e) {

Querying Using Criteria API in Hibernate 4.3

Hibernate provide Criteria Queries as an object-oriented alternative to HQL. Criteria Query is used to modify the objects and provide restriction for the objects. Many complex queries in HQL or even SQL may become larger over a period of time and spread over many lines; and will be difficult to update and maintain. We have already seen HQL in http://javajee.com/introduction-to-hibernate-query-language-hql-in-hibernate-43.

Named Queries in HQL with hibernate 4.3

We can have queries saved with a name and later we can retrieve them simply using that name. We use @NamedQuery annotation to declare a named query. We can also have a named query for native sql. For native SQL we use the annotation @NamedNativeQuery annotation. This is one of the important advantages of having a named query: you can write native SQL. You can retrieve a Query object from a saved query name (hql and native named query) using session.getNamedQuery method.

Parameter Binding in HQL using hibernate 4.3

Parameter binding is the process of binding a Java variable with an HQL statement. Using Parameter binding and not string concatenation for HQL statement creation will also guard against attacks like SQL injection.

Introduction to Hibernate Query Language (HQL) in hibernate 4.3

Hibernate provides a query language called Hibernate Query Language (HQL). HQL is similar to SQL in syntax, but HQL queries are written against Hibernate's entity objects, not database tables. Hibernate also provide Criteria Queries as an object-oriented alternative to HQL. Criteria Query is used to modify the objects and provide the restriction for the objects. Here we will see the basics of HQL and later in another tutorial we will see criteria queries.

Inheritance Strategies in Hibernate 4.3

Hibernate uses following strategies for saving an inheritance hierarchy of classes created in Java to the databases: SINGLE_TABLE, TABLE_PER_CLASS and JOINED.  

We can use @Inheritance annotation over the entity class to specify the inheritance strategy.

We specify the inheritance strategy by assigning a strategy from the InheritanceType enumeration to the strategy parameter of the @Inheritance annotation.  

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!