Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6357977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:16:45+00:00 2026-05-24T23:16:45+00:00

I have ejb 2.1 deployed in JBOSS 5 server . The jndi name is

  • 0

I have ejb 2.1 deployed in JBOSS 5 server . The jndi name is ejb/DemoEJB and it matches the jmx-console tree in jboss . While i try to lookup in struts action class as follows , it throws the ClassCastException . kindly let me know, if there is any different way to lookup . The ejb jar is separately deployed and it is not in the ear file.

   Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
        env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
        env.put(Context.PROVIDER_URL, url);
        InitialContext ctx = new InitialContext(env);
DemoEJB demoEjb = (DemoEJB)ctx.lookup("ejb/DemoEJB");

ejb-jar.xml

<?xml version = '1.0' encoding = 'windows-1252'?>
<!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>
    <session>
      <description>Session Bean ( Stateless )</description>
      <display-name>DemoEJB</display-name>
      <ejb-name>DemoEJB</ejb-name>
      <home>DemoEJB.DemoEJBHome</home>
      <remote>DemoEJB.DemoEJB</remote>
      <ejb-class>DemoEJB.impl.DemoEJBBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
    </session>

jboss.xml

<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_5_0.dtd">
<jboss>
    <session>
      <ejb-name >DemoEJB</ejb-name>
      <jndi-name>ejb/DemoEJB</jndi-name>
      <local-jndi-name >ejb/DemoEJB</local-jndi-name>
      <ejb-ref>DemoEJB.DemoEJB </ejb-ref>
      <ejb-local-ref>DemoEJB.DemoEJBHome</ejb-local-ref>
    </session>

</jboss>

Stack trace

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:16:48+00:00Added an answer on May 24, 2026 at 11:16 pm

    I think the jndi call would return the DemoEJB.DemoEJBHome class, not the DemoEJB one, hence the classcast exception.

    Try:

    DemoEJBHome home =  (DemoEJBHome)ctx.lookup("ejb/DemoEJB");
    DemoEJB demoEjb = home.create();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an entry point in an EJB deployed on JBoss. Servlets have
I have deployed an EJB with local and remote interfaces, and I can lookup
I have a top-down EJB Webservice (deployed on Websphere 6.01) that hangs the first
I have an application that is deployed on a Glassfish server, for which methods
I have the following arrangement : Tomcat --EJB-invokation--> JBoss (6.0.14) (5.1.0) The two servers
I have created a EJB2.0 using Eclipse 3.7 IDE, and deployed it in JBoss
Using jboss-esb 5.1.0.GA I have a web service that an EJB that I have
I'm using JBoss 4.2.3, EJB2, XDoclet and have deployed one EAR with the EJBs
I have a problem calling EJB object in struts action. I deployed my application
I have ejb + JPA app on GF3 server and remote swing client. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.