ActiveMQ as local JNDI tomcat ressource - activemq

i'm trying to set up ActiveMQ as Tomcat ressource with local JNDI. But when i add the config-file to the
Broker URI "brokerConfig=xbean:activemq.xml" the broker isn't starting up without any error message.
it just keeps telling me:
Mrz 30, 2012 10:23:19 AM org.springframework.jms.listener.DefaultMessageListenerContainer refreshConnectionUntilSuccessful
Warnung: Could not refresh JMS Connection for destination 'FOO.QUEUE' - retrying in 5000 ms. Cause: Could not create Transport. Reason: java.io.IOException: Could not load xbean factory:java.lang.NoClassDefFoundError: Could not initialize class org.apache.activemq.xbean.XBeanBrokerFactory
I used the default config from http://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/conf/activemq.xml and is placed in the root of my src folder.
i'm using "activemq-all_5.4.3.jar"
My web.xml in "WebContent\META-INF"
<resource-ref>
<description>JMS Connection</description>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/FooQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
</resource-ref>
My applicationContext.xml in "WebContent\WEB-INF"
<jee:jndi-lookup id="fooQueue"
jndi-name="java:comp/env/jms/FooQueue"
cache="true"
resource-ref="true"
lookup-on-startup="true"
expected-type="org.apache.activemq.command.ActiveMQQueue"
proxy-interface="javax.jms.Queue" />
<bean id="singleConnectionFactory"
class="org.springframework.jms.connection.SingleConnectionFactory"
p:targetConnectionFactory-ref="connectionFactory"/>
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate"
p:connectionFactory-ref="singleConnectionFactory"
p:defaultDestination-ref="fooQueue"/>
<bean id="messageSenderService"
class="by2.server.JmsMessageSenderService"
p:jmsTemplate-ref="jmsTemplate" />
<bean id="jmsMessageDelegate"
class="by2.server.JmsMessageDelegate" />
<bean id="myMessageListener"
class="org.springframework.jms.listener.adapter.MessageListenerAdapter"
p:delegate-ref="jmsMessageDelegate"
p:defaultListenerMethod="handleMessage">
</bean>
<jms:listener-container
container-type="default"
connection-factory="singleConnectionFactory"
acknowledge="auto">
<jms:listener destination="FOO.QUEUE" ref="myMessageListener" />
</jms:listener-container>
My context.xml in "WebContent\META-INF"
<Context reloadable="true">
<Resource auth="Container" name="jms/ConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
brokerName="FooBroker" />
<Resource auth="Container" name="jms/FooQueue"
type="org.apache.activemq.command.ActiveMQQueue" description="JMS queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.QUEUE" />
</Context>

For me it looks like a classpath error.
Did you have the xbean-spring-x.x.jar in your class path?
If not copy this file also from activemq distribution and put it in your app server classpath.

Related

Configuring Consumer Cancellation in RabbitMQ

We are using an 2-Node active-active RabbitMQ cluster with mirrored queue. With the mirroring policy being :
"policies":[{"vhost":"/","name":"ha-all","pattern":"","apply->to":"all","definition":{"ha-mode":"all","ha-sync-mode":"automatic"},"priority":0}]
Versions : RabbitMQ 3.5.4, Erlang 17.4 , spring-amqp/spring-rabbit :1.4.5.RELEASE
Now,we are trying to achieve consumer cancellation,as mentioned in Highly Available Queues.
However,since we have not used channel,we can't use {{basicConsumer}} method as given in the above link.
How do I set,"x-cancel-on-ha-failover" to true in the configuration,itself?
With the beans xml being thus :
<rabbit:connection-factory id="connectionFactory"
addresses="localhost:5672"
username="guest"
password="guest"
channel-cache-size="5" />
<!-- CREATE THE JsonMessageConverter BEAN -->
<bean id="jsonMessageConverter" class="org.springframework.amqp.support.converter.JsonMessageConverter" />
<!-- Spring AMQP Template -->
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" retry-template="retryTemplate" message-converter="jsonMessageConverter" />
<!-- in case connection is broken then Retry based on the below policy -->
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="500" />
<property name="multiplier" value="2" />
<property name="maxInterval" value="30000" />
</bean>
</property>
</bean>
<rabbit:queue name="testQueue" durable="true">
<rabbit:queue-arguments>
<entry key="x-max-priority">
<value type="java.lang.Integer">10</value>
</entry>
</rabbit:queue-arguments>
</rabbit:queue>
<bean id="messsageConsumer" class="consumer.RabbitConsumer">
</bean>
<rabbit:listener-container
connection-factory="connectionFactory" concurrency="5" max-concurrency="5" message-converter="jsonMessageConverter">
<rabbit:listener queues="testQueue" ref="messsageConsumer" />
</rabbit:listener-container>
The <rabbit:listener-container> actually populates a SimpleMessageListenerContainer bean on background. And the last one supports public void setConsumerArguments(Map<String, Object> args) on the matter.
So, to fix your requirements you just need to build the raw SimpleMessageListenerContainer <bean> for your messsageConsumer.
Meanwhile you are fixing that for your application, I'd ask you for the JIRA regarding adding <consumer-arguments> component. And we may be able to address it with the current GA deadline.

