You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luong Phan <lu...@yahoo.com> on 2003/08/21 11:07:44 UTC

Error when I load a file

Hi all,

Thanks for your advices. The error is that files
startup.sh and shutdown.sh are not executable. Now I
can start Tomcat.

But I meet the following problem:
- I use the mysql supported already by Redhat Linux
7.3 O/S to store my database.
- The jakarta-tomcat-3.2.4 is used to be the server.
- I use mysql-connector-java-3.0.6-stable-bin.jar for
connection between mysql and JSP.

- I put the my web application in the directory:
jakarta-tomcat-3.2.4/webapps/myapp.
- I put the mysql-connector-java-3.0.6-stable-bin.jar
in directories: jakarta-tomcat-3.2.4/lib, and
jakarta-tomcat-3.2.4/webapps/myapp/WEB-INF/lib 
- I create a properties file (myprop.prop contains
DBURL, DBUserName, DBPassword, and DBDriver) and put
it at directories: jakarta-tomcat-3.2.4/bin, and
jakarta-tomcat-3.2.4/conf.

After I start mysqlserver and tomcat, I type on the
Mozilla browse: http://localhost:8080/myapp, the
browser display my web page. When I link to a URL that
call the JSP program:


import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Enumeration;
import java.util.Properties;


public class MyData {
	private Connection connection;	
	private Statement statement;	
	
	
	public MyData() throws
ClassNotFoundException,SQLException{
	 			
		String DBDriver=null;
		String url=null;
		String username=null;
		String password=null;
		
		Properties props = new Properties();
		String pFile="myprop.prop";
		try {
                props.load(new
FileInputStream(pFile));
            } catch(IOException e) {
                System.err.println("Failed to load
property file");
            }
   ...
I get the following massage "Failed to load property
file".

Please help me!

Thank you very much.

LuongPhan




---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Re: Error when I load a file

Posted by Gabriel Boian <bo...@ssi-schaefer.ro>.
You shoud try to put your property file in myapp/WEB-INF/classes directory
and use a statement like this
ResourceBundle bundle = ResourceBundle.getBundle("myprop.properties");


----- Original Message -----
From: "Luong Phan" <lu...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, August 21, 2003 12:07 PM
Subject: Error when I load a file


> Hi all,
>
> Thanks for your advices. The error is that files
> startup.sh and shutdown.sh are not executable. Now I
> can start Tomcat.
>
> But I meet the following problem:
> - I use the mysql supported already by Redhat Linux
> 7.3 O/S to store my database.
> - The jakarta-tomcat-3.2.4 is used to be the server.
> - I use mysql-connector-java-3.0.6-stable-bin.jar for
> connection between mysql and JSP.
>
> - I put the my web application in the directory:
> jakarta-tomcat-3.2.4/webapps/myapp.
> - I put the mysql-connector-java-3.0.6-stable-bin.jar
> in directories: jakarta-tomcat-3.2.4/lib, and
> jakarta-tomcat-3.2.4/webapps/myapp/WEB-INF/lib
> - I create a properties file (myprop.prop contains
> DBURL, DBUserName, DBPassword, and DBDriver) and put
> it at directories: jakarta-tomcat-3.2.4/bin, and
> jakarta-tomcat-3.2.4/conf.
>
> After I start mysqlserver and tomcat, I type on the
> Mozilla browse: http://localhost:8080/myapp, the
> browser display my web page. When I link to a URL that
> call the JSP program:
>
>
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import java.util.Enumeration;
> import java.util.Properties;
>
>
> public class MyData {
> private Connection connection;
> private Statement statement;
>
>
> public MyData() throws
> ClassNotFoundException,SQLException{
>
> String DBDriver=null;
> String url=null;
> String username=null;
> String password=null;
>
> Properties props = new Properties();
> String pFile="myprop.prop";
> try {
>                 props.load(new
> FileInputStream(pFile));
>             } catch(IOException e) {
>                 System.err.println("Failed to load
> property file");
>             }
>    ...
> I get the following massage "Failed to load property
> file".
>
> Please help me!
>
> Thank you very much.
>
> LuongPhan
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


Re: Error when I load a file

Posted by Jon Wingfield <jo...@mkodo.com>.
I'm sure the stackTrace of the thrown exception would give you more 
information ;)

The code as written would try to load the file myprop.prop from the 
current working directory. This will be where you executed startup.sh 
from. If it's not there then you'll probably get a FileNotFoundException.

Jon

Luong Phan wrote:
> Hi all,
> 
> Thanks for your advices. The error is that files
> startup.sh and shutdown.sh are not executable. Now I
> can start Tomcat.
> 
> But I meet the following problem:
> - I use the mysql supported already by Redhat Linux
> 7.3 O/S to store my database.
> - The jakarta-tomcat-3.2.4 is used to be the server.
> - I use mysql-connector-java-3.0.6-stable-bin.jar for
> connection between mysql and JSP.
> 
> - I put the my web application in the directory:
> jakarta-tomcat-3.2.4/webapps/myapp.
> - I put the mysql-connector-java-3.0.6-stable-bin.jar
> in directories: jakarta-tomcat-3.2.4/lib, and
> jakarta-tomcat-3.2.4/webapps/myapp/WEB-INF/lib 
> - I create a properties file (myprop.prop contains
> DBURL, DBUserName, DBPassword, and DBDriver) and put
> it at directories: jakarta-tomcat-3.2.4/bin, and
> jakarta-tomcat-3.2.4/conf.
> 
> After I start mysqlserver and tomcat, I type on the
> Mozilla browse: http://localhost:8080/myapp, the
> browser display my web page. When I link to a URL that
> call the JSP program:
> 
> 
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import java.util.Enumeration;
> import java.util.Properties;
> 
> 
> public class MyData {
> 	private Connection connection;	
> 	private Statement statement;	
> 	
> 	
> 	public MyData() throws
> ClassNotFoundException,SQLException{
> 	 			
> 		String DBDriver=null;
> 		String url=null;
> 		String username=null;
> 		String password=null;
> 		
> 		Properties props = new Properties();
> 		String pFile="myprop.prop";
> 		try {
>                 props.load(new
> FileInputStream(pFile));
>             } catch(IOException e) {
>                 System.err.println("Failed to load
> property file");
>             }
>    ...
> I get the following massage "Failed to load property
> file".
> 
> Please help me!
> 
> Thank you very much.
> 
> LuongPhan




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Error when I load a file

Posted by Gabriel Boian <bo...@ssi-schaefer.ro>.
You shoud try to put your property file in myapp/WEB-INF/classes directory
and use a statement like this
ResourceBundle bundle = ResourceBundle.getBundle("myprop.properties");


----- Original Message -----
From: "Luong Phan" <lu...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, August 21, 2003 12:07 PM
Subject: Error when I load a file


> Hi all,
>
> Thanks for your advices. The error is that files
> startup.sh and shutdown.sh are not executable. Now I
> can start Tomcat.
>
> But I meet the following problem:
> - I use the mysql supported already by Redhat Linux
> 7.3 O/S to store my database.
> - The jakarta-tomcat-3.2.4 is used to be the server.
> - I use mysql-connector-java-3.0.6-stable-bin.jar for
> connection between mysql and JSP.
>
> - I put the my web application in the directory:
> jakarta-tomcat-3.2.4/webapps/myapp.
> - I put the mysql-connector-java-3.0.6-stable-bin.jar
> in directories: jakarta-tomcat-3.2.4/lib, and
> jakarta-tomcat-3.2.4/webapps/myapp/WEB-INF/lib
> - I create a properties file (myprop.prop contains
> DBURL, DBUserName, DBPassword, and DBDriver) and put
> it at directories: jakarta-tomcat-3.2.4/bin, and
> jakarta-tomcat-3.2.4/conf.
>
> After I start mysqlserver and tomcat, I type on the
> Mozilla browse: http://localhost:8080/myapp, the
> browser display my web page. When I link to a URL that
> call the JSP program:
>
>
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import java.util.Enumeration;
> import java.util.Properties;
>
>
> public class MyData {
> private Connection connection;
> private Statement statement;
>
>
> public MyData() throws
> ClassNotFoundException,SQLException{
>
> String DBDriver=null;
> String url=null;
> String username=null;
> String password=null;
>
> Properties props = new Properties();
> String pFile="myprop.prop";
> try {
>                 props.load(new
> FileInputStream(pFile));
>             } catch(IOException e) {
>                 System.err.println("Failed to load
> property file");
>             }
>    ...
> I get the following massage "Failed to load property
> file".
>
> Please help me!
>
> Thank you very much.
>
> LuongPhan
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Error when I load a file

Posted by Jon Wingfield <jo...@mkodo.com>.
I'm sure the stackTrace of the thrown exception would give you more 
information ;)

The code as written would try to load the file myprop.prop from the 
current working directory. This will be where you executed startup.sh 
from. If it's not there then you'll probably get a FileNotFoundException.

Jon

Luong Phan wrote:
> Hi all,
> 
> Thanks for your advices. The error is that files
> startup.sh and shutdown.sh are not executable. Now I
> can start Tomcat.
> 
> But I meet the following problem:
> - I use the mysql supported already by Redhat Linux
> 7.3 O/S to store my database.
> - The jakarta-tomcat-3.2.4 is used to be the server.
> - I use mysql-connector-java-3.0.6-stable-bin.jar for
> connection between mysql and JSP.
> 
> - I put the my web application in the directory:
> jakarta-tomcat-3.2.4/webapps/myapp.
> - I put the mysql-connector-java-3.0.6-stable-bin.jar
> in directories: jakarta-tomcat-3.2.4/lib, and
> jakarta-tomcat-3.2.4/webapps/myapp/WEB-INF/lib 
> - I create a properties file (myprop.prop contains
> DBURL, DBUserName, DBPassword, and DBDriver) and put
> it at directories: jakarta-tomcat-3.2.4/bin, and
> jakarta-tomcat-3.2.4/conf.
> 
> After I start mysqlserver and tomcat, I type on the
> Mozilla browse: http://localhost:8080/myapp, the
> browser display my web page. When I link to a URL that
> call the JSP program:
> 
> 
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import java.util.Enumeration;
> import java.util.Properties;
> 
> 
> public class MyData {
> 	private Connection connection;	
> 	private Statement statement;	
> 	
> 	
> 	public MyData() throws
> ClassNotFoundException,SQLException{
> 	 			
> 		String DBDriver=null;
> 		String url=null;
> 		String username=null;
> 		String password=null;
> 		
> 		Properties props = new Properties();
> 		String pFile="myprop.prop";
> 		try {
>                 props.load(new
> FileInputStream(pFile));
>             } catch(IOException e) {
>                 System.err.println("Failed to load
> property file");
>             }
>    ...
> I get the following massage "Failed to load property
> file".
> 
> Please help me!
> 
> Thank you very much.
> 
> LuongPhan