ALBERLAU blog

Blog about my personal experience in software development.

Friday, January 25, 2008

 

iReport 2.0.4 and 1.3.0 compatibility issue

My collegue uses iReport plugin on NetBeans, as he said iReport version is 1.3.3. After i opened report design that he created, it looked like below.











I figured out that the following line causes the problem:

?xml version="1.0" encoding="UTF8" ?>
!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD JasperReport//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"

iReport 2.0.4 when having above line completely overwrites design xml with new blank report having width and height equal to 0.



After changing header line to :

?xml version="1.0" encoding="UTF-8" ?>
!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">


the problem becomes resolved. It seems that iReport expects DOCTYPE of "DTD Report Design", but not "DTD JasperReport".

Labels: ,


Thursday, January 24, 2008

 

Playing with Maven and AppFuse

Appfuse allows to build application skeletons quickly. First choose archetype, or combination of app frameworks, because of maven all dependencies, config files and samples will be installed with single line.

Below is my personal notes taken while experimenting with appfuse application framework. I'm choosing modular spring and jsf archetype.

Change to your projects root. Type : mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-jsf -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.myproject -DartifactId=myproject


After this command, type cd myproject, edit pom.xml and change jdbc settings located at the end of the file. Then type mvn. Project build starts. At most cases you will get BUILD ERROR caused something like: Could not connect to SMTP host: localhost, port: 25. To fix situation it is easest way to get James from http://james.apache.org/ . You only need to download and start it. Start mvn again. Now i'm getting BUILD SUCCESSFUL.


Now type cd web and mvn jetty:run-war . Web application becomes available at http://localhost:8080/ . Press Ctrl+C to stop jetty.


Type cd ../core. Type mvn appfuse:gen-model . Model classes is generated from database tables.



There is a list of AppFuse Maven commands at this link: http://www.appfuse.org/display/APF/AppFuse+Maven+Plugin .


Trying to generate CRUD stuff for mvn appfuse:gen -Dentity=Message and getting java.lang.StringIndexOutOfBoundsException: String index out of range: 1. I resolved this problem by performing mvn in project root and mvn appfuse:gen -Dentity=Message both in core and web modules.

Getting "Error executing database operation: CLEAN_INSERT". Mostly this problem occures when there is a problems with example data or bean-table mapping. It is consequence of SQLException. First look at YOUR_PROJECT_ROOT\(webcore)\src\test\resources\sample-data.xml and try to fix example data. If all is ok, check your console after mvn run for SQL errors and then fix some bean in YOUR_PROJECT_ROOT\core\app\model\SomeBean.java .

The first thing in case of Windows is to change Maven repository path to something without spaces in path. Edit MAVEN_HOME/conf/settings and add or change c:/apache-maven-2.0.8/repo line. That should be done because sooner or later you'll get : Illegal character in path at index 18: file:/C:/Documents and Settings . I got this while executing mvn appfuse:gen-core . After changfing this you can move Maven repository located at C:/Documents and Settings/.m2 to a new location.

Second issue. I got java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xfire-servlet.xml] . After googling i find out that i need to run mvn jetty:run-war instead of mvn jetty:run.

Now i'm dealing with javax.el.ELException: ELResolver cannot handle a null base Object with identifier 'errors' . I find out solution to use mvn -Dcargo.wait . Use -Dmaven.test.skip=true if tests fail and you don't want to fix them. Currently i have no idea what kind of thing is cargo. But it started tomcat instead of jetty. Also running in tomcat requires context path like this: http://localhost:8081/myproject-webapp-1.0-SNAPSHOT/mainMenu.html .

Getting javascript error when selecting to edit Branch. I generated branches using mvn appfuse:gen -Dentity=Name . The list is looking ok, but going to edit i getting "Object doesn't support this property or method". The main problem was that mvn appfuse:gen -Dentity=Name makes file named branchs.xhtml, but in all config files it generates branches.xhtml . Rename file to branches to fix the problem.


[INFO] Use of @OneToMany or @ManyToMany targeting an unmapped class: org.eparty.model.Branch.members[org.eparty.model.Member]

The above problem is caused by missing entries in hibernate.cfg.xml.



java.lang.NoClassDefFoundError: org/ep/webapp/filter/LocaleFilter (wrong name: org/appfuse/webapp/filter/LocaleFilter) or something like someYourPackage.yourClass (wrong name: org/appfuse/webapp/filter/SomeAppfuseClass) . I changed all these classes to appfuse classes.


mvn appfuse:full-source . Dont't do this. Or do after full backup of what you have. At least with 2.0.1 version. After making efforts to do making working application, this will break your code. It is better to grab appFuse core classes in to project. More info about that: http://appfuse.org/display/APF/AppFuse+Core+Classes .

Thursday, January 10, 2008

 

Oracle JDBC oracle.sql.TIMESTAMP issue

Because of this magics it's possible to spend whole day while finding solution. The problem was java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp on Tomcat, while on OC4J application was running fine. As I supposed ResultSet was returning oracle.sql.TIMESTAMP instead of java.sql.Timestamp. If oracle.sql.TIMESTAMP were extending java.sql.Timestamp there would be no problem. But it extends oracle.sql.Datum. I tried different Oracle JDBC versions, starting from classes12.jar ending ojdbc6.jar . The problem remains unsolved. After deeper research i found that Oracle JDBC uses oracle.jdbc.J2EE13Compliant property to determine what to return : oracle.sql.TIMESTAMP or java.sql.Timestamp. In case when this property is false, Oracle JDBC becomes not JDBC compatible, because oracle.jdbc.driver.TimestampAccessor returns oracle.sql.TIMESTAMP. There is some abstract info about oracle.jdbc.J2EE13Compliant in Oracle JDBC FAQ . There is more issues related to this property. In case of oracle.jdbc.J2EE13Compliant==true and precission not equals zero and scale is minus 127 oracle.jdbc.driver.NumberCommonAccessor returns Double in other cases it will return BigDecimal . The fastest and easest way to solve this problem is to add -Doracle.jdbc.J2EE13Compliant=true to your Tomcat or any other "not J2EE13Compliant" application server startup properties. It's a strange ways to get compatibilities :)

Labels: , , , , ,


Archives

January 2008   February 2008   March 2009  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]