troubleshooting Question

creating my first EJB3 and deploying it on JBOSS5

Avatar of alkasser40
alkasser40 asked on
Java EE
1 Comment1 Solution523 ViewsLast Modified:
Hi,

I am trying to learn and implement EJB 3.0 with JBoss 5.
I have attached my sample code below.
I am using MyEclipse 6 IDE & JDK 6

While running client I am getting this exception :
java.lang.ClassCastException: javax.naming.Reference
      at com.sandy.PrintClient.main(PrintClient.java:18)

Waiting for your suggestions..

Thanks
1. Print.java
package com.sandy;
 
import javax.ejb.Stateless;
 
@Stateless
public class Print implements PrintRemote {
 
	public void display() {
		System.out.println("Printing test in EJB");
	}
}
 
2. PrintRemote.java
package com.sandy;
 
import javax.ejb.Remote;
 
@Remote
public interface PrintRemote {
 
	public void display();
}
 
3. PrintClient.java
package com.sandy;
 
import java.util.Properties;
 
import javax.naming.InitialContext;
 
public class PrintClient {
 
	public static void main(String[] args) {
		try {
			Properties prop = new Properties();
			prop.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
			prop.setProperty("java.naming.provider.url","jnp://localhost:1099");
			prop.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
			
			InitialContext ctx = new InitialContext(prop);
			Print print = (Print)ctx.lookup("Print/remote");
			print.display();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros