JAXB with XML:-                                                                                                                                                                 Back

Guess what! I and my team mate Neha tried hands in JAXB and XML in the office for the past two days and it worked today!!!! he he... Its a simple test program. The outline of the program goes like this:

We created an XML file called cust.xml which had details of the customer. A stand alone program called sample.java is created to marshall and unmarshall the xml file.

unmarshall - converting xml file to java objects and classes                                                                                                                                                                 Download file

marshall - reverse of unmarshall                                                                                         

Click on download file to get more details on how it works...

 Problem Faced:

         When we created the cust.xml and sample.java and when we tried executing the program, it showed an error saying 'Launch error'. When we contacted our mentor in our office, he solved the problem. The problem was that we need to create a seperate package for the sample.java and execute it. tats why we have to make a seperate package for sample.java in the project.

          Now u might ask what does build_test.xml and test.xsd do in this project.

test.xsd creates the schema of the customer type and build_test.xml is the xml file to create java classes and object and compiles all the classes created. We created folders for source, library and binary files as src, lib and bin respectively so that it is easy to store the files in the appropriate folder.

 

Don't Use System. out.println!(Log4J)

             So far, we have been using the buzz word “System. out. println” in our application to test if the particular piece of code works and for many more reasons.  Inserting log statements into code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is usually the case for multithreaded applications and distributed applications at large.

             This is were the log4J stands! Loggers are named entities... "A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the descendant logger."

              Log4J has 3 components: Categories, Appenders and Layouts.. We instantiate a category and add appenders to it and call various logging methods to describe string to the log.A category is configured to log one or more destination or target. The destinations are called as Appenders. These appenders uses the layout to format the message output that we are printing.

              In addition, there are five priority constants where we assign priority to the application. The priority range as follows:

                                         DEBUG < INFO < WARN < ERROR < FATAL

              In addition to this, log4j.properties file is very much important to create a log4j project. We describe the categories,appenders and layouts in the property file and place it in the root path of the class we are executing our project.

               For more details, u can click the download link. There are presentations and materials to read about log4j. An example link is also provided to have a look at it also.

Note: You can place the java files in a package and add the properties file as an external jar.

 Download material                       Download Example

 

 LDAP:              

              The Lightweight Directory Access Protocol (LDAP) defines a message protocol used by directory clients and directory servers. The LDAP protocol uses different messages. LDAP is an open industry standard that defines a standard method for accessing and updating information in a directory. LDAP has gained wide acceptance as the directory access method of the Internet and is therefore also becoming strategic within corporate intranets.

    To get more details on LDAP and its practical experience, click on link 

 

    Problem Faced:

 

                   If you come across a pop up saying that server must be stopped while importing an file, go to services and stop the IBM Tivoli Directory Server.