You can use Scala programming language in a JSF 2.0 / Java EE 6 web application just fine.
And it works very well! For starters, this is what you need:
Steps to create a mixed Scala-Java JSF 2.0 web project:
If Scala classes don't work, and you encounter these error messages: WARNING: WEB9052: Unable to load class places.City, reason: java.lang.NoClassDefFoundError: scala/ScalaObject
INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/scalajsf'
SEVERE: Unable to load annotated class: places.City, reason: java.lang.NoClassDefFoundError: scala/ScalaObject Then you need to add Scala library to the web deployment assembly.
And it works very well! For starters, this is what you need:
- The latest [Sun] Java 6 JDK (of course)
- Eclipse Helios 3.6, Java EE edition
- JBoss Tools 3.2 Eclipse plugin
- Scala IDE for Scala 2.8.0-final Eclipse plugin (currently, only nightly builds are available for Eclipse 3.6 Helios)
- Any Java EE 6 Server, such as Oracle GlassFish 3 or JBoss AS 6
Steps to create a mixed Scala-Java JSF 2.0 web project:
- Install Eclipse IDE Java EE with the above plugins
- Create a new Dynamic Web Project - JSF 2.0 like usual
- After project creation, change the perspective to Scala
- Right click the Project, click Configuration -> click Add Scala nature
- Make sure Scala Library is on the Java Build Path
- Make sure Scala Library is on the Web Deployment Assembly
- Start to code a Scala bean or class and use them just like Java classes! *with pleasure* :D
Troubleshooting
If Scala classes don't work, and you encounter these error messages: WARNING: WEB9052: Unable to load class places.City, reason: java.lang.NoClassDefFoundError: scala/ScalaObject
INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/scalajsf'
SEVERE: Unable to load annotated class: places.City, reason: java.lang.NoClassDefFoundError: scala/ScalaObject Then you need to add Scala library to the web deployment assembly.
- Right-click your Project, and click Properties...
- Click Deployment Assembly
- Click Add..., then choose Scala Library. The dialog should look like the picture below.
- Click OK to close the dialog.
- Rebuild & republish the web project and your Scala JSF 2.0 web project should run fine.
No comments:
Post a Comment