Spring : Java heap space outOfMemory on bean creation's exception - java

I'm migrating my Spring dependencies injections, from XML declaration into the annotation style.
But now that I've migrated DAO, Services and Controllers, the server won't launch anymore :
java.lang.OutOfMemoryError: Java heap space
I can see in the stacktrace (see below) there is a BeanCreationException, but i can't know which one because the OutOfMemory exception occurs on BeanCreationException's message construction.
I already tried to increase -Xmx and -XX:MaxPermSize JVM's argument, but i believe it's like an infinite loop or something like that. The application worked perfectly before the migration to annotation.
Do you have any idea how to know where the problem come from ?
Versions : Hibernate 3.1, Spring 2.5, Tomcat 7, JDK 7
Typical applicationContext.xml content (before) :
<bean id="fooDAO" class="foo.bar.fooDAO">
<property name="sessionFactory">
<ref bean="foo_factory" /> //extends LocalSessionFactoryBean
</property>
</bean>
<bean id="fooService" class="foo.bar.fooService">
<property name="foodDAO" ref="fooDAO" />
</bean>
<bean id="fooControler" class="foo.bar.fooControler" autowire="byName">
<property name="fooService" ref="fooService" />
</bean>
After migration :
#Repository on DAO, #Service on services and #Controller on controllers.
StackTrace :
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1239)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2367)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

Related

JDBC Connection Pool Payara 5 with JDK 17

I am testing payara 5 with jdk 17.
But I have problems with the connection pool.
<jdbc-connection-pool max-pool-size="100" datasource-classname="oracle.jdbc.pool.OracleDataSource" steady-pool-size="1" validation-table-name="dual" name="oracle_thin_emp" is-connection-validation-required="true" res-type="javax.sql.DataSource">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="URL" value="jdbc:oracle:thin:#192.168.50.19:1521:TD"></property>
<property name="serverName" value="192.168.50.19"></property>
<property name="User" value="EMP"></property>
<property name="Password" value="EMP"></property>
<property name="PortNumber" value="1521"></property>
<property name="databaseName" value="TD"></property>
</jdbc-connection-pool>
When I start payara 5 with jdk 8 the connection pool works correctly but when I start the web server with jdk 17 and ping from the admin console I get the following error:
Ping Connection Pool failed for oracle_thin_emp. Class name is wrong or classpath is not set for : oracle.jdbc.pool.OracleDataSource Please check the server.log for more details.
Log:
[Payara 5.2022.2] [SEVERE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.util] [tid: _ThreadID=163 _ThreadName=admin-thread-pool::admin-listener(4)] [timeMillis: 1657657513953] [levelValue: 1000] [[
RAR5099 : Wrong class name or classpath for Datasource Object
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at com.sun.enterprise.loader.CurrentBeforeParentClassLoader.loadClass(CurrentBeforeParentClassLoader.java:83)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
Details:
JDK: oracle jdk-17.0.3.1
Server: payara 5.2022.2
Driver: payara5\glassfish\domains\domain1\lib\ext\ojdbc7-12.1.0.2.jar
Place the driver in one directory above, <payara-home>/glassfish/domains/<domain>/lib.
The reason seems to be that the extension mechanism (system property java.ext.dirs) has been removed from Java 9.
Also, the PayaraServer5.192 Release Notes states that <payara-home>/glassfish/domains/<domain>/lib/ext are no longer placed in the classpath.
PayaraServer officially supports Java 11 in addition to Java 8 since 5.192, but it seems to be a corresponding response.

OpenEJBException in apache tomee 7.0.3

I am using apache tomee 7.0.3 as server container and using OpenJPA. While starting the server getting below excption. Please anybody can help me.
Exception :
WARNING: File error: <Deployments dir="apps/"> - Does not exist: C:\Work\EclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5\apps
Sep 20, 2017 5:34:33 PM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.deployments.classpath=false'
Sep 20, 2017 5:34:33 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating TransactionManager(id=Default Transaction Manager)
Sep 20, 2017 5:34:33 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating SecurityService(id=Tomcat Security Service)
Sep 20, 2017 5:34:33 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=My DataSource)
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.
Sep 20, 2017 5:34:38 PM sun.reflect.NativeMethodAccessorImpl invoke
SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/tds2-admin-service]] in state [STARTING_PREP]
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:854)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1627)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1607)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:763)
at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:2227)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:1038)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:718)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1298)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1124)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5087)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Sep 20, 2017 5:34:38 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/tds2-admin-service]
org.apache.openejb.OpenEJBException: Creating application failed: C:\Work\EclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5\wtpwebapps\ca-acs-tds2-admin-service: org.apache.openejb.OpenEJBRuntimeException: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:1042)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:718)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1298)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1124)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5087)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openejb.OpenEJBException: org.apache.openejb.OpenEJBRuntimeException: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:873)
... 13 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.
at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:136)
at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:105)
at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:157)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:867)
... 13 more
Caused by: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: There was an error when invoking the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory". See the nested exception for details.
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:73)
at org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:149)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:191)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:63)
at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:109)
at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:134)
... 16 more
Caused by: java.lang.IllegalStateException: On a thread without an initialized context nor a classloader mapping a deployed app
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:287)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.getContext(ThreadSingletonServiceImpl.java:263)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:298)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:60)
at org.apache.webbeans.config.WebBeansFinder.getSingletonInstance(WebBeansFinder.java:51)
at org.apache.webbeans.config.WebBeansContext.getInstance(WebBeansContext.java:185)
at org.apache.webbeans.config.WebBeansContext.currentInstance(WebBeansContext.java:203)
at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable$BmHandler.findBm(EntityManagerFactoryCallable.java:170)
at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable$BmHandler.invoke(EntityManagerFactoryCallable.java:158)
at com.sun.proxy.$Proxy79.toString(Unknown Source)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractMap.toString(AbstractMap.java:559)
at java.text.MessageFormat.subformat(MessageFormat.java:1280)
at java.text.MessageFormat.format(MessageFormat.java:865)
at java.text.Format.format(Format.java:157)
at java.text.MessageFormat.format(MessageFormat.java:841)
at org.apache.openjpa.lib.util.Localizer$Message.getMessage(Localizer.java:282)
at org.apache.openjpa.lib.util.Localizer$Message.toString(Localizer.java:309)
at org.apache.openejb.openjpa.JULOpenJPALog.record(JULOpenJPALog.java:130)
at org.apache.openejb.openjpa.JULOpenJPALog.trace(JULOpenJPALog.java:72)
at org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto(PersistenceProductDerivation.java:764)
at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(JDBCBrokerFactory.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:66)
... 21 more
This problem happens when you start the server from Eclipse and deploy the application from Eclipse.
Take these steps to fix the problem:
From Eclipse Undeploy all projects from TomEE
Double click server to open its properties.
Select Use Tomcat installation

