Posts

Showing posts with the label Exceptions

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException error we got in Hibernate 4.3 to work with my MySQL database. We are using hibernate code generation tool in Eclipse and we are able to connect to the database using the Hibernate configuration file. When we try to run code in my Main class application is connecting to the database, but transaction is failing and we got the following error: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Exception in thread "main" java . lang . NoClassDefFoundError : javax / transaction / SystemException at java . lang . Class . forName0 ( Native Method ) at java . lang . Class . forName ( Unknown Source ) at org . jboss . logging . Logger . getMessageLogger ( Logger . java : 2248 ) at org . jboss . logging . Logger . getMessageLogger ( Logger . java : 2214 ) at org . hibernate . cfg . Configuration .< clinit >( Configuration . java : 184 ) at be . comp . permanenti

user defined exceptions in java with example

The built-in exceptions in java are not able to describe a certain situation. In such cases, like the built-in exceptions, the user(programmer) can also create his own exceptions which are called 'User-defined exceptions'. The following steps are followed in creation of user-defined exceptions. The user should create an exception class as a subclass to Exception class. Since all exceptions are subclasses of Exception class, the user should also make his class a subclass to it. 1 class MyException extends Exception The user can write a default constructor in his own exception class. He can use it in case he does not want to store any exceptions details. If the user does not want to create an empty object to his exception class, he can eliminate writing the default constructor. 1 MyException () {} The user can create a parametrised constructor with a string as a parameter. He can use this to store exception details. He can call super class (Exc