Tomcat Config - catalina.properties

Answered

Hi all,

I have a run configuration that uses a tomcat server with the home directory of the tomcat server files and the base directory are the conf files from the development server.
In the server.xml it uses the catalina.properties to populate the properties, for example:

 <Host name="${base.hostname}" 

In the catalina.properties, base.hostname is populated.. in this instance base.hostname=localhost

When I start the configuration, intellij gives me the "server.xml does not contain virtual host 'localhost'...
So I change the server.xml to <Host name="localhost" and this intellij error goes away, is there anyway of getting intellij to use the properties file, or turning this off? I don't want to go through the server.xml and populating all the properties references.

Thanks.

C.

1
5 comments

Have you modified the default Tomcat installation and/or Tomcat Server Run/Debug Configuration?

Does this work if you start Tomcat from the command line?

0

I haven't modified the default Tomcat installation, it is as it was when I extracted it from the archive file.

I created a new Tomcat Server Run/Debug Configuration and set up the home as the Tomcat installation and the base is another directory with the Tomcat "conf" directory from the development server. This conf has the server.xml etc inside.

When I run it from the command line by setting the CATALINA_HOME as the Tomcat installation and the CALALINA_BASE as the other directory, Tomcat starts up, but I am not seeing this "server.xml does not contain virtual host 'localhost'" error.

0

CATALINA_HOME and CALALINA_BASE must point by default into the Tomcat installation directory, where the conf directory is located. If you did not modify the Tomcat installation please set them to same directory:

0

I have same issue. Downloaded apache tomcat 7.0.109 for windows x64, I am using openjdk 1.8_332 from openlogic for my project. In IDEA Run configuration for local Tomcat I've set up to use this downloaded tomcat, it placed both home and base directory to same path.

And only thing I changed in tomcat is I added my own catalina.properties, context.xml and server.xml that are using placeholders to define datasource values.

When I start run configuration I get 

SEVERE: Exception processing Global JNDI Resources
javax.naming.NamingException: Unexpected exception resolving reference [Root exception is java.sql.SQLException: Driver:com.mysql.jdbc.Driver@1835c46 returned null for URL:${jdbc.datasource.url}]
    at org.apache.naming.NamingContext.lookup(NamingContext.java:864)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
    at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:117)
    at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
    at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:34)
    at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:138)
    at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:145)
    at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:110)
    at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:82)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:737)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:712)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.sql.SQLException: Driver:com.mysql.jdbc.Driver@1835c46 returned null for URL:${jdbc.datasource.url}
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:295)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:181)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:738)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:670)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
    at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
    at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:244)
    at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:332)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:847)
    ... 20 more

I have this placeholder defined in my catalina.properties

Everything works when I start tomcat from terminal , but when I use Intellij IDEA Tomcat run configuration it just doesnt care about properties defined in catalina.properties.

Btw my Intellij is Build #IU-213.7172.25

0

My mistake I had additional placeholders in xml defined, but didnt have them in catalina.properties.

It is working as expected. Sorry

0

Please sign in to leave a comment.