[jboss-jira] [JBoss JIRA] (WFLY-13600) EJB client over HTTP Fail on Java SE
Cheng Fang (Jira)
issues at jboss.org
Sun Jul 5 12:17:53 EDT 2020
[ https://issues.redhat.com/browse/WFLY-13600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14199184#comment-14199184 ]
Cheng Fang commented on WFLY-13600:
-----------------------------------
When using http protocol, you will need to set up authentication, on both server side and client side. On the server side, run {{$JBOSS_HOME/bin/add-user.sh}} to set up application users. On the client side, configure it in {{wildfly-config.xml}}:
{code:xml}
<configuration>
<authentication-client xmlns="urn:elytron:client:1.2">
<authentication-rules>
<rule use-configuration="default"/>
</authentication-rules>
<authentication-configurations>
<configuration name="default">
<sasl-mechanism-selector selector="DIGEST-MD5"/>
<set-user-name name="user1"/>
<credentials>
<clear-password password="user1!!!"/>
</credentials>
... ...
</configuration>
</authentication-configurations>
</authentication-client>
</configuration>
{code}
> EJB client over HTTP Fail on Java SE
> ------------------------------------
>
> Key: WFLY-13600
> URL: https://issues.redhat.com/browse/WFLY-13600
> Project: WildFly
> Issue Type: Bug
> Components: EJB
> Affects Versions: 20.0.0.Final
> Reporter: Gergely Molnár
> Assignee: Cheng Fang
> Priority: Major
>
> Java SE code:
> {code:java}
> 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));
> }
> }
> {code}
> 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:
> {code:java}
> @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);
>
> }
> {code}
> Config:
> {code:xml}
> <?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>
> {code}
> Maven dependency:
> {code:xml}
> <dependency>
> <groupId>org.wildfly</groupId>
> <artifactId>wildfly-ejb-client-bom</artifactId>
> <version>20.0.0.Final</version>
> <type>pom</type>
> </dependency>
> {code}
>
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list