Tag Archives: J2EE

Linux vs. Windows Conflict

Since we moved to our new office with new company and additional staff, we’ve switched our platform from JEE on Linux to asp.net on Windows because D&D is easy to use which I completely disagree. Today one of the developers in the office noticed that our .net development server is down. It is used for development and test purposes (manual tests). It is crashed despite having better hardware when compared our old servers which is not a server (we build it with oem products) and it is running Fedora and still up and serves well. Windows box is broken, having power issues but Linux box is still up for 408 days. What a conflict!!! Linux box with poor hardware having better performance and robust when compared better windows box with better hardware (designed for servers).

Man, .net really sucks … I already know it but .Net developers prove it.

Do we need J2EE for this?

Question : We want to write a ERP-Software for our company.The number of users will be up to 200 (mostly not at the same time). Since usability is important, we plan to choose a Swing GUI. What do you think of it? Do we need J2EE for that? Or is this a bit too much? If you need more information to answer that question, please ask me.

Answer : Of course you do not need J2EE. If your company has an email system and Microsoft Office, you could email spreadsheets back and forth.

I like Java. Full response to question is here

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;

  • JAAS: Java Authorization and Authentication Service consists of APIs to enable authorization and access control against to agents (user, account, service … )
  • Java GSS: Java Generic Security Services consists of APIs to enable securely exchange messages between applications.
  • JCE: Java Cryptography Extension provides framework implementations for encryption, key generation, key agreement and (MAC) Message Authentication Code algorithms.
  • JSSE: Java Secure Socket Extension provides implementation for a Java version of SSL and TLS protocols.
  • SASL: Simple Authentication and Security Layer a protocol for authentication and optional establishment of a security layer between client and server applications.

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 ….