Java 如果我更改 JNDI 端口,在 Eclipse 中关闭 JBoss 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/173487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 10:52:30  来源:igfitidea点击:

Problems with shutting down JBoss in Eclipse if I change JNDI port

javaeclipsejbossjboss-tools

提问by Balint Pato

1st phase

第一阶段

I have a problem shutting down my running JBoss instance under Eclipse since I changed the JNDI port of JBoss. Of course I can shut it down from the console view but not with the stop button (it still searches JNDI port at the default 1099 port). I'm looking forward to any solutions. Thank you!

由于我更改了 JBoss 的 JNDI 端口,因此在 Eclipse 下关闭正在运行的 JBoss 实例时遇到问题。当然,我可以从控制台视图关闭它,但不能使用停止按钮(它仍然在默认的 1099 端口搜索 JNDI 端口)。我期待着任何解决方案。谢谢!

Used environment:

使用环境:

  • JBoss 4.0.2 (using default)
  • Eclipse 3.4.0. (using JBoss Tools 2.1.1.GA)
  • JBoss 4.0.2(使用默认
  • 日食 3.4.0。(使用 JBoss 工具 2.1.1.GA)

Default ports: 1098, 1099 Changed ports: 11098, 11099

默认端口:1098、1099 更改端口:11098、11099

I changed the following part in jbosspath/server/default/conf/jboss-service.xml:

我在 jbosspath/server/default/conf/jboss-service.xml 中更改了以下部分:

   <!-- ==================================================================== -->
   <!-- JNDI                                                                 -->
   <!-- ==================================================================== -->

   <mbean code="org.jboss.naming.NamingService"
      name="jboss:service=Naming"
      xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
      <!-- The call by value mode. true if all lookups are unmarshalled using
      the caller's TCL, false if in VM lookups return the value by reference.
      -->
      <attribute name="CallByValue">false</attribute>
      <!-- The listening port for the bootstrap JNP service. Set this to -1
        to run the NamingService without the JNP invoker listening port.
      -->
      <attribute name="Port">11099</attribute>
      <!-- The bootstrap JNP server bind address. This also sets the default
      RMI service bind address. Empty == all addresses
       -->
      <attribute name="BindAddress">${jboss.bind.address}</attribute>
      <!-- The port of the RMI naming service, 0 == anonymous -->
      <attribute name="RmiPort">11098</attribute>
      <!-- The RMI service bind address. Empty == all addresses
       -->
      <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
      <!-- The thread pool service used to control the bootstrap lookups -->
      <depends optional-attribute-name="LookupPool"
         proxy-type="attribute">jboss.system:service=ThreadPool</depends>
   </mbean>

   <mbean code="org.jboss.naming.JNDIView"
        name="jboss:service=JNDIView"
        xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
   </mbean>

Eclipse setup:

日食设置:

About my JBoss Tools preferences:I had a previous version, I got this problem, I read about some bugfix in JbossTools, so updated to 2.1.1.GA. Now the buttons changed, and I've got a new preferences view, but I cannot modify anything...seems to be abnormal as well:

关于我的 JBoss Tools 偏好:我有一个以前的版本,我遇到了这个问题,我读到了 JbossTools 中的一些错误修正,所以更新到 2.1.1.GA。现在按钮改变了,我有一个新的首选项视图,但我不能修改任何东西......似乎也不正常:

Error dialog:

错误对话框:

The stacktrace:

堆栈跟踪:

javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at org.jboss.Shutdown.main(Shutdown.java:202)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
    ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:228)
    ... 5 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at java.net.Socket.<init>(Socket.java:309)
    at java.net.Socket.<init>(Socket.java:211)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
    ... 5 more
Exception in thread "main" 

2nd phase:

第二阶段:

After creating a new Server in File/new/other/server, it did appear in the preferences tab. Now the stop button is working (the server receives the shutdown messages without any additional modification of the jndi port -- there is no opportunity for it now) but it still throws an error message, though different, it's without exception stack trace: "Server JBoss 4.0 Server failed to stop."

在 File/new/other/server 中创建新服务器后,它确实出现在首选项选项卡中。现在停止按钮正在工作(服务器在没有对 jndi 端口进行任何额外修改的情况下接收关闭消息 - 现在没有机会)但它仍然抛出错误消息,尽管不同,但堆栈跟踪无一例外:“服务器JBoss 4.0 服务器无法停止。”

采纳答案by skaffman

OK, what you have to do is File->New->Other->Server, and set up your JBoss server there. It will then appear in Preferences->JBossTools->Servers.

好的,您需要做的是 File->New->Other->Server,然后在那里设置您的 JBoss 服务器。然后它会出现在 Preferences->JBossTools->Servers 中。

Convoluted.

错综复杂。

回答by huo73

In MyEclipse server configuration, you find the field "Optional Shutdown Argument", which is filled with the default value

在MyEclipse服务器配置中,找到“Optional Shutdown Argument”字段,填写默认值

--shutdown

Change it to

将其更改为

-s jnp://localhost:11099 --shutdown

Edited:

编辑:

Sorry, this answer is related to MyEclipse. However, there must be some place where you can specify the JBoss shutdown command in your environment as well. Maybe you take a look at the "Run..." configurations?

抱歉,此答案与 MyEclipse 相关。但是,您的环境中也必须有一些地方可以指定 JBoss 关闭命令。也许你看看“运行...”配置?

回答by skaffman

you should modify in the file "/home/fmoisa/workspace/eclipse/plugins/org.eclipse.jst.server.generic.jboss_1.5.206.v20090115/servers/jboss42.serverdef" this:

您应该在文件“/home/fmoisa/workspace/eclipse/plugins/org.eclipse.jst.server.generic.jboss_1.5.206.v20090115/servers/jboss42.serverdef”中修改:

org.jboss.Shutdown ${serverRootDirectory}/bin -S -Djboss.boot.loader.name=shutdown.bat jboss.shutdown

org.jboss.Shutdown ${serverRootDirectory}/bin -S -Djboss.boot.loader.name=shutdown.bat jboss.shutdown

to this:

对此:

org.jboss.Shutdown ${serverRootDirectory}/bin -S -sjnp://localhost:11099 -Djboss.boot.loader.name=shutdown.bat jboss.shutdown

org.jboss.Shutdown ${serverRootDirectory}/bin -S -sjnp://localhost:11099 -Djboss.boot.loader.name=shutdown.bat jboss.shutdown

gl all ;)

全部 ;)

回答by Max Rydahl Andersen

Use the server adapter provided by JBoss tools and not the one that comes default from Eclipse WTP.

使用 JBoss 工具提供的服务器适配器,而不是来自 Eclipse WTP 的默认适配器。

Then you can simply double click on the server and you can edit the JNDI port (which btw. is automatically picked up from the XML configuration if you don't do any thing). You can also do the trick about setting the JNDI port via command line arguments in the Launch Configuration but that is more trouble than just setting the port values.

然后你可以简单地双击服务器,你可以编辑 JNDI 端口(顺便说一句,如果你不做任何事情,它会从 XML 配置中自动获取)。您还可以通过 Launch Configuration 中的命令行参数设置 JNDI 端口,但这比仅设置端口值更麻烦。

回答by Max Rydahl Andersen

Here is a detailed fix for this problem: The Eclipse WTP server connector won't shut down JBoss when the jndi port is remapped.

以下是针对此问题的详细修复: 重新映射 jndi 端口时,Eclipse WTP 服务器连接器不会关闭 JBoss。

This is because the default server connector profiles don't use their own alias for the jndiPort. This problem is also discussed at eclipse.org: http://www.eclipse.org/forums/index.php?t=msg&goto=489439&S=0db4920aab0a501c80a626edff84c17d#msg_489439

这是因为默认服务器连接器配置文件不使用它们自己的 jndiPort 别名。eclipse.org 也讨论了这个问题:http: //www.eclipse.org/forums/index.php?t =msg&goto =489439&S =0db4920aab0a501c80a626edff84c17d#msg_489439

The solution comes from the .serverdef files in eclipse:

解决方案来自eclipse中的.serverdef文件:


<eclipse>\plugins\org.eclipse.jst.server.generic.jboss_1.5.105.v200709061325\servers\jboss*.serverdef

They declare an xml property for the jndi port:

他们为 jndi 端口声明了一个 xml 属性:


<property id="jndiPort"
 label="%jndiPort"
 type="string"
 context="server"
 default="1099" /> 

This simply needs to be used where the serverdef has the STOP command coded:

这只需要在 serverdef 具有 STOP 命令编码的地方使用:

So this:

所以这:


 <stop>
  <mainClass>org.jboss.Shutdown</mainClass>
  <workingDirectory>${serverRootDirectory}/bin</workingDirectory>
  <programArguments>-S</programArguments>
  <vmParameters></vmParameters>
  <classpathReference>jboss</classpathReference>
 </stop>

becomes this:

变成这样:


 <stop>
  <mainClass>org.jboss.Shutdown</mainClass>
  <workingDirectory>${serverRootDirectory}/bin</workingDirectory>
  <programArguments>-s jnp://${serverAddress}:${jndiPort}</programArguments>
  <vmParameters></vmParameters>
  <classpathReference>jboss</classpathReference>
 </stop>

The philosophy for this can be verified by comparison to the definition for the jndi connection:

可以通过与 jndi 连接的定义进行比较来验证其原理:


 <jndiConnection>
  <providerUrl>jnp://${serverAddress}:${jndiPort}</providerUrl>
<initialContextFactory>org.jnp.interfaces.NamingContextFactory</initialContextFactory>
  <jndiProperty>
   <name></name>
   <value></value>
  </jndiProperty>
 </jndiConnection>

Credit for the inspiration for this general case fix goes to: Moisa Laurentiu Florin. It was their contribution that got me to look for a way of substituting in the ${jndiPort} instead of a hard coded value.

此通用案例修复的灵感来自:Moisa Laurentiu Florin。正是他们的贡献让我寻找一种方法来替换 ${jndiPort} 而不是硬编码值。

This fix corrects both plain Eclipse WTP server connector. I'm still investigating the JBOss IDE connector

此修复更正了普通 Eclipse WTP 服务器连接器。我仍在研究 JBOss IDE 连接器

回答by Wolfgang

This was changed in JBoss 6.0.0M3.

这在 JBoss 6.0.0M3 中有所改变。

The stop command is now:

停止命令现在是:

"- s service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"

"-s 服务:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"

Note that the port also changed: It is no longer the JNDI port at 1099, but RMI/JMX port 1090. So, you will need another config parameter in the server definition.

请注意,端口也发生了变化:它不再是 1099 处的 JNDI 端口,而是RMI/JMX 端口 1090。因此,您将需要服务器定义中的另一个配置参数。

I don't know whether the "JNDI port" parameter is required at all for JBoss 6.0.0M3 servers.

我不知道 JBoss 6.0.0M3 服务器是否需要“JNDI 端口”参数。

I have a modified eclipse plugin at http://www.cs.hs-rm.de/~knauf/public/which contains a server definition for 6.0.0M3 including this change. This site also links to a JBoss forum thread with more details about this change.

我在http://www.cs.hs-rm.de/~knauf/public/有一个经过修改的 eclipse 插件,其中包含 6.0.0M3 的服务器定义,包括此更改。此站点还链接到 JBoss 论坛主题,其中包含有关此更改的更多详细信息。

Best regards

此致

Wolfgang Knauf

沃尔夫冈·可瑙夫

回答by Martín Sánchez

Open jboss-path\bin\shutdown.jar

打开 jboss-path\bin\shutdown.jar

example: jboss-4.2.3.GA\bin\shutdown.jar

示例:jboss-4.2.3.GA\bin\shutdown.jar

and open jboss-path\bin\shutdown.jar\jndi.properties

并打开 jboss-path\bin\shutdown.jar\jndi.properties

and change

和改变

java.naming.provider.url=jnp://localhost:1099 to java.naming.provider.url=jnp://localhost:11099

java.naming.provider.url=jnp://localhost:1099 到 java.naming.provider.url=jnp://localhost:11099