[EJB 3.0] - ClassCastException: $Proxy94 cannot be cast ...
by ttrepper
Hi all,
I am using JBoss 4.2.2GA and Java(TM) SE Runtime Environment (build 1.6.0_05-b13) for my development environment.
I have a stateless session bean called UtilityBean and an interfaces called UtilityBeanLocal, marked with @Local and the bean marked with @stateless and implements serializable and the local-interface.
When I try to make a lookup through InitalContext I get a Proxy-Object, which cannot be casted to the local interface.
Stacktrace:
anonymous wrote :
| 20:05:44,843 ERROR [STDERR] java.lang.ClassCastException: $Proxy94 cannot be cast to test.ejb.stateless.UtilityBeanLocal
| 20:05:44,843 ERROR [STDERR] at test.service.helper.ApplicationHelper.getApplicationSettings(ApplicationHelper.java:23)
| 20:05:44,843 ERROR [STDERR] at test.service.helper.RegistrationHelper.isUsernameLongEnough(RegistrationHelper.java:32)
| 20:05:44,843 ERROR [STDERR] at test.web.beans.RegistrationBean.checkUserComplete(RegistrationBean.java:395)
| 20:05:44,843 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| 20:05:44,843 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| 20:05:44,843 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| 20:05:44,843 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
| 20:05:44,843 ERROR [STDERR] at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
| 20:05:44,843 ERROR [STDERR] at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
| 20:05:44,843 ERROR [STDERR] at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
| 20:05:44,843 ERROR [STDERR] at javax.faces.validator.MethodExpressionValidator.validate(MethodExpressionValidator.java:84)
| 20:05:44,843 ERROR [STDERR] at javax.faces.component.UIInput.validateValue(UIInput.java:1013)
| 20:05:44,843 ERROR [STDERR] at javax.faces.component.UIInput.validate(UIInput.java:867)
| 20:05:44,843 ERROR [STDERR] at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
| 20:05:44,843 ERROR [STDERR] at javax.faces.component.UIInput.processValidators(UIInput.java:666)
| 20:05:44,843 ERROR [STDERR] at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:335)
| 20:05:44,843 ERROR [STDERR] at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
| 20:05:44,843 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
| 20:05:44,843 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| 20:05:44,843 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| 20:05:44,843 ERROR [STDERR] at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
| 20:05:44,843 ERROR [STDERR] at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| 20:05:44,843 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| 20:05:44,843 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| 20:05:44,843 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
| 20:05:44,843 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| 20:05:44,843 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
| 20:05:44,843 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| 20:05:44,843 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
| 20:05:44,843 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
| 20:05:44,843 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
The following code shows the part, which displays all implemented interfaces of the object:
| System.out.println(obj.getClass().getName());
| Class[] interfaces = obj.getClass().getInterfaces();
| for (int i = 0; i < interfaces.length; ++i) {
| System.out.println(interfaces.getName());
| }
Output:anonymous wrote : 20:05:44,843 INFO [STDOUT] $Proxy94
| 20:05:44,843 INFO [STDOUT] test.ejb.stateless.UtilityBeanLocal
| 20:05:44,843 INFO [STDOUT] org.jboss.ejb3.JBossProxy
Stateless Bean:
| @Stateless
| public class UtilityBean implements UtilityBeanLocal, Serializable, Constants {
| private static final long serialVersionUID = 1L;
| ......
|
Interface:
| @Local
| public interface UtilityBeanLocal {
| public static final String JNDI_NAME = "UtilityBeanLocal";
| public ApplicationSettings getApplicationSettings();
| }
Context-Lookup:
| public class BeanLocator {
| public static final String JNDI_PREFIX = "java:comp/env/ejb/";
| private static transient BeanLocator instance = null;
| private InitialContext initialcontext = null;
|
| //--------------------------------------------------------------------------
| private BeanLocator() {
| try {
| Properties props = new Properties();
| props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
| props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
| props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming.jnp.interfaces");
| //Context ctx = new InitialContext(props);
| this.initialcontext = new InitialContext(props);
| } catch (NamingException e) {
| //e.printStackTrace();
| this.initialcontext = null;
| }
| }
|
| //--------------------------------------------------------------------------
| public static BeanLocator getInstance() {
| if (instance == null) {
| instance = new BeanLocator();
| }
| return instance;
| }
|
| //--------------------------------------------------------------------------
| public Object locate(String jndiName, Class<?> clazz) throws NamingException {
| Object obj = null;
| if (this.initialcontext != null) {
| //obj = PortableRemoteObject.narrow(initialcontext.lookup(jndiName), clazz);
| obj = initialcontext.lookup(jndiName);
|
| System.out.println(obj.getClass().getName());
| Class[] interfaces = obj.getClass().getInterfaces();
| for (int i = 0; i < interfaces.length; ++i) {
| System.out.println(interfaces.getName());
| }
| }
| return obj;
| }
| }
It is not working with or without passing the properties to the context.
The main question is, why I cannot cast, even if the interface is implemented???
What am I missing? Does anybody has a clue?
Thanks in advance and best regards,
Thomas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142485#4142485
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142485
18 years
[Messaging, JMS & JBossMQ] - Problem with deploying a MDB
by lochaber
I am tring to deploy a Message Driven Bean.
I have ejb-jar.xml included in the depoyed war file and a jboss.xml file in
... /jboss-4.2.2.GA/server/default/deploy/jms
The queue lives in the file jbossmq-destinations-service.xml
Am I missing a file? Can I use a war file or do I need a jar.
Here is the snippeshow ing the queue
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
The ejb-xml.jar file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>PushTriggerMDB</ejb-name>
<ejb-class>com.netthruput.wireless.mdb.PushTriggerMDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<res-ref-name>jms/QCF</res-ref-name>
<resource-ref>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
The jboss.xml file is
<?xml version="1.0"?>
<enterprise-beans>
<message-driven>
<ejb-name>TextMDB</ejb-name>
<destination-jndi-name>queue/B</destination-jndi-name>
<resource-ref>
<res-ref-name>jms/QCF</res-ref-name>
<jndi-name>ConnectionFactory</jndi-name>
</resource-ref>
</message-driven>
</enterprise-beans>
Here is the output
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /devl/wireless/jboss-4.2.2.GA
JAVA: /usr/j2se/bin/java
JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=360000
0
CLASSPATH: /devl/wireless/jboss-4.2.2.GA/bin/run.jar:/usr/j2se/lib/tools.jar
=========================================================================
12:04:22,469 INFO [Server] Starting JBoss (MX MicroKernel)...
12:04:22,472 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)
12:04:22,476 INFO [Server] Home Dir: /devl/wireless/jboss-4.2.2.GA
12:04:22,476 INFO [Server] Home URL: file:/devl/wireless/jboss-4.2.2.GA/
12:04:22,478 INFO [Server] Patch URL: null
12:04:22,479 INFO [Server] Server Name: default
12:04:22,479 INFO [Server] Server Home Dir: /devl/wireless/jboss-4.2.2.GA/server/default
12:04:22,480 INFO [Server] Server Home URL: file:/devl/wireless/jboss-4.2.2.GA/server/default/
12:04:22,480 INFO [Server] Server Log Dir: /devl/wireless/jboss-4.2.2.GA/server/default/log
12:04:22,481 INFO [Server] Server Temp Dir: /devl/wireless/jboss-4.2.2.GA/server/default/tmp
12:04:22,482 INFO [Server] Root Deployment Filename: jboss-service.xml
12:04:23,345 INFO [ServerInfo] Java version: 1.5.0_09,Sun Microsystems Inc.
12:04:23,346 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_09-b01,Sun Microsystems Inc.
12:04:23,346 INFO [ServerInfo] OS-System: SunOS 5.8,sparc
12:04:24,826 INFO [Server] Core system initialized
12:04:31,812 INFO [WebService] Using RMI server codebase: http://192.168.120.59:8083/
12:04:31,850 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
12:04:33,783 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
12:04:33,784 INFO [TransactionManagerService] Setting up property manager MBean and JMX layer
12:04:34,766 INFO [TransactionManagerService] Starting recovery manager
12:04:35,535 INFO [TransactionManagerService] Recovery manager started
12:04:35,536 INFO [TransactionManagerService] Binding TransactionManager JNDI Reference
12:04:47,107 INFO [EJB3Deployer] Starting java:comp multiplexer
12:04:47,985 INFO [STDOUT] no object for null
12:04:47,993 INFO [STDOUT] no object for null
12:04:48,060 INFO [STDOUT] no object for null
12:04:48,129 INFO [STDOUT] no object for {urn:jboss:bean-deployer}supplyType
12:04:48,164 INFO [STDOUT] no object for {urn:jboss:bean-deployer}dependsType
12:04:56,886 INFO [NativeServerConfig] JBoss Web Services - Native
12:04:56,887 INFO [NativeServerConfig] jbossws-native-2.0.1.SP2 (build=200710210837)
12:05:00,327 INFO [Embedded] Catalina naming disabled
12:05:00,952 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was
not found on the java.library.path: /devl/etsys/jdk1.5.0_09/jre/lib/sparc/server:/devl/etsys/jdk1.5.0_09/jre/lib/sparc:/devl/etsys/jdk1.5.0
_09/jre/../lib/sparc:/usr/lib
12:05:01,208 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-192.168.120.59-80
12:05:01,211 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-192.168.120.59-8009
12:05:01,211 INFO [Catalina] Initialization processed in 884 ms
12:05:01,212 INFO [StandardService] Starting service jboss.web
12:05:01,218 INFO [StandardEngine] Starting Servlet Engine: JBossWeb/2.0.1.GA
12:05:01,409 INFO [Catalina] Server startup in 197 ms
12:05:01,739 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jboss-web.deployer/ROOT.war/
12:05:03,821 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/http-invoker.sar/invoker.war/
12:05:04,222 INFO [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../deploy/jbossws.sar/jbossws-context.war/
12:05:04,618 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
12:05:07,854 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../deploy/management/console-mgr.sar/web-console.war/
12:05:09,300 INFO [MailService] Mail Service bound to java:/Mail
12:05:09,833 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-local-jdbc.rar
12:05:09,937 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-xa-jdbc.rar
12:05:10,041 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-local-jdbc.rar
12:05:10,150 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-xa-jdbc.rar
12:05:10,306 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jms/jms-ra.rar
12:05:10,441 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
12:05:10,560 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/quartz-ra.rar
12:05:10,584 INFO [QuartzResourceAdapter] start quartz!!!
12:05:10,798 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: main
12:05:10,873 INFO [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
12:05:10,883 INFO [RAMJobStore] RAMJobStore initialized.
12:05:10,884 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package
: 'quartz.properties'
12:05:10,885 INFO [StdSchedulerFactory] Quartz scheduler version: 1.5.2
12:05:10,885 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
12:05:12,662 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI n
ame 'java:DefaultDS'
12:05:13,385 INFO [NTPPushTriggerQ] Bound to JNDI name: queue/NTPPushTriggerQ
12:05:13,391 INFO [A] Bound to JNDI name: queue/A
12:05:13,396 INFO [B] Bound to JNDI name: queue/B
12:05:13,400 INFO [C] Bound to JNDI name: queue/C
12:05:13,405 INFO [D] Bound to JNDI name: queue/D
12:05:13,410 INFO [ex] Bound to JNDI name: queue/ex
12:05:13,611 INFO [testTopic] Bound to JNDI name: topic/testTopic
12:05:13,616 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
12:05:13,621 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
12:05:13,654 INFO [testQueue] Bound to JNDI name: queue/testQueue
12:05:13,776 INFO [UILServerILService] JBossMQ UIL service available at : /192.168.120.59:8093
12:05:13,881 INFO [DLQ] Bound to JNDI name: queue/DLQ
12:05:13,890 INFO [NTPStartTopic] Bound to JNDI name: topic/NTPStartTopic
12:05:14,289 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JND
I name 'java:JmsXA'
12:05:14,499 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=OracleDS' to JNDI na
me 'java:OracleDS'
12:05:15,966 INFO [TomcatDeployer] deploy, ctxPath=/WL, warUrl=.../tmp/deploy/tmp9239WL-exp.war/
12:05:16,156 INFO [STDOUT] Startup class Loaded
12:05:16,193 INFO [STDOUT] StartLoad
12:05:17,887 INFO [STDOUT] NTP Index Done
12:05:17,905 INFO [STDOUT] sssssssssssss
12:05:17,906 INFO [STDOUT] Completed Trades Done
12:05:17,912 INFO [STDOUT] Prompt Month 5
12:05:20,090 INFO [STDOUT] StopLoad
12:05:20,091 INFO [STDOUT] Page Cache initialized
12:05:20,096 INFO [STDOUT] User Cache initialized
12:05:20,096 INFO [STDOUT] -TODO PushTrigger message sent - TODO
12:05:20,132 INFO [STDOUT] queueFactory org.jboss.mq.SpyConnectionFactory@a1a199
12:05:20,344 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
12:05:20,881 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- Packages waiting for a deployer ---
org.jboss.deployment.DeploymentInfo@86f9aa89 { url=file:/devl/wireless/jboss-4.2.2.GA/server/default/deploy/jms/jboss.xml }
deployer: null
status: null
state: INIT_WAITING_DEPLOYER
watch: file:/devl/wireless/jboss-4.2.2.GA/server/default/deploy/jms/jboss.xml
altDD: null
lastDeployed: 1207677920874
lastModified: 1207677920000
mbeans:
--- Incompletely deployed packages ---
org.jboss.deployment.DeploymentInfo@86f9aa89 { url=file:/devl/wireless/jboss-4.2.2.GA/server/default/deploy/jms/jboss.xml }
deployer: null
status: null
state: INIT_WAITING_DEPLOYER
watch: file:/devl/wireless/jboss-4.2.2.GA/server/default/deploy/jms/jboss.xml
altDD: null
lastDeployed: 1207677920874
lastModified: 1207677920000
mbeans:
12:05:21,429 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-192.168.120.59-80
12:05:21,625 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-192.168.120.59-8009
12:05:21,671 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 59s:182ms
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142480#4142480
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142480
18 years