• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

JNDI lookup problem -> javax.naming...

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi people,

J2EE newbie's writing
I have a problem when I want to do a lookup
I've got this exception :
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial

my configuration:
jsdk1.4 j2re1.4.2_05
eclipse 3.0.0 with plugins :quantumDB, LombozJ2EE,Tomcat Launcher
MySQL 4.0.20 as service
Tomcat 5.0.28
all these components are working smoothly

1. I have created a new LombozJ2EE project
2. I added to WEB-INF/lib/web.xml :
<resource-ref>
<res-ref-name>jdbc/sams</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<init-param driver-name="com.mysql.jdbc.Driver"/>
<init-param url="jdbc:mysql://localhost:3306/sams"/>
<res-auth>Container</res-auth>
</resource-ref>
3. I added in Tomcat administration tool a new data source so it will
update <CATALINA_HOME>/conf/server.xml with this new data source
JNDI Name:jdbc/sams
Data Source URL: jdbc:mysql://localhost:3306/sams
JDBC Driver Class: com.mysql.jdbc.Driver
User Name: my username
Password: mypassword
4. I added in src/ two java classes :
- CreateAgency.java for creating the sams's database, it works fine with
driver = "com.mysql.jdbc.Driver";
protocol = "jdbc:mysql://localhost/sams";

- AgencyTable.java to extract the tables with
DataSource dataSource;
InitialContext ic = new InitialContext();
Context ctx = (Context) ic.lookup("java:comp/env");
dataSource = (DataSource)ic.lookup("jdbc/Sams");


5. TOMCAT IS RUNNING, MySQL TOO
I deployed the Webmodule (directories are created in<CATALINA_HOME>/webapps)

I CAN'T HAVE LOOKUP, GOT THE EXCEPTION INSTEAD

if someone could help me

thx
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the client project

u have add the the follwing lines in

MANIFEST.MF

Manifest-Version: 1.0
Main-Class: ClientClassName
Class-Path: yourapp.jar


cheers
 
Oren andJava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi bala

the MANIFEST.MF is not updated automatically whe n deployeing web module ?

how do I make "yourapp.jar" : just making a *.jar of all my workspace? and where to put it (<CATALINA_HOME)/webapps/projectname/) ?
and what should be my "Main-Class: ClientClassName" ? my app has a test.jsp that is calling DBTest.class ....

thx
 
Do not threaten THIS beaver! Not even with this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!