ClasscastException on update application - java

I have an openjpa application running in a weblogic 12.1.2 container.
When i first install the application everything works fine. If i update the ear file (or redeploy) i get the following error:
- Could not log the error: EJB Exception: found this error: EJB Exception: : <openjpa-1.1.1-SNAPSHOT-r422266:1445923 nonfatal general error> org.apache.openj
pa.persistence.PersistenceException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:199)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:152)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.newPersistenceContext(TransactionalEntityManagerProxyImpl.java:71)
at weblogic.persistence.BasePersistenceContextProxyImpl.getPersistenceContext(BasePersistenceContextProxyImpl.java:175)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:106)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:82)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:92)
at com.sun.proxy.$Proxy235.createNativeQuery(Unknown Source)
(...)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
at org.apache.openjpa.lib.xml.XMLFactory.getDOMParser(XMLFactory.java:107)
at org.apache.openjpa.jdbc.sql.SQLErrorCodeReader.parse(SQLErrorCodeReader.java:108)
at org.apache.openjpa.jdbc.sql.DBDictionary.endConfiguration(DBDictionary.java:4096)
at org.apache.openjpa.jdbc.sql.OracleDictionary.endConfiguration(OracleDictionary.java:170)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)
This is only fixed by restarting the cluster nodes. This doesn't happen in Weblogic 10.3.
I've been looking around and i stumbled across several possible solutions to no avail. One of the possible issues can be seen here: Stackoverflow Question
From here I started fiddling with the ear and i now have the xercesImpl lib ( the same that exists on the server) inside my APP-INF/lib this. Without this the application won't even install.
I've tried adding the following line to my weblogic-application.xml:
<wls:package-name>org.apache.xerces.*</wls:package-name>
And this had no effect.
Also looked into the possibility that my EntityManager was being left open upon undeploy, but i have no reason to believe this is the case. All my EntityManager are container managed and injected using the #EJB annotation.
Anyone have any ideas on this?

Related

java.lang.IllegalStateException: Session/EntityManager is closed only in uber-jar

I have an incredibly confusing error. I have several quarkus microservices, one of which runs a long process in a new thread where a database connection is also required (injected EntityManager). This used to cause an issue with the persistence context getting lost in the new thread, resulting in similar exceptions. We solved this by using a ManagedExecutor to run this new thread while conserving the persistence context. This works perfectly fine in development wie normal JARs or running the quarkus server with:
mvn quarkus:dev
However, for production we need to build a standalone uber-jar, which we do by building it with maven:
mvn package "-Dquarkus.package.type=uber-jar" "-DskipTests"
This works for all our quarkus services, and also generates one for this particular service. The server for it starts perfectly fine with the uber-jar, e.g. java -jar app-prod.jar, but when the beforementioned code with the new thread is executed, we suddenly get old familiar exceptions again:
java.lang.IllegalStateException: Session/EntityManager is closed
at org.hibernate.internal.AbstractSharedSessionContract.checkOpen(AbstractSharedSessionContract.java:407)
at org.hibernate.query.internal.AbstractProducedQuery.setHint(AbstractProducedQuery.java:1081)
at org.hibernate.query.internal.NativeQueryImpl.setHint(NativeQueryImpl.java:869)
at org.hibernate.query.internal.NativeQueryImpl.setHint(NativeQueryImpl.java:66)
at org.hibernate.internal.SessionImpl.applyQuerySettingsAndHints(SessionImpl.java:341)
at org.hibernate.internal.AbstractSharedSessionContract.getNativeQueryImplementor(AbstractSharedSessionContract.java:1143)
at org.hibernate.internal.AbstractSharedSessionContract.createNativeQuery(AbstractSharedSessionContract.java:1043)
at org.hibernate.internal.AbstractSharedSessionContract.createNativeQuery(AbstractSharedSessionContract.java:114)
at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createNativeQuery(TransactionScopedSession.java:413)
at org.hibernate.engine.spi.SessionLazyDelegator.createNativeQuery(SessionLazyDelegator.java:626)
at org.hibernate.engine.spi.SessionLazyDelegator.createNativeQuery(SessionLazyDelegator.java:65)
at org.hibernate.Session_5b93bee577ae2f8d76647de04cfab36afbf52958_Synthetic_ClientProxy.createNativeQuery(Unknown Source)
at com.test.webscraper.entity.repository.SourceTermRepository.getTotalAmountOfSourceTerms(SourceTermRepository.java:39)
at com.test.webscraper.entity.repository.SourceTermRepository_ClientProxy.getTotalAmountOfSourceTerms(Unknown Source)
at com.test.webscraper.bots.base.repository.TermRepositoryProxy.getTotalAmountOfSourceTerms(TermRepositoryProxy.java:92)
at com.test.webscraper.bots.base.repository.TermRepositoryProxy_ClientProxy.getTotalAmountOfSourceTerms(Unknown Source)
at com.test.webscraper.bots.base.JobRunner.initTermRepositoryProxyFor(JobRunner.java:99)
at com.test.webscraper.bots.base.JobRunner.tryToRunJob(JobRunner.java:82)
at com.test.webscraper.bots.base.JobRunner.runJob(JobRunner.java:70)
at com.test.webscraper.bots.base.JobRunner_ClientProxy.runJob(Unknown Source)
at com.test.webscraper.bots.base.async.JobRunnerThreadExecutor.lambda$executeJobRunFor$0(JobRunnerThreadExecutor.java:38)
at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
We have no idea why this is happening (again) in the uber-jar version only. Can anyone clue me in on why this might possibly happen? Does something happen when a project gets packaged as an uber-jar particularly that may interfere with this?

How to solve the "Unable to update binding" error in SONAR LINT?

Scenario :
Recently I have installed SONAR lint v3.4 on Eclipse Oxygen.2 Release (4.7.2
I have SONAR qube server running and I was successfully able to connect SONAR lint to it.
Problem :
However after the connection when I try to take updates from the SONARQUBE server.
Eclipse throws the following error :
Failed to update binding for 1 project,
Unable to update binding for
project 'xyz-project'
Unable to move
C:\Users\vsinghal\eclipse-workspace\.sonarlint\work{SONARQUBE server
domain}\.sonartmp_7415526389500015248\8960528228988360636
to
C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage{SONARQUBE
server domain}\modules\xyz-project
I checked the error log, following is the trace in eclipse :
java.lang.IllegalStateException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:47)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.replaceDir(FileUtils.java:153)
at org.sonarsource.sonarlint.core.container.connected.update.perform.ModuleStorageUpdateExecutor.update(ModuleStorageUpdateExecutor.java:63)
at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.updateModule(ConnectedContainer.java:118)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.updateModule(ConnectedSonarLintEngineImpl.java:260)
at org.sonarlint.eclipse.core.internal.server.Server.updateProjectStorage(Server.java:338)
at org.sonarlint.eclipse.core.internal.jobs.ServerUpdateJob.run(ServerUpdateJob.java:66)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.nio.file.AccessDeniedException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileCopy.move(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)
at java.nio.file.Files.move(Unknown Source)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDirPreferAtomic(FileUtils.java:53)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:45)
... 7 more
What did I do try and solve it ?
I gave complete permissions/full control to Everyone for the
eclipse workspace folder in windows explorer .
I tried opening eclipse as admin
I have checked the SONAR server is accessible
but after all these steps the error still doesn't go.
Can anyone help me in finding a solution to this ?
I'm currently experiencing the same issue using SolarLint in both eclipse and Intellij.
There is a reasonable suggestion on google groups, https://groups.google.com/forum/#!topic/sonarlint/nQW1kJBjUYg which suggests that the cause could by a virus scanner interfering in the process. However thus far despite following that theory, I'm still experiencing the issue. Something to try though.

Migration from WebSphere to WebLogic

I have an webapplication running on WebSphere using JDK 1.6, Spring 2.5.6 and iceFaces 1.8.2. I need to migrate that webapp to WebLogic. So I updated JDK to 1.8 and Spring to 4.2. The iceFaces framework I dont change because of the number of change on my source code.
When I deploy the application I got the following:
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.lifecycle.ClientWindowFactory' was not configured properly.
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:330)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:705)
Truncated. see log file for complete stacktrace
Caused By: javax.faces.FacesException: com.sun.faces.lifecycle.ClientWindowFactoryImpl
at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:409)
at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:253)
at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:549)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
Truncated. see log file for complete stacktrace
Caused By: java.lang.UnsupportedOperationException
at javax.faces.application.Application.subscribeToEvent(Application.java:1797)
at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Truncated. see log file for complete stacktrace
Are there some way to resolve that or I need to change my iceFaces version?
I think i resolved that including jsf 1.2 libs on my war file.
Still getting another errors, soon I update the answer if it worked or not.
UPDATE:
Yes, this solved my problem... Now webapplication is deployed sucessful. (Still getting httpError 500 when open my login page...)

Eclipse doesn't initialize JPA persistence

when I try to run a JPA project, I get the following error message :
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.<clinit>(EntityManagerFactoryProvider.java:55)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:92)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at dao.LayerDAO.<init>(LayerDAO.java:10)
at exec.Run.main(Run.java:9)
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.platform.server.NoServerPlatformDetector.checkPlatform(NoServerPlatformDetector.java:28)
at org.eclipse.persistence.platform.server.ServerPlatformUtils.detectServerPlatform(ServerPlatformUtils.java:58)
at org.eclipse.persistence.internal.jpa.IsolatedHashMap.<clinit>(IsolatedHashMap.java:48)
... 7 more
This project was running before, but I needed to reinstall Glassfish because of problems and now it's broken.
I tried to create a new project but I got the same error messages.
Do you have an idea of what could explain such a behavior ?
Thanx
Thanx to #Gimby who made me verified my EclipseLink version, I had to go into the project properties.
After a look in the BuildPath parameters, I tried to look at the "targeted runtime" I've chosen and found that none was selected.
Since I've checked it, everything goes better.
++

ClassLoader classcastexception with activemq client

I have been struggling with this problem for a while now, decided to ask the community, hoping to get some hints/answers.
I am using tomcat 7.0.54 as my J2EE container which has a WAR deployed with dependency on activemq-all.
Along with the above, I'm also placing a jar in the classpath to register a listener programmatically, by implementing the ServletContainerInitializer interface. This initializes a simple implementation of an active mq client, JvmMessageProducerImpl (I have activemq-client as a dependency in the pom).
With the above setup, when i try to start tomcat, i get the below exception. It seems that instead of loading the classes independently, the listener which is called when the web application starts, is finding an existing instance of TcpTransportFactory and throwing the ClassCastException. I have read the classloader manual for tomcat multiple times, and my understanding is that each of the war files should have independent Class loaders - but dont completely understand why the exception is being thrown?
javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Transport scheme NOT recognized: [tcp]
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:317)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:330)
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:251)
at com.monitoreverywhere.jvmmon.mq.JvmMessageProducerImpl.setup(JvmMessageProducerImpl.java:66)
at com.monitoreverywhere.jvmmon.mq.JvmMessageProducerImpl$Runner.run(JvmMessageProducerImpl.java:163)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.IOException: Transport scheme NOT recognized: [tcp]
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
at org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:181)
at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:63)
at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:315)
... 5 more
Caused by: java.lang.ClassCastException: org.apache.activemq.transport.tcp.TcpTransportFactory cannot be cast to org.apache.activemq.transport.TransportFactory
at org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:178)
... 7 more

Categories