How to enable Weblogic 12.1.2 JPA 2.1 - java

I have been deploying our web application to Weblogic server. However, although I was able to deploy the application successfully in this new version, the app does not start up and users cannot login. The log is:
May 29, 2015 4:38:47 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
I believe this happens because Weblogic enables JPA 2.0 by default (but I am not sure of it). Is there a way to enable JPA 2.1?
PS: We are using hibernate 4.3.8 and I am not an expert on application servers.
Regards.

If you can upgrade to 12.1.3 then JPA 2.1 support is included but disabled by default, you can follow their instructions for enabling it. It amounts to putting the right jars on the classpath which you can do by adding this to the top of common/bin/commEnv.sh
PRE_CLASSPATH=$MW_HOME/oracle_common/modules/javax.persistence_2.1.jar:$MW_HOME/wlserver/modules/com.oracle.weblogic.jpa21support_1.0.0.0_2-1.jar
export PRE_CLASSPATH

Related

Application not deploying on Tomcat server

I am trying to run an application on tomcat server. The application was earlier running on Jboss EAP. All the configuration changes have been made in the tomcat context.xml and other application related configuration files like web.xml, etc. The only ERROR and SEVERE logs that I see when the application is being deployed are mentioned below:
[main] ERROR org.springframework.web.context.ContextLoader - Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'redisCacheManager' defined in class path
resource [config/serviceContext.xml]: Instantiation of bean failed;
nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.tcs.cdm.cache.CacheManager]: Constructor threw
exception; nested exception is java.lang.Error: Unresolved compilation
problems: The type redis.clients.jedis.JedisPoolConfig cannot be
resolved. It is indirectly referenced from required .class files
. . .
SEVERE: Exception sending context initialized event to listener
instance of class
[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'redisCacheManager' defined in class path
resource [config/serviceContext.xml]: Instantiation of bean failed;
nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.tcs.cdm.cache.CacheManager]: Constructor threw
exception; nested exception is java.lang.Error: Unresolved compilation
problems: The type redis.clients.jedis.JedisPoolConfig cannot be
resolved. It is indirectly referenced from required .class files
. . .
SEVERE: One or more listeners failed to start. Full details will be
found in the appropriate container log file
org.apache.catalina.core.StandardContext startInternal SEVERE: Context
[/AppName] startup failed due to previous errors
I have gone through several threads but did not find any solution working for me. I have tried making version changes to jsf related jars in my pom.xml but that also doesn't help. I am currently using tomcat version 9.0.36 but have also tried TomEE 8.0.8 for the same but facing the same issue in both the cases. It would be great if someone could guide as to why this error is coming or a possible solution for the same.

Websphere with Oracle DB deployment Error NosuchMethod

I am trying to deploy war file on websphere 8.5.5.13. which is connected to oracle(11g) db and even i had created data sources connection on websphere.
The application is getting installed but when i try to start the application gives me the following error:
[29/10/18 15:00:49:733 IST] 000001e1 SystemErr R Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index; (loaded from file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader#180c62e2) called from class org.hibernate.cfg.annotations.EntityBinder (loaded from file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/DefaultAppServer/installedApps/AntivirusServerNode01Cell/cream_war.ear/cream.war/WEB-INF/lib/hibernate-core-5.0.12.Final.jar by
[29/10/18 15:00:49:733 IST] 000001e1 SystemErr R Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index; (loaded from file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader#180c62e2) called from class org.hibernate.cfg.annotations.EntityBinder (loaded from file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/DefaultAppServer/installedApps/AntivirusServerNode01Cell/cream_war.ear/cream.war/WEB-INF/lib/hibernate-core-5.0.12.Final.jar by
I also tried changing the version of hibernate and jpa but that too didnt work.
But when i deploy application without using oracle db (using h2 or derby) it runs properly.
Please help me out with this error.
Not able to find the path
The NoSuchMethodError indicates that Hibernate is trying to call a method on javax.persistence.Table that doesn't exist. The Table class has been loaded from file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar so it's WAS itself that's providing the incompatible class.
By default, WAS 8.5.5 uses JPA 2.0 but it is possible to use JPA 2.1 by following the steps described here. You've already done most of the steps described in "Embedding a third-party persistence provider within an application". The one remaining step is to configure your application's class loader order so that it will prefer classes bundled with your application to those provided by the application server.

Deploying Grails 3 App to Tomcat 8 on Elastic Beanstalk

I'm trying to deploy a Grails 3 app to a Tomcat 8 instance on Elastic Beanstalk and I've tried a few things that I've found on Google and Stack Exchange including changing the "org.springframework.boot:spring-boot-starter-tomcat" dependency from "compile" to "provided," which didn't work. Elastic Beanstalk will accept the war file, but then just shows a blank page.
I opened up the war file that Grails produced and saw that there's no index.jsp file in the base directory or web.xml file under WEB-INF. Both of those exists in a simple war file I made using a Maven web-app archetype, which works, so I have two questions:
1) Has anyone else deployed an app from the latest version of Grails to Tomcat 8? Especially on Elastic Beanstalk and especially recently? Most of the answers I've found from Googling are old, so I'm thinking maybe something has changed with a new version.
2) What's the best reference to see the process Tomcat 8 goes through when opening a WAR file and loading it? I think if I could dig deeper into this process, I could figure out where the missing pieces are.
#John Stanford , I found same problem my grails version is 3.2.3
I have tested deploy to my tomcat8 on local , and found my data-source configuration cause this problem , my grails app is just dummy app , no need database connection ,
the log /var/lib/tomcat8/logs/catalina.2017-xx-xx.log show as below
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsCacheFilter': Cannot create inner bean '(inner bean)#7cbf54fc' of type [grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter] while setting bean property 'filter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#7cbf54fc': Unsatisfied dependency expressed through method 'setUrlMappingsHandlerMapping' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'urlMappingsHandlerMapping': Unsatisfied dependency expressed through method 'setWebRequestInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openSessionInViewInterceptor': Cannot resolve reference to bean 'hibernateDatastore' while setting bean property 'hibernateDatastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
so I comment out the production.dataSource.url of application.yml
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
grails:
serverURL: http://xxx-evn-yyy-zzzz-aws-zone-2.elasticbeanstalk.com
dataSource:
dbCreate: none
#url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
and finally deploy to AWS Beanstalk and it works !

