Issue 1:
David Harrigan opened SPR-8986 and commented

Hi,

In our application we have a rapidly growing number of JAXB2 annotated classes. It is a right pain to add these classes manually to the "classesToBeBound" property in the Jaxb2Marshaller. Given that other components (I'm looking at you Hibernate : AnnotationSessionFactoryBean) have the ability to automatically add classes from packages that match annotations, why not then for the Jaxb2Marshaller (having to key in the classes manually is so old skool).

I've extended Jaxb2Marshaller (file attached) that scans on the classpath for appropriately annotated classes. Please do review and I hope that this can be incorporated into the next release. I'm happy to make changes to the codebase if required to bring it up to Spring coding standards.

It's a pity that afterPropertiesSet is marked as Final in Jaxb2Marshaller since I can't override that method to set up the setClassesToBeBound before then calling the super afterPropertiesSet. Currently as the code stands, I have to provide a dummy setClassesToBeBound and setLazyInit to be true. This dummy is then replaced by overriding the getJaxbContext. I think this needs rewriting.

An example of use:

<bean id="marshaller" class="foo.bar.AnnotationJaxb2Marshaller">
<property name="lazyInit" value="true" />
<property name="classesToBeBound">
<list>
<value>foo.bar.Class</value>
</list>
</property>
<property name="packagesToScan">
<list>
<value>foo.bar.jaxb.model</value>
</list>
</property>
</bean>

-=david=-

Affects: 3.1 GA

Attachments:

AnnotationJaxb2Marshaller_v2.java (5.10 kB)

AnnotationJaxb2Marshaller.java (4.13 kB)

Issue Links:

#13835 HTTP response code 308 ("is duplicated by")

#13844 Add ClasspathScanningJaxb2Marshaller for spring OXM ("is duplicated by")

Referenced from: commits 8980ce7, 79f32c7, ff9ad7a

Issue 2:
Loren Rosen opened SPR-305 and commented

The shell scripts in samples/jpetstore/db/hsqldb has DOS line delimiters instead of Unix delimiters. This can cause attempts to run this sample application to fail.

What happens is that, when you start up the database via server.sh, the shell sees the end of the command as '-database jpetstore\c', where by \c I mean the carriage return character. Then when the sample code itself attempts to query the database, it gets an error since the database jpetstore (with no terminating carriage return) doesn't exist:

org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [(mapped statement)] in task 'SqlMapTemplate'; nested exception is java.sql.SQLException: Table not found: CATEGORY in statement [select CATID, NAME, DESCN from CATEGORY where CATID = 'CATS']

org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:254)

org.springframework.orm.ibatis.SqlMapTemplate.execute(SqlMapTemplate.java:116)

org.springframework.orm.ibatis.SqlMapTemplate.executeQueryForObject(SqlMapTemplate.java:152)

org.springframework.samples.jpetstore.dao.ibatis.SqlMapCategoryDao.getCategory(SqlMapCategoryDao.java:17)

org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.getCategory(PetStoreImpl.java:124)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

java.lang.reflect.Method.invoke(Method.java:324)

org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:60)

org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:150)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:119)

org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)

org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)

$Proxy0.getCategory(Unknown Source)

org.springframework.samples.jpetstore.web.spring.ViewCategoryController.handleRequest(ViewCategoryController.java:31)

org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:495)

org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)

javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

To the beginning user it simply appears that the samples are broken. Some beginning users might even jump to the conclusion that spring itself doesn't work, since here even the sample code gets errors about bad SQL grammar. It took me most of a morning to figure out the problem.

Presumably the problem occurs with the scripts in the petclinic sample as well, though I haven't tried them.

Note also that it's possible some Unix shells could treat DOS line delimiters the same as Unix delimiters, and so not exhibit this bug. Here I'm using

GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin7.0)

Affects: 1.1 RC2

Issue Links:

#7861 DOS chars in sample app shell scripts ("is duplicated by")