Eclipse Catalina

I work every day with eclipse. Since the update of my Os on my mac, I am not able to open eclipse. I get the following error:

  1. Eclipse Catalina_home
  2. Eclipse Catalina Download

Cannot start tomcat running through Maven in Eclipse, org.apache.catalina.LifecycleException: Failed to start component StandardEngineTomcat. You should not explicitly include the following dependency in your app: But mark the servlet-api as provided and leave for Tomcat to supply it: It looks like some jar in the project you are deploying. May 01, 2015 Installing it as a service is not necessary for its use in Eclipse. CATALINAHOME should point to the root directory ('apache-tomcat-6.0.43-windows-x64' not 'apache-tomcat-6.0.43-windows-x64 lib'), and I'd avoid using one where there are spaces involved. That same directory should also work for Eclipse. CATALINAHOME and CATALINABASE are environment variables that point to the sharable and per-instance files used by Tomcat. For single-instance Tomcat use, CATALINAHOME and CATALINABASE normally point to the same place, which is the root Tomcat directory.

'to open eclipse you need to install the legacy Java SE 6 runtime'

So I click 'more info' and I try to install the legacy java SE 6 runtime

When I come to the desitnation select I can't install, I get the following error:

'Java for macOS 2017-001 can't be installed on this disk. A newer version of this package is already installed'.

So I unistalled Java, but this didn't helped the problem.

What can I do? I really need to open my eclipse again !

iMac Pro

Posted on Oct 13, 2019 2:52 AM

Details
Written by Nam Ha Minh
Last Updated on 05 August 2019 | Print Email
This tutorial shows you how to create a JNDI resource that represents a JDBC DataSource in Tomcat, and then how to configure a Java web application in order to access the JNDI DataSource. The benefits of using a JNDI DataSource are:
  • Utilizing database connection pooling services provided by the container, i.e. Tomcat uses Commons DBCP and Commons Pool as the implementation (tomcat-dbcp.jar).
  • Externalizing database connection and make it independent from the web application itself.
  • Sharing database connections across applications deployed in the container.
The following examples are tested in Tomcat 7 and MySQL Database 5.5.

1. Sample MySQL database

First, we need to create a sample database. Let’s execute the following MySQL script:That creates a database called usersdb and a table called users. Remember to insert some dummy data into this table.To interact with MySQL database from Java applications, the MySQL Connector/J library must present in the classpath. Here, we need to copy the mysql-connector-java-VERSION-bin.jar file to the $CATALINA_BASE/lib directory. If you have only one Tomcat instance on your computer, then $CATALINA_BASE is the Tomcat’s installation directory, e.g. c:Program FilesApache Software FoundationTomcat 7.0 on Windows platform. Doing so help Tomcat loads MySQL JDBC driver when it discovers the JNDI DataSource configuration.

2. Configure context

To declare a JNDI DataSource for the MySQL database above, create a Resource XML element with the following content:Add this element inside the root element <Context> in a context.xml file. There are two places where the context.xml file can reside (create one if not exist):
  • Inside /META-INF directory of a web application: the JNDI DataSource is only available to the application itself, thus it cannot be shared among other ones. In addition, this makes the configuration dependent on the application.
  • Inside $CATALINA_BASE/conf directory: this is the preferred place because the JNDI DataSource will be available to all web applications and it’s independent of any applications.

Therefore, we declare above Resource element in the context.xml file under the $CATALINA_BASE/conf directory. The following table describes the attributes specified in the above configuration:

Attribute name

Description

name

Name of the resource.

auth

Specify authentication mechanism for the application code, can be Application or Container.

type

The fully qualified Java class name expected by the web application when it performs a lookup for this resource.

maxActive

Maximum number of database connections in pool. Set to -1 for no limit.

maxIdle

Maximum number of idle database connections to retain in pool. Set to -1 for no limit.

maxWait

Maximum time to wait for a database connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely.

driverClassName

The fully qualified Java class name of the database driver. For MySQL Connector/J, it is com.mysql.jdbc.Driver.

url

The JDBC connection URL.

username

MySQL database user name.

password

MySQL database user password.

For more information about the attributes, visit the reference links mentioned the end of this tutorial.NOTES:
  • If you are using Tomcat inside Eclipse IDE, you need to modify the context.xml file under the Servers project. That is because Eclipse made a copy of Tomcat configuration:
  • If two resources with the same name both declared in the context.xml files under the web application’s META-INF directory and in the $CATALINA_BASE/conf directory, then the internal version takes precedence.

3. Configure web.xml

Add the following declaration into the web.xml file:This is necessary in order to make the JNDI DataSource available to the application under the specified namespace jdbc/UsersDB.

4. Code a test JSP page

Now, create a JSP page (UsersList.jsp) to test the configuration we have made:Here, we use the JSTL’s SQL tag query to make a SELECT query to the database. Note that the dataSource attribute refers to the JNDI resource name declared in the web.xml file:Here’s a sample output when loading the JSP page (http://localhost:8080/JNDIDataSourceExample/UsersList.jspSet2020):

5. Code a test Java servlet

We can look up the configured JNDI DataSource using Java code as follows:After obtaining the connection, we can use it as trivial JDBC code:Here’s the source code of an example Java servlet:And the following is a sample output when calling the servlet (http://localhost:8080/JNDIDataSourceExample/listUsers):Alternatively, we can use the Eclipse@Resource annotation (javax.annotation.Resource) instead of the lookup code above. For example, declare a field called dataSource in the servlet like this:Tomcat will look up the specified resource name and inject an actual implementation when it discovers this annotation. Therefore, the servlet code looks like this:

References:

Eclipse Catalina_home

Other Tomcat Tutorials:


About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Eclipse Catalina Download

Attachments:
[Eclipse project]393 kB