[Beginner's Corner] - java.lang.ClassCastException when trying to access remote reference
by Pasquale Imbemba
Pasquale Imbemba [https://community.jboss.org/people/pi4630] created the discussion
"java.lang.ClassCastException when trying to access remote reference"
To view the discussion, visit: https://community.jboss.org/message/714061#714061
--------------------------------------------------------------
I'm trying to access a reference (SLSB that implements a remote interface) from a remote client.
try {
Context ctxt = new InitialContext(p);
ArrayList<String> listOfBeans = getBeanNames("Bean", ctxt);
for (int i = 0; i < listOfBeans.size(); i++) {
NamingEnumeration<Binding> b = ctxt.listBindings(listOfBeans.get(i));
while (b.hasMore()) {
Binding bind = b.next();
if (bind.getName().contains(string.toString().subSequence(0, string.toString().length()))) {
Object ref = bind.getObject();
doer = (IDoSmthg) PortableRemoteObject.narrow(ref, IDoSmthg.class);
doer = (IDoSmthg)ref;
return doer;
}
}
}
} catch (NamingException nE) {
nE.printStackTrace();
}
return null;
}
According to JNDI API, getObject() retrieves the object bound to the name of the binding.
>From the API book available online:
>
> When you use Context.listBindings(), you get back an enumeration of Binding(in the API reference documentation). You can invoke getObject()(in the API reference documentation) on each
> Binding to obtain the object in that binding. The result of getObject() is the same as that obtained by looking up the object by using Context.lookup()(in the API reference documentation).
>
So I'd expect that the narrowing would have been working. But it can't cast it, I get a javax.naming.Reference cannot be cast to org.omg.CORBA.Object Exception. In Debug, I see that what getObject() returns me, is a javax.naming.Reference.
How do I get this casted correctly, so to make a call on it? I know this is not the documented way to do it, but my approach shall solve: I know the Interface, search the bean on JNDI that implements it, get the reference, make the call.
Thanks in advance!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/714061#714061]
Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months
[EJB3] - EJB - MDB - Oracle AQ - Deploy Exception - No property found for: destination
by Mario Rossi
Mario Rossi [https://community.jboss.org/people/pacionet] created the discussion
"EJB - MDB - Oracle AQ - Deploy Exception - No property found for: destination"
To view the discussion, visit: https://community.jboss.org/message/714024#714024
--------------------------------------------------------------
We are using Jboss 5.1.0 and a Oracle 10g database.
*
+<ejb-jar version="3.0" >+
+<enterprise-beans>+
+<message-driven>+
+<ejb-name>TriggerEventDispatcher</ejb-name>+
+<ejb-class>it.trs.vts.wpo.dispatcher.trigger.TriggerUpdate</ejb-class>+
+<transaction-type>Bean</transaction-type>+
+<messaging-type>javax.jms.MessageListener</messaging-type>+
++
+</message-driven>+
+</enterprise-beans>+
*+<?xml version="1.0" encoding="UTF-8"?>+
I created an Oracle AQ on the db and I am trying to create a MessageDrivenBean so that some Oracle procedure can send message to the MDB.
When i deploy the EJB i see this exception:
org.jboss.deployers.spi.DeploymentException: Error for ActivationSpec class com.sun.genericra.inbound.ActivationSpec as JavaBean
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
at org.jboss.resource.deployment.ActivationSpecFactory.createActivationSpec(ActivationSpecFactory.java:135)
at org.jboss.resource.deployers.RARDeployment.createActivationSpec(RARDeployment.java:313)
at org.jboss.resource.deployers.RARDeployment.internalInvoke(RARDeployment.java:276)
[...]
Caused by: java.beans.IntrospectionException: *No property found for: destination on JavaBean*: com.sun.genericra.inbound.ActivationSpec@c806d893{ConnectionFactoryClassName (mailto:com.sun.genericra.inbound.ActivationSpec@c806d893{ConnectionFactoryClassName) = oracle.jms.AQjmsConnectionFactory},{QueueConnectionFactoryClassName = oracle.jms.AQjmsQueueConnectionFactory},{TopicConnectionFactoryClassName = oracle.jms.AQjmsTopicConnectionFactory},{XAConnectionFactoryClassName = oracle.jms.AQjmsXAConnectionFactory},{XAQueueConnectionFactoryClassName = oracle.jms.AQjmsXAQueueConnectionFactory},{XATopicConnectionFactoryClassName = oracle.jms.AQjmsXATopicConnectionFactory},{QueueClassName = null},{TopicClassName = null},{UnifiedDestinationClassName = oracle.jms.AQjmsDestination},{ConnectionFactoryProperties = null},{JndiProperties = null},{ProviderIntegrationMode = oracle},{CommonSetterMethodName = null},{SupportsXA = false},{RedeliveryInterval = 0},{RedeliveryAttempts = 0},{ClientID = null},{MessageSelector = null},{SubscriptionDurability = Non-Durable},{ConnectionFactoryJNDIName = null},{SubscriptionName = null},{DestinationJNDIName = null},{DestinationType = javax.jms.Destination},{DeadMessageDestinationType = javax.jms.Destination},{MaxPoolSize = 8},{DestinationProperties = null},{DeadMessageDestinationJndiName = null},{DeadMessageConnectionFactoryJndiName = null},{DeadMessageConnectionFactoryProperties = null},{DeadMessageDestinationClassName = null},{DeadMessageDestinationProperties = null},{SendBadMessagesToDMD = false},{EndpointReleaseTimeOut = 180},{InstanceCount = 1},{LoadBalancingRequired = true},{Instance ID = 0},{CustomLoadBalancingMessageSelector = },{ShareClientID = false}
at org.jboss.util.propertyeditor.PropertyEditors.mapJavaBeanProperties(PropertyEditors.java:354)
at org.jboss.util.propertyeditor.PropertyEditors.mapJavaBeanProperties(PropertyEditors.java:285)
at org.jboss.resource.deployment.ActivationSpecFactory.createActivationSpec(ActivationSpecFactory.java:129)
... 70 more
The messageDrivenBean is:
+@MessageDriven(name = "TriggerUpdate", activationConfig = {+
+ @ActivationConfigProperty(propertyName="destinationType", propertyValue = "javax.jms.Queue"),+
++ @ActivationConfigProperty(propertyName="destination", propertyValue = "MY_QUEUE+"),+
+ @ActivationConfigProperty(propertyName="connectionFactoryProperties", propertyValue="jdbc_connect_string=jdbc:oracle:thin:@192.168.13.104:1521:vtsdb,host=192.168.13.104,user=myuser,password=mypassword,port=1521,driver=oracle.jdbc.driver.OracleDriver"),+
+ @ActivationConfigProperty(propertyName="destinationProperties", propertyValue="owner=wpo,name=MY_QUEUE"),+
+ @ActivationConfigProperty(propertyName="user", propertyValue="myuser"),+
+ @ActivationConfigProperty(propertyName="password", propertyValue="mypassword"),+
+ @ActivationConfigProperty(propertyName="ConnectionFactoryClassName", propertyValue="oracle.jms.AQjmsConnectionFactory"),+
+ @ActivationConfigProperty(propertyName="QueueConnectionFactoryClassName", propertyValue="oracle.jms.AQjmsQueueConnectionFactory")+
+ })+
+@ResourceAdapter("oracleaq.rar")+
+(a)TransactionManagement(TransactionManagementType.BEAN)+
+public class TriggerUpdate implements MessageListener {+
+ +
+public void onMessage(Message message) {+
+ System.out.println("Message Received");+
+}+
++
+}+
The application is in a EAR.
The file oracleaq.rar is in the deploy folder of Jboss.
In the jboss.xml file inside the META-INF/ folder of the EJB jar i put:
+<?xml version="1.0"?>+
+<jboss>+
+ <enterprise-beans>+
+ <message-driven>+
+ <ejb-name>TriggerEventDispatcher</ejb-name>+
+ +
+ <invoker-bindings>+
+ <invoker>+
+ <invoker-proxy-binding-name>message-inflow-driven-bean</invoker-proxy-binding-name>+
+ </invoker>+
+ </invoker-bindings>+
+ +
+ <resource-adapter-name>oracleaq.rar</resource-adapter-name>+
+ </message-driven>+
+ </enterprise-beans>+
+</jboss>+
In the ejb-jar.xml:#
*
*
+</ejb-jar>+
It seems to me that the setting of destination property is correct but probably I am wrong some configuration, because many of the properties in the log are null.
What can I look for ?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/714024#714024]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months