Wednesday, April 1, 2009

Struts 2 OGNL variable evaluation

< s: set name="startIndex" value="%{#parameters['start'][0]}"/ > < s: property value="@java.lang.Integer@parseInt(#startIndex)+4"/ >
Here the first statement grab the query string value using parameter object and assign it as a string, the '%{}' syntax is used for this purpose. The second statement convert the string to int and add the two integers.
IMPORTANT: for the parseInt to work you should enable the constant in struts.xml < constant name="struts.ognl.allowStaticMethodAccess" value="true" / >

Monday, March 30, 2009

SVN with Eclipse Ganymede

  1. Install svn server for windows, use the msi package.
  2. Create Repository
svnadmin create "c:\svnrepo"
Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:
[general] anon-access = read auth-access = write password-db = passwd
Next, uncomment these lines in the /conf/passwd file:
[users] harry = harryssecret sally = sallyssecret
3. Install subeclipse 1.6.x package for Ganymede. 4. check in the project using these parameters
host svn://localhost use default port repository svnrepo
In Linux if you have created a subversion group, don't forget to change the file group permission, like this.
sudo chown :subversion directory/
Do not forget to commit the project at the end.

Wednesday, December 31, 2008

Auto create tables JPA

< property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"> < property name="hibernate.hbm2ddl.auto" value="create-drop"> < property name="hibernate.show_sql" value="true"> < property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"> < /property>

Tuesday, December 2, 2008

Recusively deleting a folder in MS DOS

for /f %D in ('dir/s/b/ad ^| find/i ".svn" ') do if exist "%D" rd/s/q "%D"
replace %D with %%D for batch job

Thursday, November 13, 2008

Where not to put presistance.xml

Where to put persistence.xml in web app? In all cases, persistence.xml always resides in {root-of-persistence-unit}/META-INF/ directory. For example,

foo.war: WEB-INF/classes/META-INF/persistence.xml //good WEB-INF/classes/com/foo123/jpa/Project.class WEB-INF/web.xml index.jsp You may also package entity classes and persistence.xml inside a library jar, which is packaged inside the war: WEB-INF/lib foo.war: WEB-INF/lib/my-entities.jar WEB-INF/web.xml index.jsp my-entities.jar: META-INF/persistence.xml //good com/foo123/jpa/Project.class For comparison, some invalid configurations are: foo.war: WEB-INF/persistence.xml //invalid WEB-INF/web.xml WEB-INF/classes/com/foo123/jpa/Project. index.jsp ----------------------------------------------- foo.war: META-INF/persistence.xml //invalid WEB-INF/classes/com/foo123/jpa/Project.class WEB-INF/web.xml index.jsp ----------------------------------------------- foo.war: persistence.xml //invalid WEB-INF/classes/com/foo123/jpa/Project.class WEB-INF/web.xml index.jsp ----------------------------------------------- foo.war: META-INF/persistence.xml //invalid com/foo123/jpa/Project.class WEB-INF/web.xml index.jsp
In all these invalid configurations, EntityManager lookup will fail with javax.naming.NameNotFoundException, or @PersistenceContext injection will be silently skipped and the em variable is always null, and hence NullPointerException when referenced.

Wednesday, July 30, 2008

SCP between two remote hosts

scp emartine@localhost:/var/eone/batch/production/data/exports/*.csv emartine@192.168.100.5:/home/emartine Now it will ask for. emartine@localhost's password: emartine@192.168.100.5's password:

Monday, July 14, 2008

MYSQL Error29

mysqldump: Got error: 29: File './databasename/tablename.MYD' not found (Errcode: 24) when using LOCK TABLES The best way to get to the bottom of the error is to find out what it means: $ perror 24 OS error code 24: Too many open files
There’s two ways to fix the problem. First, if you find that you only hit the limit during mysqldumps and never during normal database operation, just add
--single-transaction to your mysqldump command line options. ex: mysqldump -h localhost --single-transaction
This will cause mysql to keep only one table open at a time. However, if this happens while backups aren’t running, you may want to increase the open_files_limit in your MySQL configuration file. By default, the variable is set to 1,024 open files.