Can't bind Hibernate session factory into java:app in WildFly 8.2.1

I am attempting to register a Hibernate Session Factory from a persistence unit in a applications deployed to WildFly 8.2.1 and I am encountering a warning exception from the Hibernate 4 code (listed below). And when I look at JNDI in the WildFly console, the session factories are definitely not registered. I would like them to be in the "java:app" scope so that I can avoid naming collisions when more that one application might have the same session factory name.
Registering an entity manager to this scope works fine.
If I leave the "java:app" prefix off the session factory name it bind just fine into JNDI, but at a global scope. I understand that I can impose some sort of name-spacing, but I was hoping I would not have to.
Any input would be appreciated. Thank you.
Details below...
The persistence unit
<persistence-unit name="myPU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:/jdbc/MyDS</jta-data-source>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<mapping-file>MySchema.hbm.xml</mapping-file>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:app/em/MY_EM" />
<property name="hibernate.session_factory_name" value="java:app/sessions/my_FACTORY"/>
<property name="hibernate.query.imports" value="com.my.model" />
<property name="hibernate.current_session_context_class" value="thread" />
<property name="hibernate.use_outer_join" value="true" />
<property name="hibernate.jdbc.use_streams_for_binary" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
</properties>
</persistence-unit>
Exception snippet
16:14:50,044 WARN [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 64) - HHH000277: Could not bind factory to JNDI: org.hibernate.engine.jndi.JndiException: Error creating intermediate context [java:app]
Caused by: javax.naming.NameNotFoundException: java:app
Full Warning exception from Hibernate
16:14:50,044 WARN [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 64) - HHH000277: Could not bind factory to JNDI: org.hibernate.engine.jndi.JndiException: Error creating intermediate context [java:app]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:205) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:159) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:103) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:497) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_51]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-security-manager-1.0.0.Final.jar:1.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.naming.NameNotFoundException: java:app
at org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:187) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.naming.InitialContext$DefaultInitialContext.createSubcontext(InitialContext.java:294) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:398) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at javax.naming.InitialContext.createSubcontext(InitialContext.java:489) [rt.jar:1.8.0_51]
at javax.naming.InitialContext.createSubcontext(InitialContext.java:489) [rt.jar:1.8.0_51]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:202) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
... 18 more
I may have found the answer...
Although it is not exactly the answer I wanted. But, it makes sense. The reason that Hibernate's JNDI binding robots cannot find the java:app subcontext is because, I think, it is attempting to find that name at the root and it does not exist there. JBoss/WildFly on the other have seems to have some implicit context when deploying the application and actually as the java:app existing under the applications/<module-name> inside the JNDI tree. Hibernate doesn't know anything about this structure.
I've modified my implementation is organize these session factory bindings by application name at the root of the JNDI tree like this:
hib > myApp > sessions > MY_SESSION_FACTORY
I hope this helps someone else out.

