Pages

Thursday, October 30, 2014

Deploying Spring Petclinic demo application to JBoss/WildFly

Spring Petclinic is a very good demo application to experiment with - it is simple enough, yet demonstrates quite a good number of features. Usually I deploy it to Tomcat and obviously don't have any issues with it - it just deploys, runs, and works as expected.

Recently, however, for demonstration purposes, I needed to deploy this application to JBoss (or WildFly). And this is not as straightforward as one might expect.

First I tried with JBossAS 7.1.1.Final. The deployment fails with the following exception:

11:42:38,247 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/petclinic]] (MSC service thread 1-3) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring/business-config.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568) [spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540) [spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
...

The latest Petclinic application (as of October 2014) uses JPA 2.1 and JBoss 7.1.1 bundles JPA 2.0 APIs. So I decided that it should probably work out of the box on WildFly since it comes with JPA 2.1 jars. And it did - the application deployed just fine, but then there's another library that prevents the application from operating properly - Dandelion:

Exception starting filter dandelionFilter: com.github.dandelion.core.DandelionException: The protocol vfs is not supported. 
        at com.github.dandelion.core.utils.ResourceScanner.scanForResourcePaths(ResourceScanner.java:204) [classes:] 
        at com.github.dandelion.core.utils.ResourceScanner.findResourcePaths(ResourceScanner.java:138) [classes:] 
        at com.github.dandelion.core.bundle.loader.spi.AbstractBundleLoader.loadBundles(AbstractBundleLoader.java:89) [dandelion-core-0.10.0.jar:] 

The issue was reported but at the time of writing this post the fix wasn't published yet. So hopefully Dandelion v0.11.0 will be capable to be deployed on WildFly.

So to overcome this and deploy Spring Petclinic (at the state of October 2014) to WildFly 8.1 one would have to get rid of the dependency on Dandelion, and rewrite some of the JSPs not to use Dandelion taglibs. Then the application deploys and works just fine.

So after making all the fixes I got Spring Petclinic running deployed to WildFly and could monitor it with XRebel:



7 comments:

Thibault Duchateau said...

Hi,

Indeed, the fix will be available in the v0.11.0, providing support for JBoss AS 5 to WildFly 8.x. (https://github.com/dandelion/dandelion/issues/23)
Sorry for the inconvenience.

Regards,
Thibault.

buycmstemplate said...

Its a great post
automobile templates free download

cviniciusm said...

Hello,

I'm using Eclipse IDE Luna 4.4 SR2 with JDK8u45, Wildfly 8.2.0.Final, STS 3.6.4.RELEASE and JBoss Tools v4.2.3.Final.

I have imported the spring petclinic.

The issue remains as the pom still has the dependency: 0.10.1

These following maven repositories doesn't show the v0.11.0: http://mvnrepository.com/ and http://search.maven.org

I saw the version changed from 0.11.0-SNAPSHOT to 1.0.0-SNAPSHOT on GitHub.

Did you use the plugin jQuery Datatable instead, please ?

arhan said...

I just used nothing :)

cviniciusm said...

Hello,

Ok, the app is fine with Tomcat.

But with Wildfly 8.2.0.Final, I removed Dandelion completely then used plug in jQuery Datatables and extension Tabletools.

arhan said...

Well, that's exactly what I described in the post :)

Thibault Duchateau said...

The 0.11.0-SNAPSHOT was still under development until it is recently renamed to 1.0.0-SNAPSHOT.

So currently if you need to deploy on JBoss/Wildfly, you need to pull the 1.0.0-SNAPSHOT.

If so, take care to enable snapshot downloads in the POM:



sonatype-nexus-snapshots
Sonatype Nexus Snapshots
https://oss.sonatype.org/content/repositories/snapshots

true


Disqus for Code Impossible