Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:30:20+00:00 2026-06-09T08:30:20+00:00

I have a working Apache 2.2.16 on Debian Squeeze that serves some PHP applications

  • 0

I have a working Apache 2.2.16 on Debian Squeeze that serves some PHP applications from /var/www/ using different domains (e.g. phpApp1.com, phpApp2.com).

I also have a working Tomcat 7.x that lives in /opt/tomcat/ and servers a JSF+JPA application that lives in /opt/tomcat/webapps/MyApp/.

So MyApp can be accessed through e.g. myapp.com:8080/MyApp/home.html or phpApp1.com:8080/MyApp/home.html (because of the port). Since I wanted this to be myapp.com/home.html instead, I connected Apache and Tomcat using mod_proxy_ajp using the following config files:

An Apache virtual host in /etc/apache2/sites-available/MyApp

<Virtualhost *:80>
    ServerName myapp.com
    ServerAlias *.myapp.com
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
</Virtualhost>

And a Tomcat virtual host in /opt/tomcat/conf/server.xml

<Host name="myapp.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
    <Context path="" reloadable="true" debug="0" docBase="MyApp" />
    <Alias>www.myapp.com</Alias>
</Host>

This works to the point that I cann access http://myapp.com/home.html and get a correct html page including css, images and js. So the AJP connector in tomcat should work.

BUT the app fails to establish a JDBC connection that otherwise works fine. It does not matter whether i use myapp.com or myapp.com:8080, it fails either way. However, it works if I access my app throug http://phpapp1.com:8080/MyApp/home.html. It only fails when I use the proxy-domain “myapp.com”.

Has anyone experienced similar problems when using AJP and JDBC? How can I solve this? I had the same problem when using mod_jk, which makes use of AJP, too. Thanks in advance.

Update 1

@Mark Rotteveel: What do you mean by “connecting directly”? I mean the JDBC connection is working if I use one of the domains that are not listed as virtual hosts in tomcats server.xml.

Here is the connection error:

ERROR: HHH000231: Schema export unsuccessful
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.DatabaseExporter.<init>(DatabaseExporter.java:52)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:367)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:304)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:293)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:492)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.myapp.util.database.Database.<init>(Database.java:70)
at com.myapp.util.database.Database.<clinit>(Database.java:38)
at com.myapp.controller.file.UploadBacking.ajaxUpload(UploadBacking.java:89)
at com.myapp.controller.file.UploadBacking$Proxy$_$$_WeldClientProxy.ajaxUpload(UploadBacking$Proxy$_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:264)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
at org.apache.myfaces.view.facelets.tag.jsf.core.AjaxHandler$AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:495)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:57)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:74)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:405)
at javax.faces.component.UICommand.broadcast(UICommand.java:103)
at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:183)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 60 more

From Database.java:

private Database() {
    entityManagerFactory = Persistence.createEntityManagerFactory("myapp_persistence_unit");
}

MyApp/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Context>

<Context>

<Resource
    name="jdbc/db_myapp" 
    auth="Container"
    type="javax.sql.DataSource" 
    username="user_myapp" 
    password="##########"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/db_myapp?autoReconnect=true"
    validationQuery="select 1"
    maxActive="15" 
    maxIdle="3" />

<Valve
    className="org.apache.catalina.valves.AccessLogValve"
    directory="logs/myapp"
    prefix="myapp_access_"
    suffix=".log"
    pattern="%h %l %u %t &quot;%r&quot; %s %b"
    resolveHosts="false" />

</Context>

From WEB-INF/web.xml

<resource-ref>
    <description>MySQL database</description>
    <res-ref-name>jdbc/db_myapp</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

And finally WEB-INF/classes/META-INF/persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="myapp_persistence_unit">
        <properties>
            <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/db_myapp" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            <property name="hibernate.current_session_context_class" value="thread" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
        </properties>
    </persistence-unit>

</persistence>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:30:22+00:00Added an answer on June 9, 2026 at 8:30 am

    I finally got it to work. If you create a virtual host in tomcat, you have to put an exact copy of your applications /META-INF/context.xml into /tomcat/conf/Catalina/domain.com/ and name it context.xml.default. Well, I don’t know if this is always the case, but for my setting it was. So these are my current config files that do the job:

    /etc/apache2/sites-enabled/domain.com

    <Virtualhost *:80>
        ServerName domain.com
        ServerAlias *.domain.com
    
        ProxyRequests Off
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
        ProxyPass / ajp://my.server.ip:8009/
    </Virtualhost>
    

    /tomcat/conf/server.xml

    <Host name="domain.com">
        <Context path="" docBase="MyApp" />
        <Alias>www.domain.com</Alias>
    </Host>
    

    I tried this after reading this thread on coderanch.com from 2006 (the authors solution is in the last post). I did not change the web.xml or context.xml since this was not a misconfiguration of the <Resource> element. Anyway, thanks for your attempts to help 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working prototype of a Java application that is using Apache Commons
I have a codeigniter code that is working on local Apache installation. But it
Ok I have PHP working on my mac os x Apache 2 server. Problem
I have a working WordPress permalink set-up. I run on Apache's using the following
I have a working WAMP environment (Apache Friends). I decided to try Subversion and
I have Apache installed with the XAMPP package, and I'm working locally. I have
I have ported Apache Tika to Android. I have a basic question. While working
I have working website in PHP with a MySQL backend which has several tables
I have working code of js, it shows different div for selected option. <html>
I have working registration script the only problem is that i do not know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.