Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9006083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:19:08+00:00 2026-06-16T01:19:08+00:00

I’m currently using Scala with JSF, of which the two play pretty well together.

  • 0

I’m currently using Scala with JSF, of which the two play pretty well together. However at times JSF needs to re-instantiate (via Class.newInstance) a data structure, like a list. For example in a managed bean I have:

@BeanProperty
var countries: java.util.List[String] = List("US").asJava

Which works fine until you get to JSF’s process validation phase where it runs into java.lang.InstantiationException:

java.lang.InstantiationException: scala.collection.JavaConversions$SeqWrapper
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.renderkit.html_basic.MenuRenderer.createCollection(MenuRenderer.java:906)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:366)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:128)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:314)
at org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenuRenderer.getConvertedValue(SelectCheckboxMenuRenderer.java:34)
...

From a fundamental level it makes sense that Wrappers may not be re-instantiated from scratch, so using JavaConverters won’t work well here. My question is there library that already provides a complete Data Structure mapping/conversion without wrappers? If not I’ll just write my own internal ones.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:19:10+00:00Added an answer on June 16, 2026 at 1:19 am

    Use a Java ArrayList as the var and then use JavaConverters/JavaConversions in your code to manipulate. That’s the usual approach I use for APIs like Hibernate, JAX-WS, JSR-303, etc. that need Java collections.

    import collection.JavaConversions._
    
    @BeanProperty
    var countries: java.util.List[String] = new java.util.ArrayList[String] += "US"
    

    or

    import collection.JavaConverters._
    
    @BeanProperty
    var countries: java.util.List[String] = new java.util.ArrayList[String]
    countries.asScala += "US"
    countries.asScala ++= List("US", "MX")
    

    If you really want to just convert back and forth and not wrap it’s easy enough without creating your own classes:

    import collection.JavaConverters._
    import collection.mutable.ArrayBuffer
    
    @BeanProperty
    var countries: java.util.List[String] = new java.util.ArrayList[String]
    
    val countriesBuff = new ArrayBuffer.empty[String]
    countriesBuff ++= countries.asScala     // Convert from ArrayList to ArrayBuffer
    // ...
    countries.addAll(countriesBuff.asJava)  // Convert the other direction
    

    But then you have to worry about the cost of copying and about when synchronization needs to happen. Wrapping/decorating just a lot more convenient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.