EJB Container initialization error : Error while binding JNDI name

I'm trying to deploy an Enterprise Web Application that i have created using Java Language. When i deploy the project i'm getting this error from Glassfish Server Log. I'm using a Stateless Remote Session Bean named "MiuUsertableFacade" that interacts with the Class Library.
Severe: Exception while loading the app
Info: file:/C:/Users/miura/Documents/NetBeansProjects/RioGamesOnlinePortalApplication/dist/gfdeploy/RioGamesOnlinePortalApplication/RioGamesOnlinePortal_jar/_RioGamesOnlinePortalPU logout successful
Severe: Exception while loading the app : EJB Container initialization error
java.lang.RuntimeException: Error while binding JNDI name miuusertablefacade#com.riogames.Entity.MiuUsertableFacadeRemote for EJB MiuUsertableFacade
.......
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameAlreadyBoundException: Use rebind to override

HTTP Status 503 on Sun Java System Application Server 9.1_02 (build b04-fcs)

We are replicating our Production application to our DR machine. Our application is a web app using Hibernate Spring and Struts2 framework running on a Sun Java System Application Server 9.1_02 (build b04-fcs). The application is stable on the production environment. Also made it to run during our first replications. Recently we encountered an HTTP Status 503.
We tried everything from redeployment to application server (servlet container) restart. We even tried rebuilding the application from source code and redeploying it just to resolve the http status 503. What could be causing this HTTP status 503?
Thanks in advance guys.
here are my dependencies/jar files
antlr-2.7.6.jar
arpeggio-1.1.jar
cglib-2.2.jar
commons-collections-3.1.jar
commons-dbcp-1.2.2.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
commons-pool-1.4.jar
dom4j-1.6.1.jar
freemarker-2.3.16.jar
ganymed-ssh2-build210.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate3.jar
javassist-3.12.0.GA.jar
jettison-1.3.2.jar
jta-1.1.jar
ldap.jar
log4j-1.2.14.jar
mime-util-2.1.3.jar
ognl-3.0.1.jar
oracle10g.jar
org.springframework.asm-3.0.6.RELEASE.jar
org.springframework.beans-3.0.6.RELEASE.jar
org.springframework.context-3.0.6.RELEASE.jar
org.springframework.core-3.0.6.RELEASE.jar
org.springframework.expression-3.0.6.RELEASE.jar
org.springframework.jdbc-3.0.6.RELEASE.jar
org.springframework.orm-3.0.6.RELEASE.jar
org.springframework.transaction-3.0.6.RELEASE.jar
org.springframework.web-3.0.6.RELEASE.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
struts2-core-2.2.3.1.jar
struts2-json-plugin-2.2.3.1.jar
struts2-spring-plugin-2.2.3.1.jar
xwork-core-2.2.3.1.jar
Here is the application server logs
Log Entry Detail
Timestamp
Apr 25, 2013 17:03:12.981
Log Level
SEVERE
Logger
org.apache.catalina.core.StandardContext
Name-Value Pairs
_ThreadID=14;_ThreadName=pool-1-thread-7;_RequestID=d73c920a-2b6a-4f42-b523-93503d089b74;
Record Number
302
Message ID
PWC1306
Complete Message
Startup of context /myproject failed due to previous errors
Log Entry Detail
Timestamp
Apr 25, 2013 17:03:12.980
Log Level
SEVERE
Logger
javax.enterprise.system.container.web
Name-Value Pairs
_ThreadID=14;_ThreadName=pool-1-thread-7;_RequestID=d73c920a-2b6a-4f42-b523-93503d089b74;
Record Number
301
Message ID
WebModule[/myproject]PWC1275
Complete Message
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myprojectSessionFactory' defined in class path resource [hibernate-config/myproject-hibernate-spring.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4523) at org.apache.catalina.core.StandardContext.start(StandardContext.java:5184) at com.sun.enterprise.web.WebModule.start(WebModule.java:326) at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:58) at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:304) at com.sun.appserv.management.util.misc.RunnableBase.run(RunnableBase.java:341) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:284) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:678) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:703) at java.lang.Thread.run(Thread.java:811) Caused by: java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1912) at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707) at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035) at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 24 more
Here's the big clue:
Caused by: java.lang.NoSuchMethodError:
javax/persistence/OneToMany.orphanRemoval()Z
It is saying that some code needs to call a method with signature boolean orphanRemoval() on the javax.persistence.OneToMany API ... but the version of the API that has just been loaded does not provide that methods.
In other words, you have a version mismatch between some of the JARs in the WAR file.
I don't think this is a mismatch between the hibernate and hibernate-jpa files because the JBoss Hibernate 3.x release zips have files with those names.
Instead, I think it is a mismatch between Hibernate and Spring. In particular, the Spring manual says:
Note: As of Spring 3.0, Spring requires Hibernate 3.2 or later.
It is not clear what version of Hibernate 3 you are using, but my theory is that it is too old for Spring 3.0.x.

Categories