6

Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other contai...

 2 years ago
source link: https://blog.jakubholy.net/2011/06/07/version-hell-with-jsfunit-arquillian-and-embedded-glassfish-and-other-containers/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers

June 7, 2011
JSFUnit and the JBoss Arquillian test framework for JavaEE look very promissing, but according to my experience there are good reasons why they are only beta and alpha versions. May be you can get them working but you must pick the right version of each dependency - for many things change between individual versions at this point - and be lucky to hit one of the "happy paths". At the end I nearly got JSFUnit 1.0.0.Beta1 running with Arquillian 10.0.0.Alpha4 and glassfish-embedded 3.0.1 but failed to deploy due to a strange parse exception of an arquillian's web fragment. I record this failure to help those who are struggling with this too.

There are the following fatal constraints:
  • JSFUnit 2.0.0.Beta1 is the latest available one (Beta2 should have been released in April but wasn't and it has still one issue opened - JSFUNIT-275]; 2.0.0. Final is due on July 1st but considering the delay of Beta2 and no progress in the final version, it will be certainly much later)
  • JSFUnit 2.0.0.Beta1 requires Arquillian 1.0.0.Alpha4, support for Alpha5 comes with Beta2.
  • Container selection:
  • Tomcat 6 only supports servlet 2.5 while JSFUnit requires 3.0 for it uses web fragments; however this seems to be fixed in JSFUNIT 1.0.0.Beta2, see JSFUNIT-273
  • I wasn't able to get JBoss Embedded (6.0.0.Final), it tried to download quazillion dependencies and ultimately failed due to some version mismatches
  • Embedded GlassFish (GF) - version 3.1 has a different API, which is supported only since Arq. Alpha5, and deployment to 3.0.1 fails due to "SAXParseException: src-resolve: Cannot resolve the name 'xml:lang' to a(n) 'attribute declaration' component.", solved only in GF 3.1 (GLASSFISH-13261). Surprisingly I got 3.0.1 working with another project but there it failed due to JSF libraries mismatch (otherwise it might also come to this problem).

My (not so well working) Ivy configuration thus was:


...
   <dependency org="org.jboss.jsfunit" name="jsfunit-arquillian" rev="2.0.0.Beta1" conf="webtest" />
   <dependency org="org.jboss.arquillian" name="arquillian-junit" rev="1.0.0.Alpha4" conf="webtest" />
   <dependency org="org.jboss.arquillian.container" name="arquillian-glassfish-embedded-3" rev="1.0.0.Alpha4" conf="webtest" />
   <dependency org="org.glassfish.extras" name="glassfish-embedded-all" rev="3.0.1" conf="webtest" />
...


The accompanying settings.xml with repositories:

<ivysettings>
   <settings defaultResolver="all_repositories" />
   <resolvers>
      <chain name="all_repositories">
         <ibiblio name="ibiblio" m2compatible="true" />
         <ibiblio name="jboss" m2compatible="true" root="https://repository.jboss.org/nexus/content/repositories/releases" /> <!-- JSFUnit etc. -->
         <ibiblio name="sunJars" m2compatible="true" root="http://download.java.net/maven/2" /> <!-- javax.* APIs etc. -->
         <ibiblio name="glassfish-embedded" m2compatible="true" root="http://download.java.net/maven/glassfish/" />
      </chain>
   </resolvers>
</ivysettings>


-

On JSF versions

It seems that you can test only JSF 2.0 applications (well, you hopefully will be able to test them once Beta2 is out); if you try to test a JSF 1.2 application you will run into conflicting APIs, resulting for example in IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory.

Tip: Increasing logging in the embedded Glassfish

GF uses java logging => copy glassfish/domains/domain1/config/logging.properties somewhere, replace INFO with FINE and run your test with the following setting:


-Djava.util.logging.config.file=/path/to/your/glassfish/config/logging.properties



If your test failes due to IllegalStateException: Error launching test at http://localhost:8181/test/ArquillianServletRunner?.... Kept on getting 404s. then likely the deployment of your application has failed and you should increase the logging level and check the issue.

Some entries of interest:
  • ClassName=com.sun.enterprise.deployment.node.web.WebCommonNode;MethodName=addDescriptor;|Adding web component ...
  • javax.enterprise.system.tools.deployment.org.glassfish.deployment.common - some important exceptions may show here
  • javax.enterprise.system.container.web.com.sun.enterprise.web|...;ClassName=com.sun.enterprise.web.WebModuleListener;MethodName=configureJsp;| sysClasspath for __default-web-module is ... jsfunit-arquillian-2.0.0.Beta1.jar: ...
  • There was a NPE which perhaps is actually OK: ClassName=org.glassfish.deployment.common.InstalledLibrariesResolver;MethodName=getInstalledLibraries;|InstalledLibrariesResolver : exception occurred : java.lang.NullPointerException|#]

Links

Tags: java

Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.

Allow me to write to you!

Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK