Posts Tagged With ‘J2EE&8217


Security in Java EE Part 1

Object Oriented application development provides developers to divide application into different layers such as database layer, business layer, presentation layer … etc. Multi layer application development approach provides easy to develop and maintain large scale projects. However, this approach addresses one of the most important issue, security.

Java EE consists of components ejb, web, web services, application clients … etc. Each of these components can be deployed into different containers or same container. Security is handled by the containers; a container provides programming or declarative security. Programming security is embedded control mechanism that is used when declarative security is insufficient. Declarative security defines applications security configuration out of the application via configuration files. Also, annotations define set of security rules by class files.

Java provides some security implementation mechanisms like;

Reference:

http://java.sun.com/j2se/1.5.0/docs/guide/security/

http://java.sun.com/javase/technologies/security/


java.lang.OutOfMemoryError: PermGen space

If you are developing JEE applications with low resources (like me ) probably you have been facing “java.lang.OutOfMemoryError: PermGen space” exception and it will be your nightmare. Sample stack trace of exception:

StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.OutOfMemoryError: PermGen space
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:28)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

You should add these parameters to domail.xml to get rid of this exception ( it is not exact solution) :

-Xmx256m
-Xms64m
-Xss128k
-XX:NewRatio=2
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled


Schema Generation : Hibernate vs Toplink

Do you know why I like hiberante and dislike toplink?
A simple reason should be hibernate scheme generation can update columns and lots of stuff in existing table as mentioned below:

SchemaExport (hbm2ddl): This tool is provided with the core Hibernate download. It uses Hibernate mapping metadata XML files to generate a SQL database schema with DDL. You can enhance your mapping files with database specific elements (SQL column datatypes, unique/check constraints/indexes, etc.) and then export the SQL DDL to a text file. You may also directly export the DDL to a database, this is very powerful in development, as you can automatically create and drop a database at each test run. See the Hibernate reference documentation for more information about this tool.

On the other hand, toplink can not update existing database table. It is terrible ….