473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

JNDI access to local EJB interface

Hi!

I'm trying to access a EntityBean from a servlet via the bean's local
home interface. The EJB and the Servlet are together in one .ear file
and I'm using JBoss 3.2.3. I think the "<local-jndi-name>" in
jboss-web.xml is wrong. But I don't know what to write there. I've
searched for examples or other help, but I haven't found anything
useful.

Thanks for your help in advance!

Steffen

My XML files:

jboss-web.xml
<jboss-web>
<ejb-local-ref>
<ejb-ref-name>ejb/Article</ejb-ref-name>
<local-jndi-name>beans/ArticleLocalHome</local-jndi-name>
</ejb-local-ref>
</jboss-web>

web.xml:
<web-app>
<display-name>Versionierung: newArticle</display-name>
<servlet>
<servlet-name>newArticleServlet</servlet-name>
<servlet-class>servlets.newArticleServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>newArticleServlet</servlet-name>
<url-pattern>/newArticle</url-pattern>
</servlet-mapping>
<ejb-local-ref>
<description>Local reference to ArticleBean</description>
<ejb-ref-name>ejb/Article</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>beans.ArticleLocalHome</local-home>
<local>beans.ArticleLocal</local>
</ejb-local-ref>
</web-app>

ejb-jar.xml:
<ejb-jar>
<enterprise-beans>
<entity>
<display-name>Article CMP-Entity Bean</display-name>
<ejb-name>ArticleEJB</ejb-name>
<home>beans.ArticleHome</home>
<remote>beans.Article</remote>
<local-home>beans.ArticleLocalHome</local-home>
<local>beans.ArticleLocal</local>
<ejb-class>beans.ArticleBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Article</abstract-schema-name>
<!--cmp-fields...-->
<primkey-field>pk</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>
SELECT OBJECT(a) FROM Article AS a
</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ArticleEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

servlet code:
....
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
InitialContext jndiContext = new InitialContext();
articleHome =
(ArticleLocalHome)jndiContext.lookup("java:comp/env/ejb/Article");
}
catch (NamingException e) {
System.out.println("JNDI lookup error!");
throw new ServletException(e);
}
}
....
Jul 17 '05 #1
0 8567

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
1
by: Kent | last post by:
I'm running on Win2000 and JRE 1.4.1.... I've got a small client trying to do get an InitialContext() and talk to the local JBoss server running on same machine (different VM of course). When...
1
by: slurper | last post by:
i have problems understanding jndi. i'm this far: i deployed the sun application server and i'm working through the examples (Duke bookstore, ...). Sometimes i see code which does a lookup to a...
1
by: John Chambers | last post by:
Hi all, I'm relatively new to JNDI concepts and need some help. I am writing a web app that accepts a variable specifying a jndi pooled connection datasource as a url variable. This is a...
0
by: no-spam | last post by:
Hello group, I have some questions concerning configuring and using a JNDI DataSource with PostgreSQL and Apache Tomcat. Currently, I belive I have successfully configured a "basic" DataSource....
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
0
by: crossroadsk | last post by:
I have a problem in configuring JNDI properties for LDAP server i created jndi.properties file in the current directory where i'm running a simple java code. jndi.properties file which i...
1
dmjpro
by: dmjpro | last post by:
how do i do JNDI program in local machine.... plze give me JNDI programming free tutorial with examples .... plz help me .... thanx
1
by: kokababu | last post by:
Hi I am developing a WebService using Java (JAX-RPC). According to the requirement, I have to create a Thread to insert data into Database. So I am opening a database connection in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.