Projects tigase _server server-core Issues #1185
NPE in SchemaManager (#1185)
wojciech.kapcia@tigase.net opened 4 years ago

If we remove named DataSource but reference it in the TDSL there's a NPE:

ADVERTENCIA: Error getting repository implementation
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at tigase.db.util.SchemaManager.getRepositoryImplementation(SchemaManager.java:887)
	at tigase.db.util.SchemaManager.lambda$null$59(SchemaManager.java:807)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.concurrent.ConcurrentHashMap$ValueSpliterator.forEachRemaining(ConcurrentHashMap.java:3605)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at tigase.db.util.SchemaManager.getRepositories(SchemaManager.java:822)
	at tigase.db.util.SchemaManager.getDataSourcesAndSchemas(SchemaManager.java:422)
	at tigase.db.util.SchemaManager.loadSchemas(SchemaManager.java:450)
	at tigase.db.util.SchemaManager.loadSchemas(SchemaManager.java:630)
	at tigase.db.util.SchemaManager.upgradeSchema(SchemaManager.java:362)
	at tigase.util.ui.console.Task.execute(Task.java:59)
	at tigase.db.util.SchemaManager.execute(SchemaManager.java:228)
	at tigase.db.util.SchemaManager.main(SchemaManager.java:182)
Caused by: java.lang.NullPointerException
	at tigase.stats.db.CounterDataLoggerRepoBean.findClassForDataSource(CounterDataLoggerRepoBean.java:54)
	... 31 more

Example config:

stats {
    'stats-logger' (class: tigase.stats.CounterDataLogger) {
        frequency = '300'
        repository () {
            default () {
                'data-source' = 'counter-data-repository'
            }
        }
    }
}
wojciech.kapcia@tigase.net commented 4 years ago

The issue was addressed in #issue #1184 but decided to improve slightly warning to make it more informative:

ADVERTENCIA: Error getting repository implementation for: stats-logger bean and named repository: counter-data-repository, available dataSources:
[default[uri=jdbc:derby:tigasedb;create=true]]
java.lang.RuntimeException: No dataSource configured!
	at tigase.db.util.SchemaManager.getRepositoryImplementation(SchemaManager.java:874)
…
``
issue 1 of 1
Type
Task
Priority
Normal
Assignee
Version
tigase-server-8.2.0
Spent time
1h 15m
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#1185
Please wait...
Page is in error, reload to recover