簡體   English   中英

找不到JNDI名稱-如何在WCM工作流插件中使用JNDI?

[英]JNDI name not found - how to use JNDI in WCM workflow plugin?

我正在使用Rational Application Developer 8.5為WebSphere Portal 7.0中的IBM Web Content Manager(WCM)開發定制工作流操作插件。

該插件需要使用JNDI獲取JDBC數據源,但是我的所有嘗試都會產生此錯誤:

javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

在WebSphere Application Server中定義了一個名為“ jdbc / wcmbulletins”的數據源。

這是獲取數據源的Java代碼:

javax.naming.InitialContext ctx=new javax.naming.InitialContext();
javax.sql.DataSource ds=(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/wcmbulletins");

RAD項目僅包含以下XML文件。 沒有類似問題中提到的“ persistence.xml”或任何其他文件。
WCM JSP組件還引用了一些JSP文件。 JSP文件與插件無關,並且不使用JNDI或JDBC。

ibm-web-bnd.xml:

<web-bnd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
    <virtual-host name="default_host"/>
    <resource-ref name="jdbc/wcmbulletins" binding-name="jdbc/wcmbulletins"/>
</web-bnd>

ibm-web-ext.xml:

<web-ext
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
    <jsp-attribute name="reloadEnabled" value="false"/>
    <jsp-attribute name="reloadInterval" value="10"/>
    <reload-interval value="3"/>
    <enable-directory-browsing value="false"/>
    <enable-file-serving value="true"/>
    <enable-reloading value="true"/>
    <enable-serving-servlets-by-class-name value="true"/>
</web-ext>

plugin.xml:

<plugin id="com.company.wcm.CompanyWCMPlugins"
    name="Company WCM Plugins"
    version="1.0.0"
    provider-name="Company Name Australia">

    <extension
        point="com.ibm.workplace.wcm.api.CustomWorkflowActionFactory"
        id="CompanyWorkflowActionFactory">
        <provider class="com.company.wcm.workflow.CompanyWorkflowActionFactory"/>
    </extension>
</plugin>

web.xml:

<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>CompanyWCM_JSPs</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <resource-ref id="ResourceRef_1377568155870">
        <description/>
        <res-ref-name>jdbc/wcmbulletins</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
</web-app>

我需要什么來使JNDI查找工作?

如果您更改代碼以繞過資源引用並改用名稱jdbc/wcmbulletins會發生什么?

另外-DS的定義范圍是什么? 如果在集群級別,請嘗試使用名稱cell/persistent/jdbc/wcmbulletins並查看得到的結果。

最后-始終有WebSphere 命名跟蹤 您可以通過Naming=all啟用它們,重新運行您的應用程序,並檢查trace.log以了解可能發生的情況。

希望這可以幫助,

史考特

根據我的經驗,wcm插件在某種程度上與它們所包含的Web應用程序無關(它們與OSGI或更相關)。 例如,在服務器啟動期間,在Web應用程序本身之前就實例化了插件,因此甚至無法可靠地從Web應用程序中查找資源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM