Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

Used environment:

  • JBoss 4.0.2 (using default)
  • Eclipse 3.4.0. (using JBoss Tools 2.1.1.GA)

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

I changed the following part in 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:

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."

like image 450
Balint Pato Avatar asked Oct 06 '08 07:10

Balint Pato


1 Answers

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

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

The solution comes from the .serverdef files in eclipse:


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

They declare an xml property for the jndi port:


<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:

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:


 <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.

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

like image 196
2 revsLouis Avatar answered Nov 09 '22 14:11

2 revsLouis