Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E52A1881F for ; Mon, 23 Nov 2015 16:20:12 +0000 (UTC) Received: (qmail 70253 invoked by uid 500); 23 Nov 2015 16:20:08 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 70191 invoked by uid 500); 23 Nov 2015 16:20:08 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 70180 invoked by uid 99); 23 Nov 2015 16:20:08 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2015 16:20:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 42DCBC6463 for ; Mon, 23 Nov 2015 16:20:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id SY5QnyBaWhMT for ; Mon, 23 Nov 2015 16:20:07 +0000 (UTC) Received: from mail-vk0-f41.google.com (mail-vk0-f41.google.com [209.85.213.41]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 104AE42B7B for ; Mon, 23 Nov 2015 16:20:07 +0000 (UTC) Received: by vkay187 with SMTP id y187so40621344vka.3 for ; Mon, 23 Nov 2015 08:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=juVllJwzHGT0Wd2KxWkyfw67XaA2YdytA9mZT1BnU+o=; b=wby17+Elbq3mF5JAkSOk6xhVvy3jN+QHQ2JhZ4GcZT0pTm8eFezsbmugaAAHpZNcmJ 8LefdrLUejf2y+7zyPm3I4rpWhK4dSgWnYLQRYJxlXb0wN/oH7CNwAVzeZFszZyn9tS9 VUZJ0mkTPEnnjqVIan0go8fFaDs5Iv7TSPhugO3HbTFK4NVrZ7fTRp2ra7lTpW156Haa Km6tNRW/wR8skLFOrT7Z+VThPXgFXOfnBbRiIKYDbuqH9w13F7lXOqFoJZu7V9xUhZyo A5lYSXQVh2dt09K2DIQu8tIXmcV2c7C3MCwbZqVESuduNO8lLe+ejdRJFWkuxllfSz4V W+jA== X-Received: by 10.31.165.194 with SMTP id o185mr19413987vke.125.1448295606533; Mon, 23 Nov 2015 08:20:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.130.212 with HTTP; Mon, 23 Nov 2015 08:19:47 -0800 (PST) In-Reply-To: References: From: Yuval Schwartz Date: Mon, 23 Nov 2015 18:19:47 +0200 Message-ID: Subject: Re: To: Tomcat Users List Content-Type: multipart/alternative; boundary=001a1141539e2842c305253799b5 --001a1141539e2842c305253799b5 Content-Type: text/plain; charset=UTF-8 Update regarding my second question below...The first question is still valid as is and I am still interested in input. On Mon, Nov 23, 2015 at 3:38 PM, Yuval Schwartz wrote: > Hello, > > I am using tomcat 8.0.22.0 > Language: Java > development: Windows, NetBeans. > deployment: ec2 linux > > I am still having trouble understanding/working with "path" and "docBase" > of context element. > I have two questions: > > First of all, I have a context.xml file in the WEB-INF folder of my > application (call it "myApplication" henceforth) that looks like: > > > maxActive="100" maxIdle="30" maxWait="10000" > username="blah" password="blahblah" > driverClassName="com.mysql.jdbc.Driver" > url="jdbc:mysql://localhost:3306/some_db?autoReconnect=true" > logAbandoned="true" removeAbandoned="true" > removeAbandonedTimeout="60" type="javax.sql.DataSource" /> > > > My context path is set to the empty string because once I set up a domain > name it will be redundant to have both the application name and domain name > in the url (they are the same). > > This works on my development environment. > > When I deploy this to a linux server of an ec2 instance (on aws) I add a > line to the server.xml file (in tomcat/conf) under the element which > reads: > > > (If I don't add this element to the server.xml file then entering just the > domain in the url takes me to the Apache Tomcat "successful installation" > page rather than to the welcome page of myApplication). > > First question: > Is this the correct way to set up tomcat so that my application has no > context path? Not sure if this leads to the "double deployment" problem or > not. When I open the tomcat manager I see two applications: one with path: > "/" and the other with path "/myApplication". (for some reason, I don't > have the option to "undeploy" the application with path: "/") > > Second question: > The resource element within the context element of my context.xml file > (located in WEB-INF) specifies a url that is specific to my development (ie > local) environment. > When I deploy myApplication to the ec2 instance I would like the resource > element to have a different url attribute (since it will now be connecting > with a database on an aws server). > One way that I found to do this was to add to the context.xml file in the > tomcat/conf directory of my server. There I add a resource element (between > the existing context element) which is identical to the one above only with > a url attribute that points to the database hosted on aws. > > This way, my application is able to connect with my database without me > changing any of the code in myApplication. > However, my Catalina.log file displays: > WARNING [localhost-startStop-1] > org.apache.catalina.core.NamingContextListener.add Resource Failed to > register in JMX: javax.naming.NamingException: Could not create resource > factory instance [Root exception is java.lang.ClassNotFoundException: > org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory] > > And my localhost.log file shows a nullpointerexception for the line in my > code: > ic.lookup("java:comp/env/jdbc/some_db"); > (Where ic is an InitialContext Object) > > There are also problems in the deployed website with some of the code that > grabs data from the db (but some of the db related code works successfully). > It turns out that these warning and exceptions were caused because of missing jar files in the JDK's jre/lib/ext folder. tomcat-dbcp.jar is not available in amazon's tomcat8 AMI (my terminology might be a bit off). Instead, one needs to transfer both the commons-dbcp.jar and commons-pool.jar from tomcat/lib into the JDK's jre/lib/ext folder In addition, since this is not the default factory in the Resource element that I declared (as was the case with tomcat-jdbc), you need to explicitly specify it: factory="org.apache.commons.dbcp.BasicDataSourceFactory" > > Any insight or suggestions would be greatly appreciated. > I'm new to a lot of this (extremely new to deploying to a server). > > Thank you > _ > > > > > > > --001a1141539e2842c305253799b5--