vrijdag 18 mei 2007

excel export from webapp HSSF IE

While using the spring-framework (rocks!) I used the poi framework of jakarta to generate excel sheets. All went well in firefox but when I tried this with Internet Explorer the file was broken. The application opening it couldn't find the temp file.

My solution for this is in using the correct response headers. I found these by looking at an opensource project with excel export functionality (thx 2 phpMyAdmin).

Using the following headers works for me:

//control cache, these make the difference
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "Public");
//these are xls specific
response.setHeader("Content-Disposition", "attachment; filename=action.xls");
response.setHeader("Content-Type", "application/vnd.ms-excel");

So good luck with it, also check your filename for characters not allowed by your filesystem.

updating blob field oracle with hibernate results in > 4000 bytes error

Ok so writing BLOB fields in Oracle (with hibernate) could give you a bla bla length > 4000 bytes error. [todo: lookup exact error] First of all I'll explain why. The BLOB fields in oracle work with a pointer and that pointer is 4000 bytes. The actual data is stored elsewhere. So your problem is that you're trying to write to this pointer instead. [todo: lookup source]

I believe (didn't have time to test yet [todo]) that the problem is within the driver. So first of all get the latest driver you can get.

oracle jdbc driver version


The following information is for completeness only.

hibernate version


hibernate mapping

<property name="xml" lazy="true" not-null="true" column="xml" />

java property

* xml data of this audit
private byte[] xml;

public byte[] getXml() {
return xml;

public void setXml(byte[] xml) {
this.xml = xml;

column definition

XML BLOB not null

sapjco problems

When using the java sap connector there are several things to keep in mind. Start by following the instructions in the given link ^.

You need a reference in your project to the sapjco.jar file. You could put this one on the lib of your jdk installation (%JAVA_HOME%/lib/ext) but I wouldn't. Read aboout classloading instead.

The same for the two ddl libraries: librfc32.dll en sapjcorfc.dll can be put in your jdk lib, %WINDOWS%/system32/ or any where else. Just make sure this path is on your system variable PATH.

It's important to start logging errors from the very first run. Because if the sapjco.jar was found on your classpath but it didn't find the dll's than only the first error will give you this information. It will print an UnsatisfiedLinkError and it should print the path where it's looking as well.

You can do this yourself in Java (f you hava the rights to) with the following line of code:


Solving this problem is easy (put the ddl's on that path) but can be tricky because for the next calls on that sapjco.jar it will return a ClassNotFoundException.
So if you missed the first error you might be wondering why your jar wasn't found (while it was).

just found an interesting article about external java sources in domino server. Should be possible to add a jar file to a project as well. More articles on the same very interesting website, also on classloading.

profiling Java

Profiling is important, it can show bottlenecks in your application and so help you solve these. An optimized application will run faster so users will be hapier.

I mostly use eclipse for development (WTP project). Check my post on this blog about my eclipse plugins as well

Before version 3.2 of eclipse I had a simple eclipse plugin for profiling. The link points to a good tutorial for setting this one up for most servers. Problem with this one is that it's not supported anymore and doesn't work with and all above 3.2

Eclipse profiler - plugin for profiling Java applications inside of Eclipse. NOTE! Project is dead and does not work on new versions of Eclipse. Use other open source (such as TPTP) or commercial profilers. SWT components library - set of additional SWT

I tried the eclipse TPTP project. It's a bit overkill but it works. I didn't get it to work using only the project documentation. Note you have to install the AC controller seperately. For the different server configurations I found another tutorial. This one worked for tomcat: eclipse TPTP tomcat howto.

todo: test and describe other server configurations like weblogic, ...

my eclipse plugins

Well most of them at least, I'll try to keep this list updated:

  1. WTP project : for developping web and enterprise applications, also includes xml validation etc
  2. TPTP project : for testing and profiling applications
  3. green : for UML integration
  4. SQL explorer : database management through jdbc
  5. PHPeclipse : php integration
  6. m2eclipse : maven integration, there is also an maven plugin for generating eclipse projects
  7. RDT : ruby integration