Issues with Hibernate and C3p0 pool

I'm testing web application with hibernate 4.3.0 and c3p0 pool and sometimes after reloading context I get this error:
INFO: Reloading Context with name [/AppName] is completed
янв 07, 2015 12:07:14 AM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at com.mchange.v2.resourcepool.BasicResourcePool.checkIdleResources(BasicResourcePool.java:1584)
at com.mchange.v2.resourcepool.BasicResourcePool.access$2000(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$CheckIdleResourcesTask.run(BasicResourcePool.java:2116)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1hge136961hmilhm17ylc97|17d425e]-AdminTaskTimer" java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$AsyncTestIdleResourceTask
at com.mchange.v2.resourcepool.BasicResourcePool.checkIdleResources(BasicResourcePool.java:1584)
at com.mchange.v2.resourcepool.BasicResourcePool.access$2000(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$CheckIdleResourcesTask.run(BasicResourcePool.java:2116)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
... 5 more
dependencies - maybe hibernate-c3p0 dependecie is enougth?
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.0.Final</version>
</dependency>
hibernate settings
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">3000</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
What is the reason for that error and hot to fix it?
All dependecies related to hibernate-c3p0 are in the classpath.
Please refer to the links I added as comments. During re-deployment classes are unloaded, if you fail to close Hibernate's sessionFactory then you get these ClassNotFound errors. One of the answer suggest that you can add a custom ServletContextListener to handle the contextDestroyed event.

How Do I use Jasypt with springs autowire?

I have see some solutions for this without the autowire but I am trying to get it to work with with the auto wire. I have been trying this since last week but found no solutions that worked in my case, it may be that I am not implementing it correctly so any help would be great.
I have a properties file myprops.properties:
Wsdl=someurl
UserName=admin
UserPassword=ENC(encriptedpassword)
and in my servlet.xml file I replaced
<context:property-placeholder location="classpath*:myprops.properties" />
with
<bean id="propertyPlaceholderConfigurer"
class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="location" value="classpath:myprops.properties" />
</bean>
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
<bean id="environmentVariablesConfiguration"
class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
</bean>
and in my service.java I am auto wiring these values like this:
#Autowired
public void setUserPassword(#Value("${UserPassword}") String userPassword) {
this.userPassword = userPassword;
}
#Autowired
public void setUserName(#Value("${UserName}") String userName) {
this.userName = userName;
}
#Autowired
public void setWsdl(#Value("${Wsdl}") String wsdl) {
this.wsdl = wsdl;
}
Thing is this works when I don't have the password encripted i.e. UserPassword=nonencriptedpassword
but as soon as I encripted it and use ENC() I get the following error
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
Truncated. see log file for complete stacktrace
This may be down something stupidly simple that I am unaware of or have over looked but I have tried following tutorials on the Jasypt wiki and site as well as tutorials xmx1024 and on jayway and I'm sure I had found one using the autowired but I can't seem to find it again.
FYI: I am using spring 3.0.4, Spring Security 3.0.4 and jasypt 1.9
any help would be Awesome
Update
I have set an Enviorment Variable APP_ENCRYPTION_PASSWORD equal to the plain text password and set the password in the properties file as the returned value of
encrypt input=plaintextpassword password=APP_ENCRYPTION_PASSWORD
I now get the Error
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.jasypt.exceptions.EncryptionOperationNotPossibleException.
org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
<11-Mar-2013 16:33:54 o'clock GMT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1363019632631' for task '0'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
<11-Mar-2013 16:33:54 o'clock GMT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application 'adminUI_EA'.>
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'adminUI_EA'.>
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: :org.jasypt.exceptions.EncryptionOperationNotPossibleException:null
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
Password encription was done in the following way
C:\Users\jonnie\Desktop\jasypt-1.9.0\bin>encrypt input=****** password=APP_ENCRYPTION_PASSWORD
----ENVIRONMENT-----------------
Runtime: Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM 20.12-b01
----ARGUMENTS-------------------
input: *******
password: APP_ENCRYPTION_PASSWORD
----OUTPUT----------------------
****encriptedPassword****
This blog post has a nice example of using #Value on a bean that is build using #Service. The test uses #Autowire to set up the #Service bean.
Set the below variable
Eclipse - go to run config and under environment tab set below new variable key/value
APP_ENCRYPTION_PASSWORD=MyKey
If running on UNIX - export APP_ENCRYPTION_PASSWORD=MyKey
Create the beans like below =>
classpath:/app1.properties
classpath:/app2.properties

Categories