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)
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 ....
Do not threaten THIS beaver! Not even with this tiny ad:
professionally read, modify and write PDF files from Java