I have Fusionauth, PostgreSQL, Elasticsearch running from a docker-compose. Below is my docker-compose.
version: '3.1'
services:
postgres_db:
container_name: ${POSTGRES_CONTAINER}
image: postgres:9.6
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- ${POSTGRES_PORT}:5432
restart: unless-stopped
volumes:
- ${VOLUMES_DIR}/postgres_data:/var/lib/postgresql/data
es_search:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
container_name: ${ES_CONTAINER}
environment:
- cluster.name=fusionauth
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
ports:
- ${ES1_PORT}:9200
- ${ES_PORT}:9300
restart: unless-stopped
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ${VOLUMES_DIR}/es_data:/usr/share/elasticsearch/data
fusionauth:
image: fusionauth/fusionauth-app:1.14.0
container_name: ${FUSIONAUTH_CONTAINER}
depends_on:
- postgres_db
- es_search
environment:
DATABASE_URL: jdbc:postgresql://postgres_db:5432/fusionauth
DATABASE_ROOT_USER: ${POSTGRES_USER}
DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
FUSIONAUTH_MEMORY: ${FUSIONAUTH_MEMORY}
FUSIONAUTH_SEARCH_SERVERS: http://es_search:9200
FUSIONAUTH_URL: http://fusionauth:9011
FUSIONAUTH_KICKSTART: "/usr/local/fusionauth/fusionauth_kickstart.json"
FUSION_AUTH_API_KEY: ${FUSION_AUTH_API_KEY}
FUSION_AUTH_APP_ID: ${FUSION_AUTH_APP_ID}
FUSION_AUTH_LAMBDA_ID: ${FUSION_AUTH_LAMBDA_ID}
FUSION_AUTH_GOOGLE_CLIENT_ID: ${FUSION_AUTH_GOOGLE_CLIENT_ID}
FUSION_AUTH_GOOGLE_CLIENT_SECRET: ${FUSION_AUTH_GOOGLE_CLIENT_SECRET}
restart: unless-stopped
ports:
- ${FUSIONAUTH_PORT}:9011
volumes:
- ${VOLUMES_DIR}/fusionauth_data:/usr/local/fusionauth/config
- ${FUSIONAUTH_KICKSTART}:/usr/local/fusionauth/fusionauth_kickstart.json
Whenever I run test cases I want to reset this Fusionauth data to a particular state. To achieve this I am following below steps
- Take Postgres DB dump at the state I want to save using
sudo pg_dump -h 127.0.0.1 -Upostgres -p 5433 -d fusionauth > outfile.sql
- Now after creating some more users/lambdas and many other things, now If I want to reset DB state.
- Stop only fusionauth container.
- Delete all indices in Elasticsearch using
curl -XDELETE "http://localhost:${ES1_PORT}/_all"
- Truncate all Postgres tables using below bash script.
truncate_tables_in_postgres() {
if [ ! -z "$1" ]; then
#export_env_file $1
set -a
source $1
set +a
fi
get_table_names="SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE' AND
table_catalog='$DATABASE_USER'"
tables=$(export PGPASSWORD=$POSTGRES_PASSWORD; psql -h 127.0.0.1 -p $POSTGRES_PORT -U $POSTGRES_USER -d $DATABASE_USER -Atc
"$get_table_names")
tables_list=($tables)
query_string="TRUNCATE TABLE ${tables_list[0]}"
for table in "${tables_list[@]:1}"
do
query_string="$query_string, $table"
done
query_string="$query_string RESTART IDENTITY CASCADE;"
echo $query_string
export PGPASSWORD=$POSTGRES_PASSWORD; psql -h 127.0.0.1 -p $POSTGRES_PORT -U $POSTGRES_USER -d $DATABASE_USER -c "$query_string"
}
- Load the dump I have taken in first step using
psql -h 127.0.0.1 -Upostgres -p 5433 -d fusionauth -f outfile.sql
- Now restart fusionauth container
After doing all the above steps I am getting java.lang.NullPointerException
from fusionauth container
fusionauth-manisha Unable to start the server. Here's why:
fusionauth-manisha
fusionauth-manisha
fusionauth-manisha [Error injecting constructor, java.lang.NullPointerException]
fusionauth-manisha -> [class java.lang.NullPointerException] null
fusionauth-manisha
fusionauth-manisha ===================================================================================================
fusionauth-manisha
fusionauth-manisha
fusionauth-manisha Jul 23, 2020 8:47:15.564 AM ERROR org.primeframework.mvc.guice.GuiceBootstrap - Unable to start the server. Exception:
fusionauth-manisha
fusionauth-manisha com.google.inject.CreationException: Unable to create injector, see the following errors:
fusionauth-manisha
fusionauth-manisha 1) Error injecting constructor, java.lang.NullPointerException
fusionauth-manisha at io.fusionauth.api.domain.guice.FusionAuthTenantIdProvider.<init>(FusionAuthTenantIdProvider.java:22)
fusionauth-manisha at io.fusionauth.api.domain.guice.FusionAuthTenantIdProvider.class(FusionAuthTenantIdProvider.java:17)
fusionauth-manisha while locating io.fusionauth.api.domain.guice.FusionAuthTenantIdProvider
fusionauth-manisha for the 5th parameter of io.fusionauth.api.service.system.kickstart.DefaultKickstartService.<init>(DefaultKickstartService.java:83)
fusionauth-manisha while locating io.fusionauth.api.service.system.kickstart.DefaultKickstartService
fusionauth-manisha while locating io.fusionauth.api.service.system.kickstart.KickstartService
fusionauth-manisha for the 1st parameter of io.fusionauth.api.service.system.KickStarter.<init>(KickStarter.java:14)
fusionauth-manisha at io.fusionauth.api.service.guice.ServiceModule.configure(ServiceModule.java:149) (via modules: io.fusionauth.app.guice.FusionAuthModule -> com.google.inject.util.Modules$OverrideModule -> io.fusionauth.api.guice.APIModule -> io.fusionauth.api.service.guice.Ser
fusionauth-manisha while locating io.fusionauth.api.service.system.KickStarter
fusionauth-manisha
fusionauth-manisha 1 error
fusionauth-manisha at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:543)
fusionauth-manisha at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186)
fusionauth-manisha at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
fusionauth-manisha at com.google.inject.Guice.createInjector(Guice.java:87)
fusionauth-manisha at com.google.inject.Guice.createInjector(Guice.java:69)
fusionauth-manisha at com.google.inject.Guice.createInjector(Guice.java:59)
fusionauth-manisha at org.primeframework.mvc.guice.GuiceBootstrap.initialize(GuiceBootstrap.java:58)
fusionauth-manisha at org.primeframework.mvc.servlet.PrimeServletContextListener.contextInitialized(PrimeServletContextListener.java:61)
fusionauth-manisha at com.inversoft.maintenance.servlet.MaintenanceModePrimeServletContextListener.contextInitialized(MaintenanceModePrimeServletContextListener.java:59)
fusionauth-manisha at io.fusionauth.app.primeframework.FusionAuthAppPrimeServletContextListener.contextInitialized(FusionAuthAppPrimeServletContextListener.java:29)
fusionauth-manisha at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
fusionauth-manisha at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
fusionauth-manisha at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402)
fusionauth-manisha at java.util.concurrent.FutureTask.run(FutureTask.java:266)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
fusionauth-manisha at java.lang.Thread.run(Thread.java:748)
fusionauth-manisha Caused by: java.lang.NullPointerException: null
fusionauth-manisha at io.fusionauth.api.domain.guice.FusionAuthTenantIdProvider.<init>(FusionAuthTenantIdProvider.java:23)
fusionauth-manisha at io.fusionauth.api.domain.guice.FusionAuthTenantIdProvider$$FastClassByGuice$$2dc4e0cf.newInstance(<generated>)
fusionauth-manisha at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
fusionauth-manisha at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
fusionauth-manisha at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
fusionauth-manisha at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
fusionauth-manisha at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
fusionauth-manisha at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
fusionauth-manisha at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
fusionauth-manisha at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
fusionauth-manisha at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
fusionauth-manisha at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
fusionauth-manisha at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
fusionauth-manisha at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
fusionauth-manisha at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
fusionauth-manisha at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
fusionauth-manisha at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
fusionauth-manisha at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
fusionauth-manisha at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:211)
fusionauth-manisha at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:182)
fusionauth-manisha ... 17 common frames omitted
fusionauth-manisha Jul 23, 2020 8:47:15 AM org.apache.catalina.core.StandardContext listenerStart
fusionauth-manisha SEVERE: Exception sending context initialized event to listener instance of class [io.fusionauth.app.primeframework.FusionAuthAppPrimeServletContextListener]
fusionauth-manisha org.primeframework.mvc.PrimeException
fusionauth-manisha at org.primeframework.mvc.guice.GuiceBootstrap.initialize(GuiceBootstrap.java:77)
fusionauth-manisha at org.primeframework.mvc.servlet.PrimeServletContextListener.contextInitialized(PrimeServletContextListener.java:61)
fusionauth-manisha at com.inversoft.maintenance.servlet.MaintenanceModePrimeServletContextListener.contextInitialized(MaintenanceModePrimeServletContextListener.java:59)
fusionauth-manisha at io.fusionauth.app.primeframework.FusionAuthAppPrimeServletContextListener.contextInitialized(FusionAuthAppPrimeServletContextListener.java:29)
fusionauth-manisha at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
fusionauth-manisha at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
fusionauth-manisha at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402)
fusionauth-manisha at java.util.concurrent.FutureTask.run(FutureTask.java:266)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
fusionauth-manisha at java.lang.Thread.run(Thread.java:748)
fusionauth-manisha
fusionauth-manisha 23-Jul-2020 08:47:15.565 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
fusionauth-manisha 23-Jul-2020 08:47:15.567 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
fusionauth-manisha Jul 23, 2020 8:47:15 AM org.apache.catalina.core.StandardContext listenerStop
fusionauth-manisha SEVERE: Exception sending context destroyed event to listener instance of class [io.fusionauth.app.primeframework.FusionAuthAppPrimeServletContextListener]
fusionauth-manisha java.lang.NullPointerException
fusionauth-manisha at org.primeframework.mvc.guice.GuiceBootstrap.shutdown(GuiceBootstrap.java:88)
fusionauth-manisha at org.primeframework.mvc.servlet.PrimeServletContextListener.contextDestroyed(PrimeServletContextListener.java:47)
fusionauth-manisha at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4746)
fusionauth-manisha at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5403)
fusionauth-manisha at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
fusionauth-manisha at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412)
fusionauth-manisha at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402)
fusionauth-manisha at java.util.concurrent.FutureTask.run(FutureTask.java:266)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
fusionauth-manisha at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
How can I resolve this problem?