2014-03-12 46 views
0

到目前爲止,我有:Social Business Toolkit示例應用程序如何使用managed-beans.xml?

  • 安裝和我的WebSphere Application 服務器,
  • 增加了一個URL資源的SBT屬性文件啓動sbt.sample-1.0.0.20140125-1133.ear

Social Business Toolkit示例應用運行良好,我可以連接到IBM Connections並檢索一些ActivityStream條目。

當我第一次加載應用程序,我注意到了這個錯誤:

Exception stack trace: com.ibm.websphere.naming.CannotInstantiateObjectException: A NameNotFoundException occurred on an indirect lookup on the name java:comp/env/url/ibmsbt-managedbeansxml. The name java:comp/env/url/ibmsbt-managedbeansxml maps to a JNDI name in deployment descriptor bindings for the application performing the JNDI lookup. Make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. 

在樣本應用程序的ibm-web-bnd.xml文件,我發現這行:

<resource-ref name="url/ibmsbt-managedbeansxml" binding-name="url/ibmsbt-managedbeansxml" /> 

而在web.xml

<resource-ref> 
    <description>Reference to a URL resource which points to the managed bean configuration for the Social Business Toolkit.</description> 
    <res-ref-name>url/ibmsbt-managedbeansxml</res-ref-name> 
    <res-type>java.net.URL</res-type> 
    <res-auth>Container</res-auth> 
    <res-sharing-scope>Shareable</res-sharing-scope> 
</resource-ref> 



我想知道,爲什麼應該有一個URL資源的JSF應用程序配置資源文件(managed-beans.xml)首先?根據Java EE文檔,JavaServer Faces實現將在/WEB-INF/文件夾中查找它。

SBT是否在某處使用JavaServer Faces技術?或者我可以選擇不使用managed-beans.xml文件在我自己的應用程序中使用SBT?

回答

1

我不會建議你考慮他們有關。 managed-beans.xml有一個名稱,它只是一組配置對象。該項目本身不使用Java Server Faces。

+0

感謝您的快速回復! – magnetronnie

+1

我要求馬克驗證答案,所以如果有任何更新,他會添加一個答案 –

1

我剛剛再次閱讀文檔,比第一次更仔細,我想我現在對第二個問題中的問題有了更好的理解。從documentation

In a web application SBTFilter (HTTP servlet filter) is responsible for initializing the application using servlet context. Application does the initialization like loading the managed beans and properties factories.

示例應用程序是一個Web應用程序。我認爲在我自己的應用程序中,我可以選擇使用com.ibm.commons.runtime.impl.app.ApplicationStandalone而不是com.ibm.commons.runtime.impl.servlet.ApplicationServlet,然後以編程方式配置端點。或者根本不使用應用程序,如下所示:

RuntimeFactory runtimeFactory = new RuntimeFactoryStandalone(); 
Application application = runtimeFactory.initApplication(null); 
Context.init(application, null, null);