Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13600

EJB client over HTTP Fail on Java SE

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 20.0.0.Final
    • EJB
    • None
      • Start server
      • Wait for server
      • Start client (remote+http work fine, pure http cause exception)
    • Compatibility/Configuration
    • Mark it as resolved. Feel free to reopen if you still see problems.

    Description

      Java SE code:

      public class Application {
       private static final String REMOTE_CALC = "ejb:/remote-ejb/RemoteCalc!" + RemoteCalc.class.getName();
      
      /**
       * Lookup remote \{@link RemoteCalc}.
       * 
       * @return a \{@link RemoteCalc} object
       * @throws NamingException Something is wrong
       */
       public static RemoteCalc getRemoteCalc() throws NamingException {
       Hashtable<String, Object> jndiProps = new Hashtable<>();
       jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
       // remote+http connection (work fine)
       //jndiProps.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080/remote-ejb");
       // http connection (fail)
       jndiProps.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/wildfly-services");
       Context context = new InitialContext(jndiProps);
      
      return (RemoteCalc) context.lookup(REMOTE_CALC);
       }
      
      /**
       * Call to run (main).
       * 
       * @param args parameters (not used)
       * @throws NamingException Something is wrong
       */
       public static void main(String[] args) throws NamingException {
       
       RemoteCalc remoteCalc = getRemoteCalc();
       System.out.println("Remote calc 95 + 76: " + remoteCalc.add(95, 76));
       }
      }
      

      Exception:
      Exception in thread "main" javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name "http"
      at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:808)
      at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:140)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at com.bosch.emea.bpart.remoteejbclient.Application.getRemoteCalc(Application.java:34)
      at com.bosch.emea.bpart.remoteejbclient.Application.main(Application.java:47)

      Lib:

      @Remote
      public interface RemoteCalc {
       /**
       * Add two integer.
       * 
       * @param a an integer
       * @param b an integer
       * @return a + b
       */
       public int add(int a, int b);
       
      }
      

      Config:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
       <authentication-client xmlns="urn:elytron:1.0">
       <authentication-rules>
       <rule use-configuration="default" />
       </authentication-rules>
       <authentication-configurations>
       <configuration name="default">
       <sasl-mechanism-selector selector="#ALL" />
       <set-mechanism-properties>
       <property key="wildfly.sasl.local-user.quiet-auth" value="true" />
       </set-mechanism-properties>
       <providers>
       <use-service-loader/>
       </providers>
       </configuration>
       </authentication-configurations>
       </authentication-client>
      </configuration>
      

      Maven dependency:

      <dependency>
       <groupId>org.wildfly</groupId>
       <artifactId>wildfly-ejb-client-bom</artifactId>
       <version>20.0.0.Final</version>
       <type>pom</type>
      </dependency>
      

       

      Attachments

        Activity

          People

            cfang@redhat.com Cheng Fang
            theonlinewolf Gergely Molnár (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: