At line 8 changed 5 lines. |
*[5] Database Questions and HowTos |
*[6] Application Server Questions and HowTos |
*[7] Using Anthill and CruiseControl |
*[8] Hibernate Specific Questions |
*[9] Archived Questions |
*[5] JSF Specific HowTos |
*[6] Database Questions and HowTos |
*[7] Application Server Questions and HowTos |
*[8] Using Anthill and CruiseControl |
*[9] Hibernate Specific Questions |
*[10] Archived Questions |
At line 22 changed 1 line. |
;:''Chances are you forgot to run "{{ant setup-tomcat}}" (or "{{ant setup}}" if you need to set up the database as well).'' |
;:''Chances are you forgot to run "{{ant setup-tomcat}}" (or "{{ant setup}}" if you need to set up the database as well). Also, if you're using Tomcat make sure you are using the latest [recommended release|DevelopmentEnvironment]. '' |
* Why do I get this error "build.xml:1037: taskdef class org.apache.catalina.ant.ReloadTask cannot be found"? |
;:''Ant cannot find the ReloadTask which is in $CATALINA_HOME\server\lib\catalina-ant.jar. You need to ensure env var CATALINA_HOME (Windows dir %CATALINA_HOME% or Unix ls $CATALINA_HOME) points to the tomcat install base directory. This error can also occur when you wrap the path in double quotes, (ie. if you have set CATALINA_HOME="c:\Tomcat 5.5" then remove the double quotes!). '' |
At line 36 added 5 lines. |
</div> |
* When working on a team, how to run test of a specific POJO using db-load task only in that specific table as well? |
;:''First, instead of using all the sample-data.xml file, create another file say sample-person.xml and there put the data that you want insert. After that you can do this: |
ant test-dao -Dtestcase=PersonDao -Dfile=metadata/sql/sample-person.xml'' |
|
At line 57 added 1 line. |
* Do you have any Struts validator [examples?|http://phd.netcomp.monash.edu.au/RobertMarkBram/blog/detailPage.asp?id=46] |
At line 50 changed 1 line. |
!!Database Specific [#5] |
* Why is the JSTL keyword 'empty' not working all the time? |
|
;:''The empty keyword (pre JSP 2.0), only worked on java.util.List, java.util.Map, on Strings and arrays. Collections like java.util.Set were not supported. If you are using pre JSP 2.0 and want to test whether a Set is empty or not use: {{{ |
|
<c:if test="${mycollection['empty']}">. |
|
}}} |
The most reliable workaround to this problem I have found, is to use this notation: |
{{{ |
<c:forEach items="${mycollection}" var="element" varStatus="rowNum"> |
|
<c:if test="${rowNum.count==1}"> |
<table> |
<tr> <th> Value Header </th> </tr> |
</c:if> |
|
<tr> |
<th> |
<c:out value="${element.value}"/> |
</th> |
</tr> |
<c:if test="${rowNum.last}"> |
</table> |
</c:if> |
</c:forEach> |
}}} |
This [article|http://weblogs.java.net/blog/mister__m/archive/2003/11/crazy_jstl_when.html] explains this in more detail. If you are using tomcat 5, this supports JSP 2.0 so you will not experience |
this problem.'' |
|
!!JSF Specific [#5] |
* I get an "Couldn't find template: /home/mats/myapp/metadata/templates/struts_form.xdt" when I run "ant setup test-all" after specifying "jsf" as web framework when running "ant new". |
;:''This is caused by the failure of JSF to install. Start with a version that has [JSF pre-installed|https://appfuse.dev.java.net/files/documents/1397/37690/appfuse-jsf-1.9.3-src.zip].'' |
|
!!Database Specific [#6] |
At line 56 changed 1 line. |
;:''MySQL 4.1.7 requires you to add set the default character set to UTF-8 to get unicode support with AppFuse. To do this, add the following to your c:\Windows\my.ini or /etc/my.cnf file:'' |
;:''MySQL 4.1.7+ requires you to add set the default character set to UTF-8 to get unicode support with AppFuse. To do this, add the following to your c:\Windows\my.ini or /etc/my.cnf file:'' |
At line 124 added 4 lines. |
* Can AppFuse talk to multiple [databases?|MultipleDatabases] |
|
* Can I audit any changes to the [Database?|DatabaseAudit] |
|
At line 84 changed 1 line. |
;:''If a class with a natural key does not declare a version or timestamp property, it's more dificult to get saveOrUpdate() and cascades to work correctly. You might use a custom Hibernate Interceptor as discussed in this chapter. (On the other hand, if you're happy to use explicit save() and explicit update() instead of saveOrUpdate() and cascades, Hibernate doesn't need to be able to distinguish between transient and detached instances; so you can safely ignore this advice.) Composite natural keys extend the same ideas. {Hibernate in Action: pag.:333} '' |
;:''If a class with a natural key does not declare a version or timestamp property, it's more dificult to get saveOrUpdate() and cascades to work correctly. You might use a custom Hibernate Interceptor as discussed in this chapter. (On the other hand, if you're happy to use explicit save() and explicit update() instead of saveOrUpdate() and cascades, Hibernate doesn't need to be able to distinguish between transient and detached instances; so you can safely ignore this advice.) Composite natural keys extend the same ideas. {Hibernate in Action: pag.:333}'' |
At line 132 added 1 line. |
* What [DB admin/clients|DBTools] can I use to administer my database? |
At line 136 added 1 line. |
* How to [run AppFuse on Oracle|RunningOnOracle]. |
At line 92 changed 1 line. |
!!Application Server Specific [#6] |
* How do I use a JNDI DataSource instead of a Spring-managed one (1.9+): |
|
;:In metadata/conf/tomcat-context*.xml, uncomment the JNDI DataSource settings. Then in web/WEB-INF/applicationContext-resources.xml, uncomment the JNDI "dataSource" bean - and delete the active "dataSource" bean. If you decide to make this a permanent change in your project, you can delete {{commons-dbcp.jar}} and {{commons-pool.jar}} from ''lib/jakarta-commons''. |
|
!!Application Server Specific [#7] |
At line 150 added 1 line. |
* How to setup/suppress [Tomcat 5.x Logging|Tomcat5Logging] |
At line 101 changed 1 line. |
!!Continuous Integration [#7] |
!!Continuous Integration [#8] |
At line 105 changed 1 line. |
!!Hibernate Specific Questions [#8] |
!!Hibernate Specific Questions [#9] |
At line 110 changed 2 lines. |
* How do I get hold of the Hibernate session in my DAO? |
;:''The DAO layer has the Hibernate sessionFactory injected (made available) to it through Spring and this entry in applicationContext-hibernate.xml: |
* How do I get hold of the [Hibernate Session|GettingHibernateSession]? |
* How do I [Setup Hibernate JMX?|HibernateJMX] |
* Does Hibernate support [Pagination?|HibernatePagination] |
* How do I fix a LazyInitializationException in my unit tests? |
;:''See [Karl Baum's writeup on Lazy Initialization|http://www.jroller.com/page/kbaum/20040708]. In particular, the __Being Lazy in your Unit Tests__ section.'' |
At line 113 changed 3 lines. |
{{{ |
<property name="sessionFactory"><ref local="sessionFactory"/></property> |
}}} |
* __Do I have to use XDoclet to generate my *.hbm.xml files? Is it possible to override a single hbm.xml file and create it by hand?__ |
At line 117 changed 1 line. |
So to access the Hibernate session from within your DAO, place a method like this in your DAO: |
<div style="margin-left: 30px"> |
If you have an @hibernate.class tag on a POJO - hibernatedoclet will generate the mapping file into build/dao/gen. If you have a mapping file (*.hbm.xml) file for your POJO in the src/dao/**/model/* |
directory, it will __overwrite__ the generated version. If you don't want to worry about the two conflicting - just remove the @ sign from @hibernate.class in your POJO and put your hbm.xml file in the {{model}} |
directory. |
At line 119 changed 1 line. |
{{{ |
No build.xml modification are need for this to work. The "package-dao" target will include these mapping files: |
At line 121 changed 1 line. |
Session session = SessionFactoryUtils.getSession(getSessionFactory(), false); |
{{{ <copy todir="${build.dir}/dao/gen"> |
<fileset dir="src/dao" includes="**/*.xml" excludes="**/*-${dao.type}.xml"/> |
<filterset refid="variables.to.replace"/> |
</copy>}}} |
At line 123 changed 1 line. |
}}} |
If you want to get rid of the hibernatedoclet process, you can do that- but make sure and run it first - and then copy all of the generated hbm.xml files into your {{model}} directory. |
</div> |
At line 125 changed 30 lines. |
* How do I get hold of the Hibernate session in my View code? |
;:''To get hold of the Session in the view code, you need to lookup the SessionFactory defined in the applicationContext-hibernate.xml: |
|
{{{ |
private void createApplicationContext() { |
if (ctx == null) { |
ctx = |
WebApplicationContextUtils.getRequiredWebApplicationContext(servlet.getServletContext()); |
} |
} |
|
public net.sf.hibernate.Session getCurrentHibernateSession() { |
createApplicationContext(); |
|
SessionFactory sessionFactory = (SessionFactory)ctx.getBean("sessionFactory"); |
SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.getResource(sessionFactory); |
net.sf.hibernate.Session currentSession = null; |
Transaction currentTransaction = null; |
|
if (sessionHolder!=null) { |
currentSession = sessionHolder.getSession(); |
currentTransaction = sessionHolder.getTransaction(); |
} |
return currentSession; |
} |
|
}}} |
|
|
!!Archived Questions (no longer relevant) [#9] |
!!Archived Questions (no longer relevant) [#10] |