Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaladin 3.x Fails With Vaadin 7.1 #25

Closed
phancox opened this issue Jul 19, 2013 · 4 comments
Closed

Scaladin 3.x Fails With Vaadin 7.1 #25

phancox opened this issue Jul 19, 2013 · 4 comments

Comments

@phancox
Copy link

phancox commented Jul 19, 2013

What is required for Scaladin to work with Vaadin 7.1.0? Migrated from working setup with Vaadin 7.0.7 to Vaadin 7.1.0 and received the following exception.

Jul 19, 2013 9:17:16 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [sportzman-internet] in context with path [/sportzman] threw exception
java.lang.IllegalStateException: Can not process requests before init() has been called
at com.vaadin.server.VaadinService.requestStart(VaadinService.java:1239)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1318)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Scaladin was latest version built against Vaadin 7.0.7 libraries. Cannot build against Vaadin 7.1.0 libraries as I get compilation errors.

@phancox
Copy link
Author

phancox commented Jul 21, 2013

Appears as if there are a number of changes required to Scaladin 3.x in order for
it to work with Vaadin 7.1.0. It looks as if I've achieved this, though I would
treat my changes as a bit of a hack at the moment as I am relatively inexperienced
with Scala, Vaadin, and Scaladin itself. I'm also quite unfamiliar with GIT so
I haven't attempted to submit my local changes here. I will, however, document
what I have found in case it helps others in the same situation until the
migration can be addressed properly.

These are the changes required to Scaladin source in order to build against Vaadin 7.1.0

Changes required to Table.scala, TableTests.scala, and Validation.scala due to
Vaadin 7.1.0 use of varargs in some method signatures. Use ":_*" on the sequence
(instead of "toArray" to make the method call compatible.

Changes required to Converter.scala

package mixins {
  trait ConverterMixin[Presentation, Model] extends ScaladinMixin
  trait DelegatingConverterMixin[Presentation, Model] extends ConverterMixin[Presentation, Model] {
    self: com.vaadin.data.util.converter.Converter[Presentation, Model] =>

    override def wrapper = super.wrapper.asInstanceOf[Converter[Presentation, Model]]

    override def convertToModel(value: Presentation, targetType: Class[_ <: Model], locale: Locale): Model =
      wrapper.convertToModel(Option(value), locale).getOrElse(null).asInstanceOf[Model]

    override def convertToPresentation(value: Model, targetType: Class[_ <: Presentation], locale: Locale): Presentation =
      wrapper.convertToPresentation(Option(value), locale).getOrElse(null).asInstanceOf[Presentation]

    override def getPresentationType: Class[Presentation] = wrapper.presentationType

    override def getModelType: Class[Model] = wrapper.modelType
  }
}

abstract class DeletagePeerConverter[Presentation: ClassTag, Model: ClassTag](override val p: com.vaadin.data.util.converter.Converter[Presentation, Model] with ConverterMixin[Presentation, Model]) extends Converter[Presentation, Model](p) {

  def convertToPresentation(value: Option[Model], locale: Locale): Option[Presentation] =
    Option(p.convertToPresentation(value.getOrElse(null).asInstanceOf[Model], presentationType, locale))

  def convertToModel(value: Option[Presentation], locale: Locale): Option[Model] =
    Option(p.convertToModel(value.getOrElse(null).asInstanceOf[Presentation], modelType, locale))
}

@phancox
Copy link
Author

phancox commented Jul 21, 2013

And in order to fix the original "java.lang.IllegalStateException: Can not process requests before init() has been called"

Update ScaladinServlet.scala to insure init() method is invoked:

override def createServletService(c: com.vaadin.server.DeploymentConfiguration) = {
  val service = new ScaladinServletService(new com.vaadin.server.VaadinServletService(this, c) with ScaladinServletServiceMixin).p
  service.init()
  service
}

This one is very much a guess but appears to work for me.

@jdahlstrom
Copy link

Hi Peter, I'm a Vaadin core developer. These changes look correct. You might like to check out the migration guide - I added a mention of the requirement to invoke VaadinService.init(), thanks.

@ripla
Copy link
Collaborator

ripla commented Oct 31, 2013

Thanks for all the help and information, it's really appreciated. I'm closing this as the current 3.0 works with 7.1.7

@ripla ripla closed this as completed Oct 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants