IBMStockTrader / portfolio

Microservice implemented with MicroProfile that persists stock portfolios to JDBC (such as DB2)
Apache License 2.0
7 stars 60 forks source link

Database Concurrent Update Error #54

Open CC9759 opened 1 year ago

CC9759 commented 1 year ago

Recreating the Error

  1. Make a new portfolio
  2. Buy Stock with the portfolio
  3. Swap the stock and number of stocks to buy
  4. Click submit and get 500 error
  5. Return to previous page
  6. Buy stock correctly

When the steps above are recreated, the error message below generates. I'm currently unsure of what this would affect

Portfolio's log:

Launching defaultServer (Open Liberty 22.0.0.12/wlp-1.0.71.cl221220221107-1900) on Eclipse OpenJ9 VM, version 17.0.5+8 (en_US)
[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT   ] CWWKG0028A: Processing included configuration resource: /opt/ol/wlp/usr/servers/defaultServer/includes/postgres.xml
[INFO    ] CWWKE0002I: The kernel started after 6.603 seconds
[INFO    ] CWWKF0007I: Feature update started.
[INFO    ] CWWKS0007I: The security service is starting...
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
[INFO    ] DYNA1001I: WebSphere Dynamic Cache instance named baseCache initialized successfully.
[INFO    ] DYNA1071I: The cache provider default is being used.
[INFO    ] DYNA1056I: Dynamic Cache (object cache) initialized successfully.
[INFO    ] CWWKS5780I: The MicroProfile JWT version 1.2 mpConfigProxy processed successfully.
[INFO    ] CWWKS4103I: Creating the LTPA keys. This may take a few seconds.
[INFO    ] CWWKS1123I: The collective authentication plugin with class name NullCollectiveAuthenticationPlugin has been activated. 
[INFO    ] CWPKI0830I: Certificate with the CN=IBM Cloud Databases SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWPKI0830I: Certificate with the CN=Amazon RDS Root 2019 CA,OU=Amazon RDS,O=Amazon Web Services\, Inc.,ST=Washington,L=Seattle,C=US SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWPKI0830I: Certificate with the CN=Amazon RDS us-east-1 2019 CA,OU=Amazon RDS,O=Amazon Web Services\, Inc.,L=Seattle,ST=Washington,C=US SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWPKI0830I: Certificate with the L=Seattle,CN=Amazon RDS us-east-1 Root CA RSA2048 G1,ST=WA,OU=Amazon RDS,O=Amazon Web Services\, Inc.,C=US SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWPKI0830I: Certificate with the L=Seattle,CN=Amazon RDS us-east-1 Root CA RSA4096 G1,ST=WA,OU=Amazon RDS,O=Amazon Web Services\, Inc.,C=US SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWPKI0830I: Certificate with the L=Seattle,CN=Amazon RDS us-east-1 Root CA ECC384 G1,ST=WA,OU=Amazon RDS,O=Amazon Web Services\, Inc.,C=US SubjectDN from the cert_defaultTrustStore environment variable is being added to the defaultTrustStore keystore.
[INFO    ] CWWKS1655I: The default Java Authentication SPI for Containers (JASPIC) AuthConfigFactory class com.ibm.ws.security.jaspi.ProviderRegistry is being used because the Java security property authconfigprovider.factory is not set. 
[INFO    ] Successfully loaded default keystore: /opt/ol/wlp/usr/servers/defaultServer/resources/security/key.p12 of type: pkcs12
[AUDIT   ] CWWKS4104A: LTPA keys created in 3.198 seconds. LTPA key file: /opt/ol/wlp/output/defaultServer/resources/security/ltpa.keys
[INFO    ] CWWKS4105I: LTPA configuration is ready after 3.324 seconds.
[INFO    ] CWWKS6012I: The JSON Web Token (JWT) consumer service is available.
[INFO    ] CWWKS6002I: The JSON Web Token (JWT) endpoint service is available.
[INFO    ] CWWKS5500I: The MicroProfile JWT configuration [MicroProfileJwtService] was successfully processed.
[INFO    ] CWWKS5500I: The MicroProfile JWT configuration [defaultMpJwt] was successfully processed.
[INFO    ] CWWKS5500I: The MicroProfile JWT configuration [stockTraderJWT] was successfully processed.
[INFO    ] SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.
[INFO    ] CWPMI2003I: Monitoring metrics can be retrieved through mpMetrics.
[INFO    ] SRVE0169I: Loading Web Module: health.
[INFO    ] SRVE0250I: Web Module health has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/health/
[INFO    ] SRVE0169I: Loading Web Module: ibm/api.
[INFO    ] SRVE0250I: Web Module ibm/api has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/ibm/api/
[INFO    ] SRVE0169I: Loading Web Module: IBMJMXConnectorREST.
[INFO    ] SRVE0250I: Web Module IBMJMXConnectorREST has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/IBMJMXConnectorREST/
[INFO    ] CWWKX0103I: The JMX REST connector is running and is available at the following service URL: service:jmx:rest://cjot-portfolio-864555bc-7hdzq:9443/IBMJMXConnectorREST
[INFO    ] CWWKX0103I: The JMX REST connector is running and is available at the following service URL: service:jmx:rest://cjot-portfolio-864555bc-7hdzq:9443/IBMJMXConnectorREST
[INFO    ] SRVE0169I: Loading Web Module: PublicMicroProfileMetrics.
[INFO    ] SRVE0250I: Web Module PublicMicroProfileMetrics has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/metrics/
[INFO    ] SRVE0169I: Loading Web Module: OpenAPIUI.
[INFO    ] SRVE0250I: Web Module OpenAPIUI has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/openapi/ui/
[INFO    ] SRVE0169I: Loading Web Module: com.ibm.ws.security.jwt.
[INFO    ] SRVE0250I: Web Module com.ibm.ws.security.jwt has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/jwt/
[INFO    ] CWWKZ0018I: Starting application Portfolio.
[INFO    ] CWWKZ0136I: The Portfolio application is using the archive file at the /opt/ol/wlp/usr/servers/defaultServer/apps/Portfolio.war location.
[INFO    ] SRVE0169I: Loading Web Module: /openapi/platform.
[INFO    ] SRVE0250I: Web Module /openapi/platform has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/openapi/platform/
[INFO    ] SRVE0169I: Loading Web Module: MicroProfileOpenAPI.
[INFO    ] SRVE0250I: Web Module MicroProfileOpenAPI has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/openapi/
[INFO    ] SESN0176I: A new session context will be created for application key default_host/ibm/api
[INFO    ] SESN0176I: A new session context will be created for application key default_host/health
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] DYNA1056I: Dynamic Cache (object cache) initialized successfully.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.health.3.1.internal] [/health] [HealthCheckReadinessServlet]: Initialization successful.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.health.3.1.internal] [/health] [HealthCheckServlet]: Initialization successful.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.health.3.1.internal] [/health] [HealthCheckStartupServlet]: Initialization successful.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.health.3.1.internal] [/health] [HealthCheckLivenessServlet]: Initialization successful.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/IBMJMXConnectorREST
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SRVE0242I: [com.ibm.ws.jmx.connector.server.rest] [/IBMJMXConnectorREST] [JMXRESTProxyServlet]: Initialization successful.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/metrics
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.metrics.internal.public] [/metrics] [PublicMetricsRESTProxyServlet]: Initialization successful.
[INFO    ] SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at /opt/ol/wlp/output/defaultServer/logs/state/plugin-cfg.xml.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/openapi/ui
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/openapi/platform
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/jwt
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/openapi
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SRVE0242I: [io.openliberty.microprofile.openapi.2.0.internal] [/openapi] [ApplicationServlet]: Initialization successful.
[INFO    ] J2CA8050I: An authentication alias should be used instead of defining a user name and password on dataSource[PortfolioDB].
[INFO    ] CWRLS0010I: Performing recovery processing for local WebSphere server (defaultServer).
[INFO    ] CWRLS0007I: No existing recovery log files found in /opt/ol/wlp/output/defaultServer/tranlog/tranlog. Cold starting the recovery log.
[INFO    ] CWRLS0006I: Creating new recovery log file /opt/ol/wlp/output/defaultServer/tranlog/tranlog/log1.
[INFO    ] CWRLS0006I: Creating new recovery log file /opt/ol/wlp/output/defaultServer/tranlog/tranlog/log2.
[INFO    ] CWRLS0007I: No existing recovery log files found in /opt/ol/wlp/output/defaultServer/tranlog/partnerlog. Cold starting the recovery log.
[INFO    ] CWRLS0006I: Creating new recovery log file /opt/ol/wlp/output/defaultServer/tranlog/partnerlog/log1.
[INFO    ] CWRLS0006I: Creating new recovery log file /opt/ol/wlp/output/defaultServer/tranlog/partnerlog/log2.
[INFO    ] CWRLS0012I: All persistent services have been directed to perform recovery processing for this WebSphere server (defaultServer).
[INFO    ] WTRN0135I: Transaction service recovering no transactions.
[WARNING ] You have specified multiple ids for the entity class [com.ibm.hybrid.cloud.sample.stocktrader.portfolio.json.Stock] without specifying an @IdClass. By doing this you may lose the ability to find by identity, distributed cache support etc. Note: You may however use EntityManager find operations by passing a list of primary key fields. Else, you will have to use JPQL queries to read your entities. For other id options see @PrimaryKey.
[INFO    ] CWWKO1660I: The application Portfolio was processed and an OpenAPI document was produced.
[INFO    ] WELD-000900: 3.1.9 (Final)
[INFO    ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host *  (IPv6) port 9080.
[INFO    ] CWWKO0219I: TCP Channel defaultHttpEndpoint-ssl has been started and is now listening for requests on host *  (IPv6) port 9443.
[AUDIT   ] CWWKF0012I: The server installed the following features: [json-1.0, jwt-1.0, microProfile-4.1, monitor-1.0, mpConfig-2.0, mpFaultTolerance-3.0, mpHealth-3.1, mpJwt-1.2, mpMetrics-3.0, mpOpenAPI-2.0, mpOpenTracing-2.0, mpRestClient-2.0, opentracing-2.0, restConnector-2.0].
[AUDIT   ] CWWKF0013I: The server removed the following features: [appClientSupport-1.0, batch-1.0, beanValidation-2.0, concurrent-1.0, ejb-3.2, ejbHome-3.2, ejbLite-3.2, ejbPersistentTimer-3.2, ejbRemote-3.2, j2eeManagement-1.1, jacc-1.5, jaspic-1.1, javaMail-1.6, javaee-8.0, jaxb-2.2, jaxws-2.2, jca-1.7, jcaInboundSecurity-1.0, jms-2.0, jsf-2.3, jsp-2.3, managedBeans-1.0, mdb-3.2, wasJmsClient-2.0, wasJmsSecurity-1.0, wasJmsServer-1.0, webProfile-8.0, websocket-1.1].
[INFO    ] CWWKF0008I: Feature update completed in 49.792 seconds.
[AUDIT   ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 56.313 seconds.
[AUDIT   ] CWWKZ0022W: Application Portfolio has not started in 30.318 seconds.
[INFO    ] Publishing to Trade History topic enabled: false
[INFO    ] Cash Account microservice enabled: false
[INFO    ] Using Stock Quote URL from config map: http://cjot-stock-quote-service:9080/stock-quote
[INFO    ] CWWKW0750I: The following interfaces are configured as RequestScoped which will result in slower performance:  Consider using ApplicationScoped for better performance.
[INFO    ] SRVE0169I: Loading Web Module: Portfolio.
[INFO    ] SRVE0250I: Web Module Portfolio has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://cjot-portfolio-864555bc-7hdzq:9080/portfolio/
[INFO    ] SESN0176I: A new session context will be created for application key default_host/portfolio
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[AUDIT   ] CWWKZ0001I: Application Portfolio started in 31.589 seconds.
[INFO    ] CWWKS9123I:  For URL /* in application Portfolio, the following HTTP methods are uncovered, and not accessible: HEAD OPTIONS TRACE 
[INFO    ] SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at /opt/ol/wlp/output/defaultServer/logs/state/plugin-cfg.xml.
[INFO    ] Setting the server's publish address to be /
[INFO    ] SRVE0242I: [Portfolio] [/portfolio] [com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService]: Initialization successful.
[err] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[err] SLF4J: Defaulting to no-operation (NOP) logger implementation
[err] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO    ] CWMOT1001I: A JaegerTracer instance was created for the Portfolio application.  Tracing information is sent to localhost:6831.
[INFO    ] EclipseLink, version: Eclipse Persistence Services - 2.7.11.v20220804-52dea2a3c0
[INFO    ] DSRA8203I: Database product name : PostgreSQL
[INFO    ] DSRA8204I: Database product version : 12.12
[INFO    ] DSRA8205I: JDBC driver name  : PostgreSQL JDBC Driver
[INFO    ] DSRA8206I: JDBC driver version  : 42.5.3
[WARNING ] 

Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "stock_pkey"
  Detail: Key (owner, symbol)=(Testing, KD) already exists.
Error Code: 0
Call: INSERT INTO STOCK (SYMBOL, COMMISSION, dateQuoted, PRICE, SHARES, TOTAL, owner) VALUES (?, ?, ?, ?, ?, ?, ?)
    bind => [7 parameters bound]
Query: InsertObjectQuery({"symbol": "KD", "shares": 10, "commission": 0.0, "price": 0.0, "total": 0.0, "date": "null"})
[WARNING ] Failure refreshing portfolio for Testing
[WARNING ] javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.11.v20220804-52dea2a3c0): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "stock_pkey"
  Detail: Key (owner, symbol)=(Testing, KD) already exists.
Error Code: 0
Call: INSERT INTO STOCK (SYMBOL, COMMISSION, dateQuoted, PRICE, SHARES, TOTAL, owner) VALUES (?, ?, ?, ?, ?, ?, ?)
    bind => [7 parameters bound]
Query: InsertObjectQuery({"symbol": "KD", "shares": 10, "commission": 0.0, "price": 0.0, "total": 0.0, "date": "null"})
[INFO    ] javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.11.v20220804-52dea2a3c0): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "stock_pkey"
  Detail: Key (owner, symbol)=(Testing, KD) already exists.
Error Code: 0
Call: INSERT INTO STOCK (SYMBOL, COMMISSION, dateQuoted, PRICE, SHARES, TOTAL, owner) VALUES (?, ?, ?, ?, ?, ?, ?)
    bind => [7 parameters bound]
Query: InsertObjectQuery({"symbol": "KD", "shares": 10, "commission": 0.0, "price": 0.0, "total": 0.0, "date": "null"})
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:980)
    at org.eclipse.persistence.internal.jpa.QueryImpl.performPreQueryFlush(QueryImpl.java:978)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:211)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:482)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.dao.StockDao.readStockByOwner(StockDao.java:56)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.dao.StockDao$Proxy$_$$_WeldClientProxy.readStockByOwner(Unknown Source)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService.getPortfolio(PortfolioService.java:255)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService$Proxy$_$$_WeldSubclass.getPortfolio(Unknown Source)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService.updatePortfolio(PortfolioService.java:420)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService$Proxy$_$$_WeldSubclass.updatePortfolio$$super(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:51)
    at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:78)
    at com.ibm.tx.jta.cdi.interceptors.TransactionalInterceptor$1.run(TransactionalInterceptor.java:137)
    at com.ibm.ws.uow.embeddable.EmbeddableUOWManagerImpl.runUnderCurrentUOW(EmbeddableUOWManagerImpl.java:1077)
    at com.ibm.ws.uow.embeddable.EmbeddableUOWManagerImpl.runUnderNewUOW(EmbeddableUOWManagerImpl.java:1040)
    at com.ibm.ws.uow.embeddable.EmbeddableUOWManagerImpl.runUnderUOW(EmbeddableUOWManagerImpl.java:1013)
    at com.ibm.tx.jta.cdi.interceptors.TransactionalInterceptor.runUnderUOWManagingEnablement(TransactionalInterceptor.java:151)
    at com.ibm.tx.jta.cdi.interceptors.Required.required(Required.java:40)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService$Proxy$_$$_WeldSubclass.updatePortfolio(Unknown Source)
    at com.ibm.hybrid.cloud.sample.stocktrader.portfolio.PortfolioService$Proxy$_$$_WeldClientProxy.updatePortfolio(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.ibm.ws.jaxrs20.cdi.component.JaxRsFactoryImplicitBeanCDICustomizer.serviceInvoke(JaxRsFactoryImplicitBeanCDICustomizer.java:350)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsServerFactoryBean.performInvocation(LibertyJaxRsServerFactoryBean.java:641)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.performInvocation(LibertyJaxRsInvoker.java:160)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:101)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.invoke(LibertyJaxRsInvoker.java:273)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:213)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.invoke(LibertyJaxRsInvoker.java:444)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:112)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:277)
    at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:137)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:146)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.doPut(IBMRestServlet.java:136)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:96)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1258)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:746)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:193)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:98)
    at com.ibm.ws.security.jaspi.JaspiServletFilter.doFilter(JaspiServletFilter.java:56)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:1002)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1140)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1011)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:75)
    at com.ibm.ws.webcontainer40.servlet.CacheServletWrapper40.handleRequest(CacheServletWrapper40.java:85)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:938)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:281)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1246)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:468)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:427)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:567)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:501)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:361)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:328)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:167)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:75)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:514)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:584)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:968)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1057)
    at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:245)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:857)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.11.v20220804-52dea2a3c0): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "stock_pkey"
  Detail: Key (owner, symbol)=(Testing, KD) already exists.
Error Code: 0
Call: INSERT INTO STOCK (SYMBOL, COMMISSION, dateQuoted, PRICE, SHARES, TOTAL, owner) VALUES (?, ?, ?, ?, ?, ?, ?)
    bind => [7 parameters bound]
Query: InsertObjectQuery({"symbol": "KD", "shares": 10, "commission": 0.0, "price": 0.0, "total": 0.0, "date": "null"})
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:342)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1666)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:915)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:979)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:640)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:567)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2105)
    at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:313)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:275)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:261)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:428)
    at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:168)
    at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:183)
    at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:515)
    at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:85)
    at org.eclipse.persistence.queries.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:95)
    at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:327)
    at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:60)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
    at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:812)
    at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:110)
    at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:87)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3004)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1898)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1880)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1830)
    at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:229)
    at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:128)
    at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:4409)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1503)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1649)
    at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:457)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:975)
    ... 87 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "stock_pkey"
  Detail: Key (owner, symbol)=(Testing, KD) already exists.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
    at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.postgresql.ds.PGPooledConnection$StatementHandler.invoke(PGPooledConnection.java:441)
    at jdk.proxy31/jdk.proxy31.$Proxy128.executeUpdate(Unknown Source)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:520)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:907)
    ... 117 more