Wednesday, March 4, 2009

Error when converting struts jar into bundle with Bnd

I did face errors when converting struts jar into bundles using bnd tool.

The problem was the name of the package:

...i18n.calendar.nls.pt-br;resolution:=opti...

The package pt-br contains a - sign. According to the Java spec, this is not a package name. The OSGi specification does therefore not allow you to export a package that includes a - sign.

Once i removed these packages from the manifest file , it worked fine .

Bnd tool for converting jars into bundles OSGi

This provides a easy way of converting jars into bundles.This does a brute force check and writes every package present in the jar as export and all imports in the java files inot manifest imports.

The command to convert jar into bundle is

java -jar bnd.jar wrap xxx.jar

Its better to check in the Spring Repository for the available bundle before converting it from a a jar to bundle.

http://www.springsource.com/repository/app/

Ref :

http://www.aqute.biz/Code/Bnd

http://blog.springsource.com/2008/02/18/creating-osgi-bundles/

Improving Eclipse performance

Try the below configuration on experimental basis to improve this performance

In the eclipse installation directory parallel to eclipse.exe you will find a file called eclipse.ini

modify it to have the following changes

Change the XXMaxPermSize to 256M
Change the min and max heap size to be 512
Restart eclipse.

--launcher.XXMaxPermSize
256M
-Xms512m
-Xmx512m

Tiimout params for spring remoting

All properties can be set for spring remoting including connection timeout.

The HttpInvokerProxyFactoryBean takes in httpInvokerRequestExecutor as a parameter which in turn takes in httpClient(org.apache.commons.httpclient.HttpClient).

Hence all properties for HttpClient as timeout , connectiontime etc can be set.

Code snippet for injecting httpclient into the connection object(with timeout for 5 seconds)

<bean id="httpParamObject"
class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
<property name="httpClient">
<bean class="org.apache.commons.httpclient.HttpClient">
<property name="timeout" value="5000" />
</bean>
</property>
</bean>

<bean id="testServer"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl"
value="http://10.1.66.109:8080/server/TestServer" />
<property name="serviceInterface"
value="com.pg.server.IServerImpl" />
<property name="httpInvokerRequestExecutor" ref=" httpParamObject" />

</bean>

Jnotify - monitor file system Events

JNotify is a java library that allow java application to listen to file system events, such as:

* file created.
* file modified.
* file renamed.
* file deleted

JNotify works on both Windows (Windows 2000, XP, Vista) and Linux with INotify support (Kernel 2.6.14 and above).

http://jnotify.sourceforge.net/

Strut 2 performance Tips

Set devmode false

Set template caching true

Define custom interceptor stack. Remove interceptors that are not required.

In classes we can create a templates folder and customize the way js files and templates are loaded.

Ref: http://struts.apache.org/2.0.11.1/docs/performance-tuning.html

Removing tomcat from Spring Dm to reduce memory

By commenting out the servlet subsystem, there should be no Tomcat running in dm Server ß

In profile.config comment as indicated below to disable the tomcat instance.

/* * SpringSource dm Server profile manager default configuration file. */
"profile": { "version" : 1.0, "name" : "web", "subsystems" : [/* "com.springsource.server.servlet", "com.springsource.server.web" */], "optionalSubsystems" : [/* "com.springsource.server.management" */] }}

Mem usage

WITH TOMCAT - 68MB W

WITHOUT TOMCAT - 51 MB ( so 17 MB less)

Ref :http://forum.springframework.org/showthread.php?p=216805

 
Free Domain Names @ .co.nr!