1

I'm trying to create a working development environment using a TomEE 8.0.4 docker image. I'm packaging my project into a war with all the dependencies (those which not provided with TomEE). Then I'm copying that war to the webapps directory in the docker container with

docker cp app.war tomee-instance:/usr/local/tomee/webapps

That's giving me these logs:

tomee-instance       | 14-Nov-2020 00:31:43.724 INFO [Catalina-utility-1] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Undeploying context [/app]
tomee-instance       | 14-Nov-2020 00:31:43.743 WARNING [Catalina-utility-1] com.sun.faces.config.ConfigureListener.contextDestroyed Unexpected state during contextDestroyed: no ConfigManager instance in current ServletContext but one is expected to exist.
tomee-instance       | 14-Nov-2020 00:31:43.765 INFO [Catalina-utility-1] org.apache.openejb.assembler.classic.Assembler.destroyApplication Undeploying app: /usr/local/tomee/webapps/app
tomee-instance       | 14-Nov-2020 00:31:43.773 INFO [Catalina-utility-1] org.apache.openejb.assembler.classic.Assembler.doResourceDestruction Closing DataSource: app/appDS
tomee-instance       | 14-Nov-2020 00:31:43.900 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [app] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
tomee-instance       | 14-Nov-2020 00:31:43.911 INFO [Catalina-utility-1] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application archive [/usr/local/tomee/webapps/app.war]
tomee-instance       | 14-Nov-2020 00:31:43.911 INFO [Catalina-utility-1] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /app
tomee-instance       | 14-Nov-2020 00:31:43.913 INFO [Catalina-utility-1] org.apache.openejb.util.JarExtractor.extract Extracting jar: /usr/local/tomee/webapps/app.war
tomee-instance       | 14-Nov-2020 00:31:43.938 INFO [Catalina-utility-1] org.apache.openejb.util.JarExtractor.extract Extracted path: /usr/local/tomee/webapps/app
tomee-instance       | 14-Nov-2020 00:31:43.941 WARNING [Catalina-utility-1] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Context] failed to set property [cachingAllowed] to [false]
tomee-instance       | 14-Nov-2020 00:31:44.119 INFO [Catalina-utility-1] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /usr/local/tomee/webapps/app
tomee-instance       | 14-Nov-2020 00:31:44.237 INFO [Catalina-utility-1] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=app/appDS, type=Resource, provider-id=Default JDBC Database)
tomee-instance       | 14-Nov-2020 00:31:44.237 INFO [Catalina-utility-1] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Resource(id=app/appDS)
tomee-instance       | 14-Nov-2020 00:31:44.382 INFO [Catalina-utility-1] org.apache.openejb.config.AutoConfig.processResourceRef Auto-linking resource-ref 'openejb/Resource/app/appDS' in bean app.Comp1660470862 to Resource(id=app/appDS)
tomee-instance       | 14-Nov-2020 00:31:44.382 INFO [Catalina-utility-1] org.apache.openejb.config.AutoConfig.processResourceRef Auto-linking resource-ref 'openejb/Resource/appDS' in bean app.Comp1660470862 to Resource(id=app/appDS)
tomee-instance       | 14-Nov-2020 00:31:44.383 INFO [Catalina-utility-1] org.apache.openejb.config.AutoConfig.deploy Configuring PersistenceUnit(name=app-pu, provider=org.eclipse.persistence.jpa.PersistenceProvider)
tomee-instance       | 14-Nov-2020 00:31:44.384 INFO [Catalina-utility-1] org.apache.openejb.config.AutoConfig.setJtaDataSource Adjusting PersistenceUnit app-pu <jta-data-source> to Resource ID 'app/appDS' from 'null'
tomee-instance       | 14-Nov-2020 00:31:44.384 INFO [Catalina-utility-1] org.apache.openejb.config.AutoConfig.setNonJtaDataSource Adjusting PersistenceUnit app-pu <non-jta-data-source> to Resource ID 'app/appDSNonJta' from 'null'
tomee-instance       | 14-Nov-2020 00:31:44.387 INFO [Catalina-utility-1] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/usr/local/tomee/webapps/app" loaded.
tomee-instance       | 14-Nov-2020 00:31:44.387 INFO [Catalina-utility-1] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /usr/local/tomee/webapps/app

