I've been trying to set up my tomcat server on amazon's ec2 server with little luck. I have the same exact setup running fine on my windows local machine with no issues.
Caused by: javax.naming.NameNotFoundException: Name [jdbc/orders] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 103 more
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
--><Server port="8005" shutdown="SHUTDOWN">
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener"/>
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="jdbc/orders" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="marios"
password="135181mi!" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/orders" />
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine defaultHost="localhost" name="Catalina">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
</Host>
</Engine>
</Service>
</Server>
WEB-INF/context.xml tried to also put this in tomcat7/config/context.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context docBase="PaphosDiner" path="/PaphosDiner" reloadable="true" source="org.eclipse.jst.jee.server:PaphosDiner">
<ResourceLink name="jdbc/orders"
global="jdbc/orders"
auth="Container"
type="javax.sql.DataSource" />
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
web.xml
<resource-ref>
<description>Database</description>
<res-ref-name>jdbc/orders</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I have also included the mysqlconnector jar in the server
You are not technically doing anything wrong, I have experienced (with tomcat and mysql) and rectified this issue on my side, you can validate by having a JSP Database test page not using DataSource, the issue is that most Amazon services do not support things out of the box:
JNDI Datasource
EC2 including Beanstalk lack this feature, as per your code above:
dataSource="jdbc/orders"
Solution is to either resort to:
JDBC DriverManager
Create JNDI Datasource
References:
https://forums.aws.amazon.com/thread.jspa?threadID=108499
https://forums.aws.amazon.com/thread.jspa?messageID=313642
Related
I have configured javamelody 1.86.0 on Tomcat 8.8 and all the other metrics are captured except from the JDBC. Below are the config I have on the Tomcat application:
Context.xml:
<ResourceLink type="javax.sql.DataSource"
name="jdbc/LocalAPIDB"
global="jdbc/APIDB"/>
Server.xml:
<Resource type="javax.sql.DataSource"
name="jdbc/APIDB"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/apiDB"
username="xxxx"
password="xxxxx"
initialSize="340"
maxActive="3770"
maxIdle="2330"
minIdle="890"
testOnBorrow="true"
validationQuery="SELECT 1"
validationInterval="30000"
timeBetweenEvictionRunsMillis="5000"
minEvictableIdleTimeMillis="60000"
removeAbandoned="true"
removeAbandonedTimeout="60"
abandonWhenPercentageFull="0"
logAbandoned="true"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer"/>
On mbeans I can see there are active connections but on the graph nothing is captured.
JDBC Graph
MBeans
Debugging Logs
I suggest that you move the Resource from server.xml to the xml context file of the webapp (conf/Catalina/localhost/MpesaIntegrations.xml) and that you remove the ResourceLink.
So the xml context file of the webapp is like this:
<?xml version="1.0" encoding="UTF-8" ?>
<Context>
<Resource type="javax.sql.DataSource"
name="jdbc/LocalAPIDB"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/apiDB"
username="xxxx"
password="xxxxx"
initialSize="340"
maxActive="3770"
maxIdle="2330"
minIdle="890"
testOnBorrow="true"
validationQuery="SELECT 1"
validationInterval="30000"
timeBetweenEvictionRunsMillis="5000"
minEvictableIdleTimeMillis="60000"
removeAbandoned="true"
removeAbandonedTimeout="60"
abandonWhenPercentageFull="0"
logAbandoned="true"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer"
/>
</Context>
And/or, if that's not enough, you probably have a listener or filter in your webapp that is getting and keeping in cache the DataSource. In that case, put the javamelody listener and filter near the top of your WEB-INF/web.xml file.
For anybody scratching their head trying to find out why JavaMelody won't show database stats such as 'active JDBC connections', I finally solved it by doing 2 things. Note that in my case I'm using Java 11 running Apache Tomcat 9 hosting an Apache Derby 10.15.2 database:
Setting up the database in the 'apache-tomcat-9.0.52\conf\context.xml' file eather than in java code in my webapp. I think this made the database associated with the JNDI resource name so JavaMelody could see it. I added this XML to that context.xml file:
<Resource name="jdbc/DatabaseJNDIResourceName"
auth="Container"
type="javax.sql.DataSource"
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:../DatabaseName;"
username="someuser"
password="s3cret"
/>
Then you can get the DataSource in your webapp java code using:
InitialContext initialContextJNDI = new InitialContext();
DataSource dataSource = (DataSource)initialContextJNDI.lookup("java:comp/env/jdbc/DatabaseJNDIResourceName");
Note that a method to detect a potential JNDI resource name problem is to see if the resource name shows up in JavaMelody by navigating to the page 'JNDI tree' at the bottom, linked here http://localhost:8080/monitoring?part=jndi
Inserting the web.xml code referred to here. Interestingly, when that XML code was left out, javamelody would still run but it didn't report JDBC-related data.
<filter>
<filter-name>javamelody</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>javamelody</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
Another thing, even after these fixes finally solved the problem and made JavaMelody aware of my database, I didn't immediately notice since the graphs barely change if your database queries are fast. I only confirmed that the database stats were being logged after executing a long SQL query and updating the 'opened jdbc connections' page, linked at the bottom of the javamelody stats page here, which showed one single connection while the database took a few seconds to process the large (1 million row table) query http://localhost:8080/monitoring?part=connections
I was able to start the Broadleaf demo application from the provided scripts adminstart.sh and startsite.sh. I was also able to change the database to MySQl. However, I do not understand how to create a war that can run on my Tomcat instance.
I see that broadleaf does things differently as compared to the common approach. Usually I put the context values into the file application-context. xml that is referred in web.xml. There is no need for modifying Tomcat context.xml. The example is
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-context.xml</param-value>
</context-param
In the broadleaf configuration there are several context parameters
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>blAdmin.root</param-value>
</context-param>
<context-param>
<param-name>patchConfigLocation</param-name>
<param-value>
classpath:/bl-open-admin-contentClient-applicationContext.xml
classpath:/bl-open-admin-contentCreator-applicationContext.xml
classpath:/bl-admin-applicationContext.xml
classpath:/bl-cms-contentClient-applicationContext.xml
classpath:/bl-cms-contentCreator-applicationContext.xml
classpath*:/blc-config/admin/bl-*-applicationContext.xml
classpath:/applicationContext.xml
classpath:/applicationContext-email.xml
/WEB-INF/applicationContext-datasource.xml
/WEB-INF/applicationContext-admin-security.xml
/WEB-INF/applicationContext-admin-filter.xml
/WEB-INF/applicationContext-admin.xml
</param-value>
</context-param>
<context-param>
<param-name>shutdownHookMethod</param-name>
<param-value>forceFlush</param-value>
</context-param>
Plus in addition in web.xml:
<!-- Initialize spring mvc -->
<servlet>
<servlet-name>admin</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-servlet-open-admin.xml
classpath:/applicationContext-servlet-admin.xml
classpath:/applicationContext-servlet-cms-contentClient.xml
classpath:/applicationContext-servlet-cms-contentCreator.xml
classpath:/bl-menu-admin-applicationContext-servlet.xml
classpath*:/blc-config/admin/bl-*-admin-applicationContext-servlet.xml
/WEB-INF/applicationContext-servlet-admin.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
The result is that the Tomcat instance contains context.xml in the conf directory that provides database pool configuration:
What is the best way of utilizing broadleaf in my application?
Configuration
Put your MySQL JDBC driver to tomcat7/lib folder
Open web.xml for both, site and admin modules in DemoSite
Add the following code in both web.xml
<resource-ref>
<description>WEB</description>
<res-ref-name>jdbc/web</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>STORAGE</description>
<res-ref-name>jdbc/storage</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>SECURE</description>
<res-ref-name>jdbc/secure</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Open cmd prompt for windows or command shell for linux
Navigate to your JDK_directory/bin and create keystore for SSL switching
keytool -genkey -alias tomcat -keyalg RSA -storepass password
Open Tomcat7/conf/server.xml
Add the following code to enable SSL switching, just below your default connector port
<Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" maxThreads="200"
scheme="https" secure="true"
SSLEnabled="true"
keystorePass="password"
clientAuth="false"
sslProtocol="TLS"
/>
Open Tomcat7/conf/tomcat-users.xml
Add following
<user username="tomcat" password="password" roles="manager-gui"/>
Populate database.properties with values for your database or
Configure JNDI for tomcat
In your admin or site folder there is file target/tomcat-server-config/context.xml.
Copy this file into tomcat7/conf/
Open this file and replace the following properties with your database values
username="${database.user}" : Replace with your database username (eg. broadleaf)
password="${database.password}" : Replace with your database password
driverClassName="${database.driver}" : Replace with your database classname (eg. org.postgresql.Driver)
url="${database.url}" : Replace with your database URL with database path, port and name. (eg. jdbc:postgresql://localhost:5432/broadleaf)
in your IDE Start Maven project install goal of lifecycle (of entire project or each module)
This will create wars for each module
Start tomcat (run startup.bat/startup.sh in ~/tomcat7/bin/ )
Go to app manager and enter tomcat username and key that you added into tomcat-users.xml
deploy admin and site wars
context path is url mapping (eg. /admin and /demo-site)
XML configuration url is full path to your targets context.xml (eg. ~/target/tomcat-server-conf/context.xml)
WAR directory is full path to your war in target directory
Don't forget to change blPU.hibernate.hbm2ddl.auto in development.properties from create to update (standalone tomcat have trouble to create tables - that's my expirience with postreSQL)
I have an ASP.NET web application written in VB.NET. One part of the application makes an AJAX call to an internal ASMX file which in turn makes a call to a remote web service which is just a single ASMX file. Normally this works fine and has been deployed a couple of times and works fine. One client however, is getting the message from the AJAX call:
The HTTP request is unauthorized with client authentication scheme
'Anonymous'. The authentication header received from the server was
'NTLM’.
I have scoured a large amount of websites trying to fix this but I can’t seem to find any answer that works for me.
I have been unable to replicate the error on my test server, which is the same as the client, Win2003 IIS6.
The remote web service is deployed on Windows 2008 r2 – IIS7.5. The remote service is deployed using ‘Anonymous’ authentication only. The client deployment is set up with Anonymous and ‘Integrated Windows Authentication’. I have tried changing the authentication levels on both implementations but cannot replicate the issue. The closest I have come is when I set the remote service IIS authentication to
The HTTP request is unauthorized with client authentication scheme
'Ntlm'. The authentication header received from the server was ''.
In the web.config file the reference to the remote service is:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SVCMappingSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://svc.website.com/services/myService.asmx" binding="basicHttpBinding" bindingConfiguration="SVCMappingSoap" contract="SVCMappingService.SVCMappingSoap" name="SVCMappingSoap"/>
</client>
</system.serviceModel>
I have tried changing a number of the setting in the <security> section but still unable to replicate.
I am not sure of your total server setup.
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
</security>
instead of above one please try with below configuration
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
please go through below links, you can more idea on those and you can change the config based on your requirements:
http://blogs.msdn.com/b/publicsector/archive/2005/10/19/482833.aspx
http://fczaja.blogspot.com/2009/10/http-request-is-unauthorized-with.html
http://ddkonline.blogspot.com/2009/11/fix-http-request-is-unauthorized-with.html
I had to change the default generated
<security mode="Transport"/>
into
<security mode="Transport" >
<transport clientCredentialType="Ntlm"/>
</security>
One more comment for this problem:
If you are not using HTTPS,
<security mode="Transport"/>
is not supported. You can use
<security mode="TransportCredentialOnly">
instead.
I would like to know where are the WebSphere configuration details saved?
Specifically, configuration details that are shown in the Administrative Console (from the web) or from the console using wsadmin.
Some of the examples would be:
Java and Process Management: Class
loader, Process definition, Process
execution
Container Settings:
Session management, SIP Container
Settings, Web Container Settings,
Portlet Container Settings
Are there XML files that persist these configuration details?
Nicholas
WebSphere Application Server configuration data is stored in XMI format in the profile configuration repository.
The settings you referred to are stored in server.xml
${PROFILE_HOME}/config/cells/${CELL}/nodes/${NODE}/servers/${SERVER}/server.xml
Along with server.xml # ${PROFILE_HOME}/config/cells/${CELL}/nodes/${NODE}/servers/${SERVER}/server.xml, there are other files too which save more data as below:
resources.xml at the same path. This file has all the resources information saved.
variables.xml at the same path. This file saves the variables used in places like DB drivers etc.
Also, there are other important file mentioned here - https://websphereapplicationservernotes.wordpress.com/2012/12/13/websphere-application-server-important-files/
As the URLs get obsolete these days, I am pasting the content here too:
CELL-scope
• admin-authz.xml
Contains the roles set for administration of the Admin console.
/appsrv01/config/cells//
• profileRegistry.xml
Contains a list of profiles and profile configuration data
• resources.xml
Defines operating cell scope environmental resources, including JDBC, JMS, JavaMail, URL end point configuration, and so on.
• security.xml
Contains security data , including all user ID and password information.
• virtualhosts.xml
Contains virtual host and Multipurpose Internet Mail Extensions (MIME)-type configurations.
• variables.xml
Contains cell level WebSphere variables
• wimconfig.xml
Contains the federated repository configurations for global security
/config/cells//wim/config/
NODE-scope
• namestore.xml
Provides persistent JNDI namespace binding data
• resources.xml
Defines node scope environmental resources, including JDBC, JMS, JavaMail, URL end point configuration, and so on
• serverindex.xml
Specifies all the ports used by servers on this node
• variables.xml
Contains node level WebSphere variables
SERVER-scope
• resources.xml
Contains the configuration of resources, such as, JDBC, JMS, JavaMail, and URL end points at server scope
• server.xml
Contains application server configuration data
• variables.xml
Contains server level variables
I'm trying to get Tomcat 6.0.20 working with SSL authentication. I used keytool to create a new certificate, put it into my user dir, and set the tomcat authentication to this (server.xml):
(Omitted)
-->
<Server port="8005" shutdown="SHUTDOWN">
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" SSLRandomSeed="builtin" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="9090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9091" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<Connector port="9091" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/home/media/.keystore"
keystorePass="123456"
clientAuth="false" sslProtocol="TLS" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="9091" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
</Engine>
</Service>
</Server>
However, whist connection thru http is fine, whenever I try to connect through port 9091 (https) I always get the message "the connection was interrupted". I never got a certificate or anything, though there was no errors in catalina.out
What could be wrong. Must I generate a OpenSSL key pair and import it in addition to creating and specifying a keystore?
I'd suggest using curl to troubleshoot your problems. curl is a unix tool as well as a library, and on Windows is runs well under cygwin. Try the following command:
curl -Iv https://yourhost:9091
You should see some output which looks something like this:
* About to connect() to yourhost port 9091 (#0)
* Trying 67.207.137.114... connected
* Connected to yourhost (67.207.137.114) port 9091 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS alert, Server hello (2):
* SSL certificate problem, verify that the CA cert is OK. Details:
From here you should be able to narrow down where to troubleshoot.