• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Access EJB from Swing App with Wildfly as AS  RSS feed

 
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I am sure this question gets asked a million times. And I bet the reason is because there is so many documents created with so many variations which for some crazy reason never seemed to work in my case. Its too bad how to do this couldnt be standardized and then remove all the wrong ways which are suggested out there. The implementation I am about to present came from a post who said they finally got it to work and this is how they did it. Except it didnt work for me.

First my environment:
Windows 7
Eclipse IDE Luna
Wildfly AS 8.1 using Standalone only no EAP
Have created a manager user which is the user I am using.
Database I am using as a datasource is DB2 9.7

EJB:
SampleBean is Webservice and Local which extends EJBInterface



EJBInterface:
SampleBeanInterface is Remote



Swing app has jboss-client.jar in build path as well as the EJB

ClientUtility:



Table Model Lookup function:




Error:
Jul 10, 2014 8:24:04 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Jul 10, 2014 8:24:05 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Jul 10, 2014 8:24:05 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Jul 10, 2014 8:24:05 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
Jul 10, 2014 8:24:07 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Jul 10, 2014 8:24:07 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@554850, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@c2c34a,channel=jboss.ejb,nodename=s160]} on channel Channel ID a8700422 (outbound) of Remoting connection 00aaeda6 to s160/10.143.74.86:8080
javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http:remoting://s160:8080 (No connection provider for URI scheme "http" is installed)]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.cs.db2Sample.swing.PlacesModel.lookup(PlacesModel.java:140)
at com.cs.db2Sample.swing.PlacesModel.<init>(PlacesModel.java:23)
at com.cs.db2Sample.swing.PeopleTable.<init>(PeopleTable.java:23)
at com.cs.db2Sample.swing.PeopleTable.createAndShowGUI(PeopleTable.java:57)
at com.cs.db2Sample.swing.PeopleTable.access$0(PeopleTable.java:47)
at com.cs.db2Sample.swing.PeopleTable$2.run(PeopleTable.java:74)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.cs.db2Sample.swing.PlacesModel.getAllPlaces(PlacesModel.java:113)
at com.cs.db2Sample.swing.PlacesModel.<init>(PlacesModel.java:24)
at com.cs.db2Sample.swing.PeopleTable.<init>(PeopleTable.java:23)
at com.cs.db2Sample.swing.PeopleTable.createAndShowGUI(PeopleTable.java:57)
at com.cs.db2Sample.swing.PeopleTable.access$0(PeopleTable.java:47)
at com.cs.db2Sample.swing.PeopleTable$2.run(PeopleTable.java:74)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

So, what am I doing wrong?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haven't fully read the post, but 2 quick things:


Have created a manager user which is the user I am using.


You need to create an application user and not a management user for allowing the remote EJB invocations.

The other one:


props.put(Context.PROVIDER_URL, "http:remoting://" + SERVER + ":" + PORT);


You seem to have a typo in there. It should be http-remoting and not http:remoting.
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
added new app user and changed the http-remoting and this is the new error:


Jul 10, 2014 8:55:26 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Jul 10, 2014 8:55:26 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Jul 10, 2014 8:55:27 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Jul 10, 2014 8:55:27 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
Jul 10, 2014 8:55:28 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Jul 10, 2014 8:55:28 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@554850, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@c2c34a,channel=jboss.ejb,nodename=s160]} on channel Channel ID cfec4ea4 (outbound) of Remoting connection 00d71c61 to s160/10.143.74.86:8080
Jul 10, 2014 8:55:29 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Jul 10, 2014 8:55:29 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@f0ac2b, receiver=Remoting connection EJB receiver [connection=Remoting connection <1a0034>,channel=jboss.ejb,nodename=s160]} on channel Channel ID e438dd51 (outbound) of Remoting connection 0065ad45 to s160/10.143.74.86:8080
javax.naming.NameNotFoundException: com.cs.db2Sample.service.SampleBeanInterface -- service jboss.naming.context.java.jboss.exported."com.cs.db2Sample.service.SampleBeanInterface"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.cs.db2Sample.swing.PlacesModel.getAllPlaces(PlacesModel.java:113)
at com.cs.db2Sample.swing.PlacesModel.<init>(PlacesModel.java:24)
at com.cs.db2Sample.swing.PeopleTable.<init>(PeopleTable.java:27)
at com.cs.db2Sample.swing.PeopleTable.createAndShowGUI(PeopleTable.java:61)
at com.cs.db2Sample.swing.PeopleTable.access$0(PeopleTable.java:51)
at com.cs.db2Sample.swing.PeopleTable$2.run(PeopleTable.java:78)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Jul 10, 2014 8:55:31 AM org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleEnd
INFO: EJBCLIENT000016: Channel Channel ID cfec4ea4 (outbound) of Remoting connection 00d71c61 to s160/10.143.74.86:8080 can no longer process messages
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed something that may or may not be relevant. As I have been checking out the admin console. I noticed the JNDI View. In this view it shows :

java:
java:Jboss
java:Jboss/exported
java:global
applications


I couldnt help notice there is no ejb: I wonder if that is what my problem is

final String JNDI = "ejb:" + APP + "/" + MODULE + "/" + DISTINCT + "/" + BEAN + "!" + INTERFACE;


If I open applications, I find the ear. in that I see java:app and inside that I find the EJB and in that I find the name for the EJB/Interface

If I open java:global, I find the ear, then the ejb, and then the ejb/Interface.

Does this help any?
 
Saloon Keeper
Posts: 2579
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you print-out the JNDI name that you assembled? It should be something like

ejb:wildflyDB2SampleEAR/wildflyDB2SampleEJB//SampleBean!com.cs.db2Sample.service.SampleBeanInterface
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ron. You are correct, I can print out the name and your guess as to what the name would be is correct. The part I cant figure out is how that solves my problem?
 
Ron McLeod
Saloon Keeper
Posts: 2579
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you deploy the EAR, do you see this in the list of JNDI bindings?

java:jboss/exported/wildflyDB2SampleEAR/wildflyDB2SampleEJB/SampleBean!com.cs.db2Sample.service.SampleBeanInterface
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is
 
Ron McLeod
Saloon Keeper
Posts: 2579
323
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the package name for the EJB interface?
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package com.cs.db2Sample.service;
 
Do you want ants? Because that's how you get ants. And a tiny ads:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!