And then one exception for each class of my model, something identical to this:

tomee-instance       | 14-Nov-2020 00:31:44.394 INFO [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [com.example.base.core.model.IdEntity_]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
tomee-instance       |    java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.example.base.core.model.IdEntity_]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
tomee-instance       |            at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
tomee-instance       |            at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
tomee-instance       |            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
tomee-instance       |            at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:209)
tomee-instance       |            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
tomee-instance       |            at java.base/java.lang.Class.forName0(Native Method)
tomee-instance       |            at java.base/java.lang.Class.forName(Unknown Source)
tomee-instance       |            at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToClass(ConversionManager.java:461)
tomee-instance       |            at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:159)
tomee-instance       |            at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:225)
tomee-instance       |            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.preInitializeCanonicalMetamodel(EntityManagerSetupImpl.java:3966)
tomee-instance       |            at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:384)
tomee-instance       |            at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:316)
tomee-instance       |            at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:112)
tomee-instance       |            at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:134)
tomee-instance       |            at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:105)
tomee-instance       |            at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:157)
tomee-instance       |            at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:924)
tomee-instance       |            at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:759)
tomee-instance       |            at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1309)
tomee-instance       |            at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1131)
tomee-instance       |            at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
tomee-instance       |            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
tomee-instance       |            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5044)
tomee-instance       |            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
tomee-instance       |            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
tomee-instance       |            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
tomee-instance       |            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
tomee-instance       |            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
tomee-instance       |            at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848)
tomee-instance       |            at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
tomee-instance       |            at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
tomee-instance       |            at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
tomee-instance       |            at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
tomee-instance       |            at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
tomee-instance       |            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
tomee-instance       |            at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1620)
tomee-instance       |            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:305)
tomee-instance       |            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
tomee-instance       |            at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1151)
tomee-instance       |            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1353)
tomee-instance       |            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1357)
tomee-instance       |            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1335)
tomee-instance       |            at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
tomee-instance       |            at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
tomee-instance       |            at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
tomee-instance       |            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
tomee-instance       |            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
tomee-instance       |            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
tomee-instance       |            at java.base/java.lang.Thread.run(Unknown Source)

Then, if I try to access the app with the browser I have this:

java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.ref.PhantomReference]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

It's just an example, because sometimes I get this exception but when it tries to load PostgreSQL related classes.

If I restart the container (which I'm trying to avoid due to time considerations), there are no errors and the app works as expected.

The app context.xml is the following:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/app" antiResourceLocking="false" cachingAllowed="false" reloadable="true" override="true" privileged="true" />

The project is a simple JAX-RS service, with neither EJBs nor frameworks like Spring.

I'm sorry if I'm feeling desperate, but the TomEE docs didn't help, and I don't know how to continue.

Edit: I've put the complete catalina.log after the container has started and the app redeployed at pastebin, here. And the same file, after some request have been done until an error page is delivered here.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Alfredo Tostón
  • 327
  • 2
  • 12
  • Two thoughts on this: 1. The exception message in the second box seems to be a follow-up of an error that happened early. Can you add (a) the very first exception including the "Caused by" part, and (b) the log file of the tomee container _before_ you copy the war into it? 2. I see you are adding the application after the container was already created and started. You should definitely create your own Dockerfile and image so that you can add your application war _before_ you create and start the container. This may also help with your issue. – Kekzpanda Feb 02 '21 at 01:46
  • Hello, after all, thanks for the reply. About point (1) I've just put the entire logs at pastebin as I'm saying in the las edited paragraph (now the las one). At (2), I've heard people rebuild the entire image each time they deploy. I'm trying to avoid that, ir order to save development time, but my intention is to publish the app in a by-me-managed docker environment, and call me a crank, but I'd prefer not to rebuild the entire image each time I deploy. In addition, is a physical tomee server unable to deploy on the fly? And if the answer is negative, how, and why the docker image is? – Alfredo Tostón Feb 03 '21 at 17:08
  • The issue is not related to TomEE but to Tomcat. It is a known issue that is explained here https://stackoverflow.com/a/41503819/5171182. And it is also known that a restart helps as it does in your case. However, the clean "no-restart-solution" explained by the answer is imho far more of an overkill than just creating the image right in the first place. Your choice! :) – Kekzpanda Feb 08 '21 at 12:17

0 Answers0