在Glassfish 4.1.1自定义资源上进行JNDI查找

编程入门 行业动态 更新时间:2024-10-14 06:17:10
本文介绍了在Glassfish 4.1.1自定义资源上进行JNDI查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用JNDI自定义资源直接在我的服务器(Glassfish)中存储数据,但它显然无法正常工作。

I am trying to use JNDI custom resources to store data directly in my server (Glassfish) but it is apparently not working.

我将JNDI定义为下面的图片

I define my JNDI as on the image below

,对应于以下说明在我的domain.xml中。

which corresponds to the following description in my domain.xml.

<custom-resource factory-class="org.glassfish.resources.custom.factory.PrimitivesAndStringFactory" res-type="java.lang.String" jndi-name="projectStage"> <property name="value" value="UnitTest"></property> </custom-resource>

然后,我试图在我的托管bean中获取此值。

And then, i am trying to get this value in one of my managed bean.

Context c = new InitialContext(); c.lookup("projectStage");

但是...... javax.naming.NamingException:'projectStage查找失败'是我唯一得到的。

But... javax.naming.NamingException: Lookup failed for 'projectStage' is the only thing i get from it.

如果有人对我有所了解,我会很感激!

If anyone has an idea for me, i will be thankful !

推荐答案

解决了!

我正在手动编辑我的domain.xml以添加我的JNDI自定义资源,因为Glassfish 4.1.1管理界面在点击新建时出现运行时错误... 在JNDI自定义资源部分。

I was editing my domain.xml manually to add my JNDI custom resource as Glassfish 4.1.1 administration interface gives an Runtime error when clicking on New... on the JNDI Custom Resource section.

编辑完 domain.xml 文件后,显示在管理面板中,但显然没有正常工作。

Once the domain.xml file edited, it was displayed well in the administration panel but apparently not properly working.

我用 create-custom-resource asadmin控制台的命令解释此处。

I have created the custom resource with the create-custom-resource command of the asadmin console explains here.

create-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property "value=UnitTest" projectStage

然后它看起来被正确添加到系统。 (看起来它不仅存储在 domain.xml 文件中)

And then it looks to be properly added to the system. (looks like it is not only stored in the domain.xml file)

更多推荐

在Glassfish 4.1.1自定义资源上进行JNDI查找

本文发布于:2023-11-21 23:43:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615134.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   资源   Glassfish   JNDI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!