Premature end of file when running junits


Premature end of file error when running Junits

[junitreport] [Fatal Error] :-1:-1: Premature end of file.
[junitreport] The file /tmp/repository/Yogesh/task2652_story1984/modulesmgr/junit_report/out/xml/TEST-com.coresecurity.ctrlsvc.modules.ModulesImportAndBasicCRUDTest.xml is not a valid XML document. It is possibly corrupted.

1) TESTS-testsuites.xml was coming out to be empty.
2) The resulting xml file was getting too large in size.

Hibernate logging was enabled which was leading to large size of XML.
We disabled logging in config.xml as given below
Earlier it was true, we made it false


use OnClick with caution

JSP Code :

<a href="abc.jsp" onclick='’>LOGOUT

The above statement gets converted to Servlet CODE :

out.write("<a href="abc.jsp" onclick='");




What ever scriplet you write in onclick, will get executed every time the JSP is called. Not only on onclick as can be wrongly assumed.

BUG in struts2

Actually I used

Now, I have specified type as button, so I expected that it will not go to action on click on the button.

But what happens is

when I click on button, it asks if I want to close the window,
Now, even I click NO, it still goes to action specified in form.

Solution : This is a BUG in struts2.

the HTML tag that is generated is something like:

<button type="submit” id=”test_0″ value=”Submit” class=”button positive save”>Submit

Please note that we have given type=button in s:submit tag, and the HTML generated still contains type=submit.

Can get some information from

Internationalization tips for JSP

In order to display the complex script characters like Japanese, Chinese, etc in the browser window, the following changes need to be made at the beginning of each JSP file:

<%@ page language="java" 
contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

Wherever input controls are present, the following additional steps need to be taken:
Add the following code before reading any parameters in the previous JSP file:

request.setCharacterEncoding("UTF-8"); // Set the request encoding

While sending output to a browser:

response.setContentType ("charset=UTF-8");

Color of Error Messages in struts 2


I am working on struts 2.
I have one text field and have put validation (with xml)on the text field if its blank, throw an error.
But the field error I am getting is in black colour.
Does anyone have idea how to display the field error in red colour.


U can the use the following tag in your .css Stylesheet file

.errorMessage {
color: red;
font-size: 0.8em;

And include this Stylesheet in the file where u have the text field.

Source :

How to connect Hibernate with Microsoft Access

1. Go to Control Panel
2. Go to Administrative Tools
3. Go to ODBC Data sources
4. Create a DSN (say mydb), give the path to .mdb file.
5. Get hibernate.jar

6. Extract contents of and get Access_JDBC30.jar

7. Create a new Java Project in NetBeans 6.7 or greater. and give the above 2 jars in classpath of the project

8. Create the employee class inside demo package with the following contents

package demo;

import javax.persistence.Entity;
import javax.persistence.Id;

* @author Yogi
public class Employee implements Serializable {
int empId;
String empIbu;
String empName;
int empSalary;

public Employee() {
public String toString()
return empName;
public Employee(int empId, String empIbu, String empName, int empSalary) {
this.empId = empId;
this.empSalary = empSalary;
this.empName = empName;
this.empIbu = empIbu;

public String getEmpIbu() {
return empIbu;

public void setEmpIbu(String empIbu) {
this.empIbu = empIbu;

public int getEmpId() {
return empId;

public void setEmpId(int empId) {
this.empId = empId;

public String getEmpName() {
return empName;

public void setEmpName(String empName) {
this.empName = empName;

public int getEmpSalary() {
return empSalary;

public void setEmpSalary(int empSalary) {
this.empSalary = empSalary;


9. Create hibernate.cfg.xml in the root directory of the application (outside all packages)

<!-- Please note, here the value update is not working with MS-Access
Although it should work theoretically, but practically, the value
update is able to create the table for the first time
and after that it fails every time -->

10. Create file inside client package (Though not mandatory)

* To change this template, choose Tools | Templates
* and open the template in the editor.

package client;

import demo.Employee;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session;

* @author Yogi
public class EmployeeClient {
public static void main(String args[])
/* Here we have used AnnotationConfiguration because, we have used Annotations in
* Employee class to map the class fields with the table fields.
* If Employee.hbm.xml is used for this mapping then here we would have used
* Configuration (which we normally do)

SessionFactory factory=new AnnotationConfiguration().configure().buildSessionFactory();
Session session = factory.openSession();
Transaction tx=null;

Criteria c = session.createCriteria(Employee.class);
List l = c.list();
Iterator it = l.iterator();
// Employee e = new Employee(234, "IVS", "Vinay", 6500);
// tx = session.beginTransaction();
// tx.commit();
// tx=null;
catch(HibernateException ex)
System.out.println("Exception occured : " + ex.getMessage());
System.out.println("Closing the session");

Please note the text in red in EmployeeClient class.
Here we have used AnnotationConfiguration because, we have used Annotations in Employee class to map the class fields with the table fields.
If Employee.hbm.xml is used for this mapping then here we would have used Configuration (which we normally do)

SessionFactory factory=new Configuration().configure().buildSessionFactory();