0

We are using Vaadin7 in a larger OSGI (karaf 4) application and have the VaadinServlet declared using blueprint:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint default-activation="eager" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<!-- Vaadin servlet serving static Vaadin resources -->
<service interface="javax.servlet.Servlet">
  <service-properties>
    <entry key="servlet-name" value="Vaadin Resources" />
    <entry key="alias" value="/VAADIN-ui" />
    <entry key="contextId" value="app-vaadin" />
  </service-properties>
  <bean class="com.vaadin.server.VaadinServlet" />
</service>

By default Vaadin runs in debug mode and has a setting of ProductionMode which needs to set to true. This can done as a context-param but the application does not use a web.xml file. I've tried to set it as property of the bean but it is not recognised.

JamesP
  • 602
  • 6
  • 12

1 Answers1

0

You can extend VaadinServlet and use VaadinServletConfiguration annotation.

From docs:

Annotation for configuring subclasses of VaadinServlet. For a VaadinServlet class that has this annotation, the defined values are read during initialization and will be available using DeploymentConfiguration.getApplicationOrSystemProperty(String, String) as well as from specific methods in DeploymentConfiguration. Init params defined in web.xml or the @WebServlet annotation take precedence over values defined in this annotation.

You can use it like this:

@VaadinServletConfiguration(productionMode = false)
public class MyAppServlet extends VaadinServlet {
}
mczerwi
  • 490
  • 2
  • 11
  • Not sure how to go about that as none of the JAVA code declares a VaadinServlet, it is only referred to in the blueprint XML. In fact there are a couple of servlets declared in different bundles. The one above is just for handling resources, another starts up UIProvider class. – JamesP Jun 16 '17 at 14:01
  • You are using default `VaadinServlet` implementation (`com.vaadin.server.VaadinServlet`), that's why it's not in your Java code. You can create your own servlet class extending default one (it may be empty as in the example above) and then set it in your blueprint xml. Reading [offical docs](https://vaadin.com/docs/-/part/framework/application/application-environment.html) may help you to understand it better. – mczerwi Jun 16 '17 at 21:08
  • Thanks, I did read a lot of docs but managed not to have found that page. – JamesP Jun 19 '17 at 08:42