josefortyfive / BookStoreWebsite2

Simple Bookstore Website
0 stars 0 forks source link

Lec 144. Environment Error #78

Closed josefortyfive closed 3 months ago

josefortyfive commented 3 months ago

Issue with BookStoreWebsite2

Environment stopped working after a long break. Return with an error below.



Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.89
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          May 3 2024 20:22:11 UTC
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.89.0
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 11
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_21.0.3.v20240426-1530\jre
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           21.0.3+9-LTS
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Eclipse Adoptium
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\Edmar\Documents\Eclipse Workplace\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\apache-tomcat-9.0.89
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\Edmar\Documents\Eclipse Workplace\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\apache-tomcat-9.0.89
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\Edmar\Documents\Eclipse Workplace\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dstdout.encoding=UTF-8
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dstderr.encoding=UTF-8
Aug 15, 2024 4:06:22 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -XX:+ShowCodeDetailsInExceptionMessages
Aug 15, 2024 4:06:22 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded Apache Tomcat Native library [1.3.0] using APR version [1.7.4].
Aug 15, 2024 4:06:22 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
Aug 15, 2024 4:06:22 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
Aug 15, 2024 4:06:22 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized [OpenSSL 3.0.13 30 Jan 2024]
Aug 15, 2024 4:06:23 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Aug 15, 2024 4:06:23 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [511] milliseconds
Aug 15, 2024 4:06:23 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Aug 15, 2024 4:06:23 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.89]
Aug 15, 2024 4:06:24 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Aug 15, 2024 4:06:24 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: BookStoreWebsite2]
Aug 15, 2024 4:06:24 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 6.5.0.Final
Aug 15, 2024 4:06:24 PM org.hibernate.cache.internal.RegionFactoryInitiator initiateService
INFO: HHH000026: Second-level cache disabled
Aug 15, 2024 4:06:25 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/bookstoredb
Aug 15, 2024 4:06:25 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH10001001: Connection properties: {password=****, user=root}
Aug 15, 2024 4:06:25 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH10001003: Autocommit mode: false
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Aug 15, 2024 4:06:25 PM com.mchange.v2.log.MLog 
INFO: MLog clients using java 1.4+ standard logging.
Aug 15, 2024 4:06:25 PM com.mchange.v2.c3p0.C3P0Registry 
INFO: Initializing c3p0-0.9.5.5 [built 11-December-2019 22:18:33 -0800; debug? true; trace: 10]
Aug 15, 2024 4:06:25 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH10001007: JDBC isolation level: <unknown>
Aug 15, 2024 4:06:25 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource 
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@a32ba7e6 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@72d0c2b2 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, identityToken -> 1hgeeeeb5nlrzh7xg3sxa|13866865, idleConnectionTestPeriod -> 3000, initialPoolSize -> 5, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 120, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@3ca9c8d1 [ description -> null, driverClass -> null, factoryClassLocation -> null, forceUseNamedDriverClass -> false, identityToken -> 1hgeeeeb5nlrzh7xg3sxa|2ae88712, jdbcUrl -> jdbc:mysql://localhost:3306/bookstoredb, properties -> {password=******, user=******} ], preferredTestQuery -> null, privilegeSpawnedThreads -> false, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, extensions -> {}, factoryClassLocation -> null, identityToken -> 1hgeeeeb5nlrzh7xg3sxa|2570851e, numHelperThreads -> 3 ]
Aug 15, 2024 4:06:27 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter [com.bookstore.controller.frontend.CommonFilter]
java.lang.ExceptionInInitializerError
    at com.bookstore.controller.frontend.CommonFilter.<init>(CommonFilter.java:28)
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:224)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:97)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3856)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4474)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:878)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:735)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: BookStoreWebsite2] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1590)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1511)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:55)
    at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
    at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at com.bookstore.dao.JpaDAO.<clinit>(JpaDAO.java:18)
    ... 35 more
Caused by: org.hibernate.PropertyAccessException: Exception occurred inside: 'com.bookstore.entity.Book.bookId' (getter)
    at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:56)
    at org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:46)
    at org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl.<init>(BasicEntityIdentifierMappingImpl.java:119)
    at org.hibernate.persister.entity.AbstractEntityPersister.generateIdentifierMapping(AbstractEntityPersister.java:5577)
    at org.hibernate.persister.entity.AbstractEntityPersister.lambda$prepareMappingModel$16(AbstractEntityPersister.java:5216)
    at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.processSubPart(MappingModelCreationProcess.java:163)
    at org.hibernate.persister.entity.AbstractEntityPersister.prepareMappingModel(AbstractEntityPersister.java:5214)
    at org.hibernate.persister.entity.AbstractEntityPersister.prepareMappingModel(AbstractEntityPersister.java:5060)
    at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.execute(MappingModelCreationProcess.java:84)
    at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.process(MappingModelCreationProcess.java:42)
    at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:199)
    at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:371)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:300)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:457)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1506)
    ... 39 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because "this.bookId" is null
    at com.bookstore.entity.Book.getBookId(Book.java:101)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:48)
    ... 53 more

Aug 15, 2024 4:06:27 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more Filters failed to start. Full details will be found in the appropriate container log file
Aug 15, 2024 4:06:27 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/BookStoreWebsite2] startup failed due to previous errors
Aug 15, 2024 4:06:27 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
WARNING: The web application [BookStoreWebsite2] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Aug 15, 2024 4:06:27 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [BookStoreWebsite2] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base/jdk.internal.misc.Unsafe.park(Native Method)
 java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269)
 java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1847)
 java.base/java.lang.ref.ReferenceQueue.await(ReferenceQueue.java:71)
 java.base/java.lang.ref.ReferenceQueue.remove0(ReferenceQueue.java:143)
 java.base/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:218)
 com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:91)
 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
 java.base/java.lang.Thread.run(Thread.java:1583)
Aug 15, 2024 4:06:27 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Aug 15, 2024 4:06:27 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [4610] milliseconds
Aug 15, 2024 4:06:30 PM org.apache.catalina.loader.WebappClassLoaderBase checkStateForResourceLoading
INFO: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1328)
    at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:960)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:123)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:90)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Performed the following troubleshooting

Key note of the possible issue

Was using eclipse 2022 then upgrade to eclipse 2024. But, after I upgraded the IDE I was still able to run the Project.

josefortyfive commented 3 months ago

Issue has been resolved.

Main issue is in Book.java

The bookId was declared as Integer.

But, the getter setter is int.

Changed from


public int getBookId() {
    return this.bookId;
}

public void setBookId(int bookId) {
    this.bookId = bookId;
}

To


public Integer getBookId() {
    return this.bookId;
}

public void setBookId(Integer bookId) {
    this.bookId = bookId;
}