WahidNasri / hivemq-chat-extension

HiveMQ extension to use MQTT as chat protocol.
GNU General Public License v3.0
8 stars 7 forks source link

nextExtensionOrDefault must not be called if authenticateSuccessfully, failAuthentication, continueAuthentication #7

Open lucasjinreal opened 3 years ago

lucasjinreal commented 3 years ago
2021-10-24 03:59:35,209 INFO  - nextExtensionOrDefault must not be called if authenticateSuccessfully, failAuthentication, continueAuthentication or nextExtensionOrDefault has already been called.
2021-10-24 03:59:35,209 INFO  - Client disconnected with id: android_f_client_swWbU 
2021-10-24 03:59:35,231 INFO  - MQTT 3.1 client connected with id: android_f_client_swWbU 
java.lang.NullPointerException
    at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
    at java.base/java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
    at java.base/java.util.Properties.put(Properties.java:1334)
    at com.db.MyBatis.getProperties(MyBatis.java:18)
    at com.db.MyBatis.getSession(MyBatis.java:29)
    at com.db.MyBatis.getUser(MyBatis.java:35)
    at com.chat.authorizers.authentication.connectAuthorizers.LoginAuthorizer.authorize(LoginAuthorizer.java:22)
    at com.chat.authorizers.authentication.MyAuthenticatorProvider.lambda$getAuthenticator$0(MyAuthenticatorProvider.java:49)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.call(ConnectSimpleAuthTask.java:44)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.call(ConnectSimpleAuthTask.java:28)
    at com.hivemq.extensions.auth.AbstractAuthTask.apply(AbstractAuthTask.java:55)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.apply(ConnectSimpleAuthTask.java:28)
    at com.hivemq.extensions.auth.AbstractAuthTask.apply(AbstractAuthTask.java:31)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.runInOutTask(PluginTaskExecutor.java:332)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.runTask(PluginTaskExecutor.java:302)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.executeTask(PluginTaskExecutor.java:251)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.run(PluginTaskExecutor.java:164)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
2021-10-24 03:59:35,232 INFO  - nextExtensionOrDefault must not be called if authenticateSuccessfully, failAuthentication, continueAuthentication or nextExtensionOrDefault has already been called.
2021-10-24 03:59:35,232 INFO  - Client disconnected with id: android_f_client_swWbU 
lucasjinreal commented 3 years ago

using test info:

image

lucasjinreal commented 3 years ago

@WahidNasri Help!! Please help

WahidNasri commented 3 years ago

Hello @jinfagang I will take a look very soon, Thank you for your interest

lucasjinreal commented 3 years ago

@WahidNasri thanks god you replied me. thank u so much, I really want make your mqtt app get run cause I really love it. I want to make this able to chat. But currently stucked at login, server side error like this

lucasjinreal commented 3 years ago

@WahidNasri did u got a chance to help me out on this issue? I am really want make this app run

WahidNasri commented 3 years ago

@jinfagang Do you build the project on your own or you're using the prebuilt version? It seems like you have some issues with the SQL session.

WahidNasri commented 3 years ago

@jinfagang Now you can set your Database information on the project before you build it, please refer to the file mybatis-config.xml for that.

lucasjinreal commented 3 years ago

@WahidNasri Thanks! Now i have another question, how do I build such file: ChatExtension-1.0-SNAPSHOT-distribution.zip since I changed the xml config, I forget how to do it...

lucasjinreal commented 3 years ago

@WahidNasri I using mvn package got error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.476 s
[INFO] Finished at: 2021-10-29T06:21:57+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.asciidoctor:asciidoctor-maven-plugin:0.0.1 or one of its dependencies could not be resolved: Could not find artifact org.asciidoctor:asciidoctor-maven-plugin:jar:0.0.1 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
lucasjinreal commented 3 years ago

image

@WahidNasri Does the pom.xml need to edit?

lucasjinreal commented 3 years ago

@WahidNasri Now I get error like this:

2021-10-29 06:48:49,056 INFO  - MQTT 3.1 client connected with id: android_f_client_BauuJ 
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
### The error may exist in com/db/UserMapper.java (best guess)
### The error may involve com.db.UserMapper.getUserByEmailAndPassword
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:153)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
    at com.sun.proxy.$Proxy48.getUserByEmailAndPassword(Unknown Source)
    at com.db.MyBatis.getUser(MyBatis.java:28)
    at com.chat.authorizers.authentication.connectAuthorizers.LoginAuthorizer.authorize(LoginAuthorizer.java:22)
    at com.chat.authorizers.authentication.MyAuthenticatorProvider.lambda$getAuthenticator$0(MyAuthenticatorProvider.java:49)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.call(ConnectSimpleAuthTask.java:44)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.call(ConnectSimpleAuthTask.java:28)
    at com.hivemq.extensions.auth.AbstractAuthTask.apply(AbstractAuthTask.java:55)
    at com.hivemq.extensions.auth.ConnectSimpleAuthTask.apply(ConnectSimpleAuthTask.java:28)
    at com.hivemq.extensions.auth.AbstractAuthTask.apply(AbstractAuthTask.java:31)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.runInOutTask(PluginTaskExecutor.java:332)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.runTask(PluginTaskExecutor.java:302)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.executeTask(PluginTaskExecutor.java:251)
    at com.hivemq.extensions.executor.task.PluginTaskExecutor$PluginTaskExecutorRunnable.run(PluginTaskExecutor.java:164)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client

but my MySql is on, and there actually have default data in it??

lucasjinreal commented 3 years ago
 <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>

but my sql:

image

lucasjinreal commented 3 years ago

@WahidNasri Now, I am able to in, but get error in home screen:

 AUTHORIZED
2021-10-29 07:04:32,854 ERROR - Uncaught Error:
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'uranus.USER' doesn't exist
### The error may exist in com/db/UserMapper.java (best guess)
### The error may involve com.db.UserMapper.getUserContacts-Inline
### The error occurred while setting parameters
### SQL: SELECT DISTINCT     u.id,     m.room_id roomId,     u.first_name firstName,     u.last_name lastName,     u.email,     u.avatar,     r.is_group isGroup FROM     USER u JOIN room_membership m ON     u.id = m.user_id JOIN room r ON     r.id = m.room_id WHERE     m.room_id IN(     SELECT         m.room_id     FROM         room_membership m     WHERE         m.user_id = ? ) AND u.id <> ? AND r.is_group = 0 UNION ALL SELECT     r.id id,     r.id roomId,     r.name firstName,     '' lastName,     '' email,     r.avatar avatar,     r.is_group isGroup FROM     `room_membership` m JOIN room r ON     m.room_id = r.id WHERE     r.is_group = 1 AND user_id = ?;
### Cause: java.sql.SQLSyntaxErrorException: Table 'uranus.USER' doesn't exist
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:153)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
    at com.sun.proxy.$Proxy48.getUserContacts(Unknown Source)
    at com.db.MyBatis.getUserContacts(MyBatis.java:69)
    at com.chat.authorizers.authentication.connectAuthorizers.LoginAuthorizer.lambda$sendRoomsArchives$0(LoginAuthorizer.java:41)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.sql.SQLSyntaxErrorException: Table 'uranus.USER' doesn't exist
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
    at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:371)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
    ... 10 common frames omitted

I only changed db name from chat -> uranus,

image

the tables exist, anything wrong?

lucasjinreal commented 3 years ago

@WahidNasri Can u help add adopt for mysql 8.0 since it changed a lot of things, currently I googled a lot this issue caused by nullCatalogMeansCurrent this value set false in 8.0, but I don't know how to set it in mybatis, I am totally confused so much!