Benoit,

I am still dead in the water.  I've spent the entire day trying things and digging into the code.
- It works fine on the same build with the spring version
- If FAILS on WINDOWS as well as Linux
- Other jars in the same folder are loaded without problem

I've tried putting the driver file in every folder I can think of. and tried both relative and fully qualified paths in classpath.  I expanded the driver jar file and pulled the Driver class setting up a com/mysql/jdbc/Driver folder path for the class file.  I've tried setting classpath externally and specifying classpath in the java command. Nothing works.

I downloaded jpa source and dug into the code.  It is failing in jpa's DataSourceFactory.java on a simple java native classForName api.  It fails on the custom loader call, then tries again using native java in the catch block.  Failing there throws the exception.   I've used that method hundreds of times.  The three ways I know it can fail:

- Class truly doesn't exist in classpath (I'm certain after days of testing that this is not the case) - Class is corrupted (but same jar file is loaded with no problem in the spring implementation
- Classpath is missing or incorrect by the time the loader is called.

Unfortunately, I have found no way to get a trace of the classpath used by the classloader. I know I'm passing in the correct classpath.  Is there any possibility that the classpath could be altered prior to calling the jpa class resolver code?

Is there any way you can try to reproduce this just to confirm or reject the thought that I'm going crazy?  It should only take a couple of minutes.  Simply explode the jpa-guice zip, change james-database.properties, and copy the driver file somewhere.  If it finds the driver for you, then I'll try to figure out what is different.  If it fails for you as well, maybe the two of us together can figure out what is wrong.

Please advise.

Thanks. I really appreciate your help.

Jerry


On 10/4/2021 7:21 PM, Jerry Malcolm wrote:
Benoit,

Update to my earlier post below:

- Uploaded spring implementation to a parallel directory on the same server I'm setting up guice implementation on
- Tested out-of-the-box.  Server started clean.
- Edited james-database.properties and changed to mysql
- Copied the mysql driver to lib folder.
- Successfully started.  And I verified in the console logs that it was indeed talking to the mysql server.

So from what I have found,  out-of-the-box spring + mysql driver works fine

Out of the box guice (from the jpa-guice folder of the same build) + maria/mysql cannot find driver jar file (see earlier post below for more details)

I am more than willing to add some debug statements in the jpa-guice code if you can tell me what to look for and where to look.  But I'm at a loss.

Let me know what you think.

Jerry


On 10/4/2021 6:50 PM, Jerry Malcolm wrote:
Benoit,

No success yet.  I started over completely clean:

-- Refreshed latest master from git, rebuilt clean and re-deployed to my server.
-- Created keystore using password in sample-configuration files.
-- Out of the box, it started clean.
-- I renamed james-database.properties to *.save and renamed james.database.mariadb.properties to james.database.properties -- I downloaded a new mariadb-java-client-2.0.2.jar from the mariadb site.
-- I first put it in extensions-jars folder.  Failed
-- I moved it to james-server-jpa.app.lib Failed.

I actually need mysql, not maria.  I didn't try the test again with mysql this time.  But if mariadb doesn't work. I'm going to assume that mysql still will not work.

Earlier in the day when I couldn't think of anything else to try, I went back to derby just to get past this problem temporarily, and I brought in all of my own customized conf xml files and added all of the associated jar files to extensions-jars just to see if JAMES could find other extension jar files.  I got a bunch of Guice @inject errors on my mailet implementations, which is a question for another day.  But the fact that it reported Guice errors means it found my custom mailet jar files without any problem.

I also double-checked my java version, and I'm running 11.

As I mentioned earlier, I copied the mysql jar from my running production server (probably 10-12 month old production JAMES 3.0.x, but not having any problems.)

My next step is to install a parallel spring server from the same build on this same server using the same mariadb / mysql drivers and see if the problem moves to spring install or not. Not sure what I'll do either way to resolve the guice problem. But more information is good.

I am also totally comfortable with adding log or println statements anywhere in the james code if you tell me what to log.

Thanks again for your help.

Jerry


On 10/4/2021 3:11 AM, btell...@apache.org wrote:
Have you tried puttil the driver JAR in james-server-jpa-app.lib, maybe?

On 04/10/2021 12:02, Jerry Malcolm wrote:
On 10/3/2021 11:36 PM, Jerry Malcolm wrote:
On 10/3/2021 11:14 PM, btell...@apache.org wrote:
Hello,

Extra driver needs to be explicitly added to the classpath.

java -Djdk.tls.ephemeralDHKeySize=2048 \
       -classpath 'james-server-jpa-app.lib/*:/path/to/driver.jar' \
       -javaagent:/root/libs/openjpa-3.1.2.jar \
-Dlogback.configurationFile=/root/conf/logback.xml \
        -Dworking.directory=/root/ org.apache.james.JPAJamesServerMain

Note that I did add extra instructions on the 3.7.0 release line.
Benoit,

Thanks, I'll try that.  I did a git clone about a month ago.  So I
missed that in the release notes.  I'm just sandboxing now. Once I
think I've got everything working, I'll pull again from the master
for my production build.

Benoit,

No success using the classpath parameter.  Here's what I have for the
full start up line:

exec java \
  -javaagent:james-server-jpa-app.lib/openjpa-3.1.2.jar \
  -classpath
'james-server-jpa-app.lib/*:/usr/share/james/conf/lib/external/mysql-connector-java-8.0.26.jar'
\
  -Dworking.directory=. \
  -Djdk.tls.ephemeralDHKeySize=2048 \
  -Dlogback.configurationFile=conf/logback.xml \
  -Xms128m \
  -Xmx512m \
  -Dcom.sun.management.jmxremote=true \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -jar james-server-jpa-app.jar \

I checked that the jar file specified does exist in conf/lib/eternal.

I tried using the relative path: conf/lib/external/....jar as well as
the fully qualified path as specified in the command line above.  I'm
still getting ClassNotFound exceptions on the mySQL class.

   -
https://github.com/apache/james-project/tree/master/server/apps/jpa-app#using-alternative-jdbc-drivers


   -
https://github.com/apache/james-project/blob/master/server/apps/jpa-app/docker-compose.yml


Best regards,

Benoit

On 04/10/2021 11:06, Jerry Malcolm wrote:
I have a different issue in my migration from spring to jpa-guice.  I absolutely cannot get james/java to locate my jdbc driver.  I copied a
working driver from my spring server and the associated
james-database.properties to my jpa-guice server.  I played around
with classpaths and ended up putting the mysql jar directly in the
james-server-jpa-app.lib folder.  But no matter what I do,  I
always get:

Caused by: java.lang.ClassNotFoundException: org.mysql.jdbc.Driver
          at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)

          at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)


I'm using mysql, not maria.  But just in desperation, I downloaded the
mariadb driver and put it in the lib folder as well. I changed the
properties file to call out the mariadb driver.  Got the same error. It can't find mariadb driver either.  I changed it back to derby, and
it worked.

So I've got mysql (that is working fine in my production server),
mariadb, and derby drivers side by side in the same lib folder. Java
finds 1 and can't find the other two.

I have a pretty good handle on how jar files, classpaths, loaders
work.  This one totally baffles me.  Is there something I need to
change for the jpa-guice build or some place specific that I need to
put the driver jar?


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to