0

I'm trying to put my web site on line. For that, I've a debian and a jetty server. When I try to go on my web site, it show my the homepage, so, this is ok.

But, when I try to log in, it put me an error message.

It's working on my local machine with this configuration :

<?xml version="1.0" encoding="utf-8"?>
<domain project-version="6">
    <map name="datamap"/>

    <node name="datanode"
         factory="org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory"
        >
        <map-ref name="datamap"/>
        <data-source>
            <driver value="com.mysql.jdbc.Driver"/>
            <url value="jdbc:mysql://127.0.0.1:3306/database"/>
            <connectionPool min="1" max="10"/>
            <login userName="username" password="password"/>
        </data-source>
    </node>
</domain>

So,I verified the username and password are ok. I tried to execute my web site on my own machine with the new configuration :

<url value="jdbc:mysql://serverip:3306/database"/>

What did I miss?

The error message is :

enter image description here

(I'm sorry, I'm trying to find where I can find the jetty log on the server, I will update it with the full stack)

I supposed I forget one information? I'm sure about my password and login for the mysql on the server. I'm using SSH, the configuration is in my workbench : enter image description here

I'm using maven, so I add mysql in the pom.xml :

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

I read that can be because we didn't put the mysql in the classpath. But, that should works, shouldn't it?

EDIT : I tried : <url value="jdbc:mysql://serverusername@serverpwd/serverip:3306/database"/>, without success...

EDIT 2 : This configuration is working :

<node name="datanode"
    factory="org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory"
    schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
    <map-ref name="datamap" />
    <data-source>
        <driver value="com.mysql.jdbc.Driver" />
        <url value="jdbc:mysql://127.0.0.1/database" />
        <connectionPool min="1" max="1" />
        <autoReconnect> true</autoReconnect>
        <failOverReadOnly>  false</failOverReadOnly>
        <login userName="userName" password="password" />
    </data-source>
</node>
Bob
  • 529
  • 1
  • 7
  • 28
  • The error is a general connectivity error. Not related to your credentials. Is your database running on the same machine as your Jetty? Try to ssh to the server, and the following command there: "netstat -an |grep 3306" this will show if the DB is there and is using the expected port. – andrus_a Sep 08 '17 at 11:47
  • Oh ok, because I had an credential issue too ! I'll do that and give you the answer, Thanks a lot, I'm still blocking on that – Bob Sep 08 '17 at 13:17
  • The result is : tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN – Bob Sep 10 '17 at 10:22
  • :( no idea? I'm still block on this without any idea – Bob Sep 15 '17 at 08:13
  • Another shot in the dark. The connection may be timing out. Try adding this to the URL: "?connectTimeout=0&autoReconnect=true" . For an even more reliable result, try using an external connection pool, e.g. Hikari - http://www.baeldung.com/hikaricp with appropriate reconnect properties. Cayenne can be instructed to use an external connection pool on startup via ServerRuntime.builder(..).dataSource(dataSource)... – andrus_a Sep 15 '17 at 12:20
  • thanks ! I don't know why it's working now. I tried what you tell me and first it was not working. And the second time (I deployed it two times) and then it's working. I changed a little the XML file, see in the post as EDIT 2 – Bob Sep 17 '17 at 10:00
  • Could you put your comment in a answer? I'll put it as solve. – Bob Sep 17 '17 at 10:07
  • 1
    I just posted the answer. Note that Cayenne will ignore and tags. So they don't do anything really. These parameters need to be added to the URL inside the – andrus_a Sep 17 '17 at 14:06
  • Ok, When I put the connect timeou and auto reconnect in the URL, I've an error like 'need a ; after autoreconnect' – Bob Sep 18 '17 at 07:40

1 Answers1

1

The connection may be timing out. Try adding this to the URL: ?connectTimeout=0&autoReconnect=true. For an even more reliable result, try using an external connection pool, e.g. Hikari, with appropriate reconnect properties. Cayenne can be instructed to use an external connection pool on startup via ServerRuntime.builder(..).dataSource(dataSource)..

andrus_a
  • 2,528
  • 1
  • 16
  • 10
  • Now, I don't have any issue. But, i cannot have my data stored in the database. It's a strange behavior! – Bob Sep 19 '17 at 09:08