2014-01-26 58 views
3

我有一個Vaadin項目,我正在嘗試創建兩個UI 我有2個類。第一:Vaadin 2 servlets - 運行在Tomcat7

ConfirmUI.java

@Theme("dm") 
@SuppressWarnings("serial") 
public class ConfirmUI extends UI{ 

    private static final long serialVersionUID = 8015006014121297134L; 

    @WebServlet(value = {"/confirm/*", "/VAADIN/*"}, asyncSupported = true) 
// @WebServlet(value = {"/dm/*", "/VAADIN/*"}, asyncSupported = true) 
    @VaadinServletConfiguration(productionMode = false, ui = ConfirmUI.class, widgetset = "m4team.dm.widgetset.DmWidgetset") 
    public static class Servlet extends VaadinServlet { 

     private static final long serialVersionUID = 5269739354418135390L; 
    } 

    @Override 
    protected void init(VaadinRequest request) { 
     Page.getCurrent().setTitle("DM | Register"); 

    } 

} 

其次:

DmUI.java

@Theme("dm") 
@JavaScript("http://www.google.com/recaptcha/api/js/recaptcha_ajax.js") 
public class DmUI extends UI { 


// @WebServlet(value = "/*", asyncSupported = true) 
    @WebServlet(value = {"/dm/*", "/VAADIN/*"}, asyncSupported = true) 
    @VaadinServletConfiguration(productionMode = false, ui = DmUI.class, widgetset = "m4team.dm.widgetset.DmWidgetset") 
    public static class Servlet extends VaadinServlet { 
    } 

    @Override 
    protected void init(final VaadinRequest request) { 


     Page.getCurrent().setTitle("DM"); 



      @Override 
      public void afterViewChange(ViewChangeEvent event) { 
       // TODO Auto-generated method stub     
      } 
     });   
    } 

} 

當他們單獨運行它的工作原理(當其中一個被註釋掉)。 但當我都取消註釋,並嘗試在Tomcat的7運行它們,我得到這樣一個錯誤:

Server Tomcat v7.0 Server at localhost failed to start. 

和:

SEVERE: A child container failed during start 
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DM]] 
     at java.uti 

    l.concurrent.FutureTask$Sync.innerGet(Unknown Source) 
     at java.util.concurrent.FutureTask.get(Unknown Source) 
     at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) 
     at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
     at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 
     at java.util.concurrent.FutureTask.run(Unknown Source) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
     at java.lang.Thread.run(Unknown Source) 
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DM]] 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
     ... 7 more 

Caused by: java.lang.IllegalArgumentException: The servlets named [m4team.dm.ui.view.ConfirmUI$Servlet] and [m4team.dm.ui.view.DmUI$Servlet] are both mapped to the url-pattern [/VAADIN/*] which is not permitted 
    at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:335) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2466) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2148) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2109) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102) 
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2102) 
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1293) 
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878) 
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376) 
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
... 7 more 

,所以我認爲這個問題可能會在這裏:

Caused by: java.lang.IllegalArgumentException: The servlets named [m4team.dm.ui.view.ConfirmUI$Servlet] and [m4team.dm.ui.view.DmUI$Servlet] are both mapped to the url-pattern [/VAADIN/*] which is not permitted 

有沒有人有任何解決方案?

的問題與此類似16270619但我沒有web.xml中

回答

0

/VAADIN/*只對靜態文件。除了應用程序映射的位置之外,它還需要可用。

正常的設置是將/*映射到Vaadin servlet和靜態資源。

隨着@WebServlet註釋爲一個servlet類,你可以定義多個映射,如大括號括起來的列表如下:

@WebServlet(value = {"/myui/*", "/VAADIN/*"}, 
      asyncSupported = true) 

如果你已經使用了web.xml它會是什麼樣子 -

<servlet-mapping> 
    <servlet-name>myservlet</servlet-name> 
    <url-pattern>/myui/*</url-pattern> 
</servlet-mapping> 

<servlet-mapping> 
    <servlet-name>myservlet</servlet-name> 
    <url-pattern>/VAADIN/*</url-pattern> 
</servlet-mapping> 

如果您有多個servlet,則應該只指定一個/VAADIN/*映射。無論您將該模式映射到哪個servlet,只要它是一個服務器小程序即可。

參見

+0

,但我有一個映射/ VAADIN/*和它不工作 - URL模式[/ VAADIN/*]這是不允許的。 – m4koon

+0

在代碼中,你有兩個。 –

+0

好的我看到問題在哪裏,謝謝你的幫助 – m4koon