Skip to main content

Posts

Change default JAVA_OPTS in JBoss 7

To change JVM memory options in JBOSS 7 for standalone server, find the file standalone.conf.bat in bin directory and edit the file like below. rem # JVM memory allocation pool parameters - modify as appropriate. set "JAVA_OPTS=-Xms3072M -Xmx3072M -XX:MaxPermSize=1024M"

JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period [60 seconds]

To resolve this error, edit the below in \jboss-as-7.1.1.Final\standalone\configurationstandalone.xml find the below lines and add deployment-timeout. <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">             <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>         </subsystem> <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">             <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="1200" />         </subsystem>

Rest Client addon on Firefox/Chrome to test restful services & web pages

https://addons.mozilla.org/en-us/firefox/addon/restclient/ Using this browser extension we can test our restful services as well as web pages by proving some request headers.  I am testing my application (java code) by providing cookie, this will be fast for debugging, no need enter values every time in browser. Just capture the request data from chrome developer console/ firebug once and hit the server with same data or modified one. it is easy & very helpful.

SQLQuery.executeUpdate() will invalidate hibernate's second level cache

when SQLQuery.executeUpdate() called all second level cache will be invalidated.  Example: SQLQuery query = session.createSQLQuery("UPDATE TABLE ....."); query.setInteger("status", 1); query.executeUpdate(); To avoid: SQLQuery query = session.createSQLQuery("UPDATE TABLE ....."); query.setInteger("status", 1); query.addsynchronizedqueryspace("TABLE");  query.executeUpdate(); details here: http://www.link-intersystems.com/bin/view/Blog/Hibernate's+second+level+cache+and+native+queries

Disable hibernate Optimistic Lock for specific scenario

Optimistic Lock gives more control on concurrent modification on data. That can be achieved very easily in hibernate using @Version column. But in some cases we may have to avoid concurrency check, example background process. To disable Optimistic lock set OptimisticLockMode as NONE for entity class while hibernate is initiating. We can't remove version column that needs Database changes and ORM changes. In this way we can disable Optimistic Lock by code. implement "org.hibernate.event.Initializable" interface override the below method.     @Override     public void initialize(Configuration cfg) {         Iterator<?> persistentClassIterator = cfg.getClassMappings();         while (persistentClassIterator.hasNext()) {             PersistentClass persistentClass = PersistentClass.class.cast(persistentClassIterator.next());                     Iterator propertyIterator = persistentClass.getDeclaredPropertyIterator();                    while (proper