How to connect to Jira with basic authentication required?

I`m trying to set BASIC Authentication on HTTP component (camel ver. 2.14.1).
I`m looking for a way to setup basic auth. Something like in CXF spring bean and http:authorization properties.
<bean id="myAuth" class="org.apache.camel.component.http.HttpConfiguration">
<property name="authMethod" value="Basic"/>
<property name="authUsername" value="${user}"/>
<property name="authPassword" value="${password}"/>
</bean>
<bean id="http" class="org.apache.camel.component.http.HttpComponent">
<property name="camelContext" ref="myContext"/>
<property name="httpConfiguration" ref="myAuth"/>
</bean>
and the route is:
<route>
<from uri="timer://projectTimer?repeatCount=1" />
<simple>http://10.47.2.203:8080/rest/api/2/project/TM</simple>
</setHeader>
<to uri="http://dontMatter" />
<process ref="main" />
</route>
I got an error:
Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [org.apache.camel.component.http.HttpOperationFailedException - HTTP operation failed invoking http://10.47.2.203:8080/rest/api/2/project/TM with statusCode: 404]
What is the correct configuration for http basic authentication?
Thanks for any advice.

error when running red5 application on windows

I made very sample application for red5
I set WEB-INF(red5-web.properties, red5-web.xml, web.xml)
when I runnig the red.bat I view in the debug this error code :
[INFO] [Launcher:/test] org.springframework.beans.factory.xml.XmlBeanDefi
nitionReader - Loading XML bean definitions from ServletContext resource [/WEB-I
NF/red5-web.xml]
Exception in thread "Launcher:/test" org.springframework.beans.factory.xm
l.XmlBeanDefinitionStoreException: Line 25 in XML document from ServletContext r
esource [/WEB-INF/red5-web.xml] is invalid; nested exception is org.xml.sax.SAXP
arseException; lineNumber: 25; columnNumber: 68; cvc-id.2: There are multiple oc
currences of ID value 'web.handler'
and my client can't connect to server :(
from your description its impossible to say exactly what you've done.
You might better start to use for example the existing demo application that ship with every release.
Sebastian
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/red5-web.properties" />
</bean>
<bean id="web.context" class="org.red5.server.Context"
autowire="byType" />
<bean id="web.scope" class="org.red5.server.WebScope"
init-method="register">
<property name="server" ref="red5.server" />
<property name="parent" ref="global.scope" />
<property name="context" ref="web.context" />
<property name="handler" ref="web.handler" />
<property name="contextPath" value="${webapp.contextPath}" />
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>
<bean id="web.handler" class="com.myapp.Application" />
</beans>
change the web.handler bean in your red5-web.xml file
<bean id="web.handler" class="com.myapp.Application"
singleton="true" autowire="byName" />
Check the other bean names also. The error you posted says same ID used for two or more beans.

URIs when using domain.xml at embedded glassfish

I'm embedding a Java EE 5 application using GlassFish 3.0.1. I already can deploy it (when using without specific configuration), but when trying to run server with the domain.xml (basically JAAS info), I get this error:
java.lang.IllegalArgumentException: URI is not absolute
My code is this (error points to the last line):
Server.Builder builder = new Server.Builder("ipc");
EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
File domainDir = new File( "domains/ipc-domain" );
File domainXML = new File( domainDir.getAbsoluteFile(), "config/domain.xml" );
efsb.instanceRoot( domainDir.getAbsoluteFile() );
efsb.configurationFile( domainXML.getAbsoluteFile() );
EmbeddedFileSystem efs = efsb.build();
builder.embeddedFileSystem(efs);
//Trying to set variable used at domain.xml (blind shot)
Properties props = new Properties();
props.setProperty( "com.sun.aas.instanceRoot" , domainDir.toURI().toString());
Server server = builder.build( props );
My domain.xml (specific part) have this:
<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" version="10.0">
<system-applications/>
<applications>
<application context-root="/IPC" location="${com.sun.aas.instanceRoot}/applications/IPC/" name="IPC" object-type="user">
<property name="keepSessions" value="false"></property>
<property name="defaultAppName" value="IPC"></property>
<module name="IPC">
<engine sniffer="ejb"></engine>
<engine sniffer="security"></engine>
<engine sniffer="jpa"></engine>
<engine sniffer="web"></engine>
</module>
</application>
</applications>
<resources>
<jdbc-connection-pool pool-resize-quantity="1" datasource-classname="org.apache.derby.jdbc.ClientDataSource" max-pool-size="2" res-type="javax.sql.DataSource" steady-pool-size="1" name="ipc-pool">
<property name="PortNumber" value="1527"></property>
<property name="ServerName" value="0.0.0.0"></property>
<property name="User" value="app"></property>
<property name="Password" value="root"></property>
<property name="DatabaseName" value="IPC"></property>
</jdbc-connection-pool>
<jdbc-resource pool-name="ipc-pool" jndi-name="jdbc/IPC"></jdbc-resource>
</resources>
I've already tried to change the parts related to the "${com.sun.aas.instanceRoot}" variable, but then I have small variations of the URI error. Any insight?

Cannot port WAR file from Tomcat to Glassfish. Error with RESOURCE_LOCAL versus JTA

I'm trying to take a WAR, which deploys and runs fine on Tomcat, and deploy it on Glassfish. The initial error message in Glassfish is:
com.sun.enterprise.deployment.backend.IASDeploymentException:
Deployment Error -- The
persistence-context-ref-name
[org.nhindirect.config.store.dao.impl.AnchorDaoImpl/entityManager]
in module
[C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\config-service]
resolves to a persistence unit called
[config-store] which is of type
RESOURCE_LOCAL. Only persistence units
with transaction type JTA can be used
as a container managed entity manager.
Please verify your application.
The WAR does not have a persistence.xml in its META-INF folder. However, there is a JAR under WEB-INF\lib that itself contains a persistence.xml. The following are its contents:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="config-store" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate" />
</properties>
</persistence-unit>
</persistence>
So here's my question: is it possible to run a WAR configured for RESOURCE_LOCAL on Glassfish, or must I reconfigure the WAR for JTA?
I've investigated the first option by making the following changes to the WAR's web.xml:
Changed version="2.5" to version="2.4"
Changed xmlns="http://java.sun.com/xml/ns/javaee"
to
xmlns="http://java.sun.com/xml/ns/j2ee"
Changed xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
to
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
After these changes, the WAR seemed to deploy successfully, however, I could not access its WSDL and the following error was found in the Glassfish log:
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
'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'
defined in ServletContext resource
[/WEB-INF/beans.xml]: Initialization
of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'entityManagerFactory' defined in
ServletContext resource
[/WEB-INF/beans.xml]: Invocation of
init method failed; nested exception
is java.lang.NoClassDefFoundError:
javassist/bytecode/ClassFile at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at
java.security.AccessController.doPrivileged(Native
Method) at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at
org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:596)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:365)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4655)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5364)
at
com.sun.enterprise.web.WebModule.start(WebModule.java:345)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:986)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:970)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:704)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1649)
at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1254)
at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:182)
at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:278)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:1005)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:992)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:470)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:182)
at
com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
at
com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:231)
at
com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298)
at
com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132)
at
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:609)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:653)
at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:773)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:390)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:373)
at
com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:477)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at
sun.reflect.GeneratedMethodAccessor13.invoke(Unknown
Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
at $Proxy1.invoke(Unknown Source) at
com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)
at
com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:170)
at
com.sun.enterprise.deployment.client.DeploymentClientUtils.startApplication(DeploymentClientUtils.java:159)
at
com.sun.enterprise.deployment.client.DeployAction.run(DeployAction.java:538)
at
java.lang.Thread.run(Thread.java:619)
Caused by:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'entityManagerFactory' defined in
ServletContext resource
[/WEB-INF/beans.xml]: Invocation of
init method failed; nested exception
is java.lang.NoClassDefFoundError:
javassist/bytecode/ClassFile at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at
java.security.AccessController.doPrivileged(Native
Method) at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
at
org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:270)
at
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:122)
at
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:78)
at
org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
at
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:97)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1326)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
... 56 more Caused by:
java.lang.NoClassDefFoundError:
javassist/bytecode/ClassFile at
org.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(AbstractJarVisitor.java:236)
at
org.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(AbstractJarVisitor.java:202)
at
org.hibernate.ejb.packaging.AbstractJarVisitor.addElement(AbstractJarVisitor.java:163)
at
org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:100)
at
org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:139)
at
org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:287)
at
org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:614)
at
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:360)
at
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
at
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 73 more
Part of the above error message complains about javassist. This seems strange because the following section is in the WAR's pom.xml
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
If helpful, here are the contents of the WAR's beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"
default-autowire="byName">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<context:annotation-config />
<context:component-scan base-package="org.nhindirect.config" />
<tx:annotation-driven transaction-manager="transactionManager" />
<jaxws:endpoint id="configurationService"
address="/ConfigurationService" >
<jaxws:implementor>
<bean id="configurationServiceImpl"
class="org.nhindirect.config.service.impl.ConfigurationServiceImpl">
<property name="domainSvc" ref="domainSvc"/>
<property name="addressSvc" ref="addressSvc"/>
<property name="anchorSvc" ref="anchorSvc"/>
<property name="certSvc" ref="certSvc"/>
<property name="settingSvc" ref="settingSvc"/>
<property name="DNSSvc" ref="dnsSvc"/>
</bean>
</jaxws:implementor>
</jaxws:endpoint>
<!-- <jaxws:endpoint id="addressService" implementor="org.nhindirect.config.service.ws.AddressServiceWS"
address="/AddressService" /> -->
<!-- Service Implementations -->
<bean id="domainSvc" class="org.nhindirect.config.service.impl.DomainServiceImpl">
<property name="dao" ref="domainDao"/>
</bean>
<bean id="addressSvc" class="org.nhindirect.config.service.impl.AddressServiceImpl">
<property name="dao" ref="addressDao"/>
</bean>
<bean id="anchorSvc" class="org.nhindirect.config.service.impl.AnchorServiceImpl">
<property name="dao" ref="anchorDao"/>
</bean>
<bean id="certSvc" class="org.nhindirect.config.service.impl.CertificateServiceImpl">
<property name="dao" ref="certificateDao"/>
</bean>
<bean id="settingSvc" class="org.nhindirect.config.service.impl.SettingServiceImpl">
<property name="dao" ref="settingDao"/>
</bean>
<bean id="dnsSvc" class="org.nhindirect.config.service.impl.DNSServiceImpl">
<property name="dao" ref="dnsDao"/>
</bean>
<!-- DAO's -->
<bean id="domainDao" class="org.nhindirect.config.store.dao.impl.DomainDaoImpl"/>
<bean id="addressDao" class="org.nhindirect.config.store.dao.impl.AddressDaoImpl"/>
<bean id="anchorDao" class="org.nhindirect.config.store.dao.impl.AnchorDaoImpl" />
<bean id="certificateDao" class="org.nhindirect.config.store.dao.impl.CertificateDaoImpl"/>
<bean id="settingDao" class="org.nhindirect.config.store.dao.impl.SettingDaoImpl"/>
<bean id="dnsDao" class="org.nhindirect.config.store.dao.impl.DNSDaoImpl"/>
<!-- Exception translation bean post processor -->
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- SWAP THIS JPA IMPLEMENTATION WITH THE APPROPROATE DB CONFIGURATION
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="config-store" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql:nhindconfig" />
<property name="username" value="nhind" />
<property name="password" value="nhind" />
</bean>
-->
<!-- EMBEDDED DERBY JPA CONFIGURATION FOR A WORKING OUT OF THE BOX CONFIGURATION WITH NO PREREQUISITES OF
SETTING UP AN EXTERNAL DATABASE. REMOVE THIS SECTION AND REPLACE WITH READ JPA CONFIGURATION (SEE
ABOVE SECTION) FOR PRODUCTION -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<!-- <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" /> -->
<property name="databasePlatform" value="org.hibernate.dialect.DerbyDialect" />
</bean>
</property>
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="config-store" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:nhindconfig;create=true" />
<property name="username" value="nhind" />
<property name="password" value="nhind" />
</bean>
<!-- END DERBY JPA CONFIGURATION -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" />
</beans>
Sorry if I've provided too much information. I'm new to JPA and wasn't sure what would and wouldn't be helpful to anyone.
Thank you in advance.
Somewhere in your code you're probably injecting an EntityManager using code that looks something like this:
#PersistanceContext // Requires JTA
EntityManager em;
In this situation, you're asking the container (Glassfish itself, to create and manage the EntityManager for you. Glassfish being clusterable, attempts to protect you from accidentally making a transaction across multiple servers that is not truly ACID, but requiring you to use a JTA-transaction (which is sharable between multiple clustered servers).
If you know for sure you are NEVER going to cluster your glassfish container for this application, you can safely keep using RESOURCE_LOCAL transactions, however, you cannot have Glassfish manage that EntityManager for you. You can have Glassfish manage an EntityManagerFactory though.
#PersistanceUnit // Does NOT require JTA
EntityManagerFactory factory;
This is safe to use for persistance units that are RESOURCE_LOCAL. You just need to request an EntityManager from the factory using factory.createEntityManager().
Now your EntityManager is application-managed, not container-managed. So Glassfish will assume that you will handle transaction isolation in a cluster.