How to create an internal bridge to forward a queue to a topic - glassfish

I'm trying to set-up an internal bridge from a queue to a topic and I'm getting a "Lookup failed" exception.
Here's some more details:
Env: GlassFish 3.1.2.2 (fresh install) and embedded JMS host
Create queue connection pool (javax.jms.QueueConnectionFactory): pool1 (jndi and pool name)
Create topic connection pool (javax.jms.TopicConnectionFactory): pool2 (jndi and pool name)
Create queue: queue1 (jndi and queue name)
Create topic: queue1 (jndi and queue name)
The domain.xml is configured as follows:
<jms-service default-jms-host="default_JMS_host">
<jms-host host="localhost" name="default_JMS_host" lazy-init="false">
<property name="imq.bridge.enabled" value="true"></property>
<property name="imq.bridge.admin.user" value="admin"></property>
<property name="imq.bridge.admin.password" value="admin"></property>
<property name="imq.bridge.bridge1.type" value="jms"></property>
<property name="imq.bridge.activelist" value="bridge1"></property>
<property name="imq.bridge.bridge1.xmlurl" value="file:///c:/tmp/bridge.xml"></property>
</jms-host>
</jms-service>
And the bridge.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jmsbridge SYSTEM "sun_jmsbridge_1_0.dtd">
<jmsbridge name="bridge1">
<link name="link1">
<source connection-factory-ref="pool1" destination-ref="queue1">
</source>
<target connection-factory-ref="pool2" destination-ref="topic1">
</target>
</link>
<connection-factory ref-name="pool1" lookup-name="pool1"/>
<connection-factory ref-name="pool2" lookup-name="pool2" />
<destination ref-name="queue1" name="queue1" type="queue" lookup-name="queue1" />
<destination ref-name="topic1" name="topic1" type="topic" lookup-name="topic1" />
</jmsbridge>
EXCEPTION:
[01/Feb/2013:16:14:56 CAT] WARNING [B2217]: Failed to start bridge service manager:
javax.naming.NamingException: Lookup failed for 'pool1' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.
JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: pool1 not found]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at com.sun.messaging.bridge.service.jms.JMSBridge.createConnectionFactory(JMSBridge.java:513)
at com.sun.messaging.bridge.service.jms.JMSBridge.createLink(JMSBridge.java:333)
at com.sun.messaging.bridge.service.jms.JMSBridge.init(JMSBridge.java:227)
at com.sun.messaging.bridge.service.jms.BridgeImpl.start(BridgeImpl.java:125)
at com.sun.messaging.bridge.BridgeServiceManagerImpl.startBridge(BridgeServiceManagerImpl.java:447)
at com.sun.messaging.bridge.BridgeServiceManagerImpl.start(BridgeServiceManagerImpl.java:255)
at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:1548)
at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:456)
at com.sun.messaging.jmq.jmsserver.BrokerProcess.start(BrokerProcess.java:164)
at com.sun.messaging.jmq.jmsserver.DirectBrokerProcess.start(DirectBrokerProcess.java:92)
at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:206)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: javax.naming.NameNotFoundException: pool1 not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
The documentation is pretty good but I can't get around that issue...

Related

RabbitMQ set queue Parameters while connecting through camel

I am trying to connect to RabbitMQ queues present in the server using apache-camel configuration.
It works fine when I create the queues with durable field false and auto-delete field true. But doesn't work when either of them is otherwise.
applicationContext.xml file looks like this -
<bean id="customConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost" />
<property name="port" value="5672" />
<property name="username" value="guest" />
<property name="password" value="guest" />
<property name="virtualHost" value="Test" />
</bean>
<bean id="testBean" class="test.TestBean" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from
uri="rabbitmq://localhost:5672/ex1?connectionFactory=#customConnectionFactory&queue=Q1&autoDelete=true&durable=true" />
<to uri="bean:testBean?method=hello" /> <!-- This method consumes and prints the message -->
</route>
</camelContext>
Here I need to specify the properties autoDelete and durable for the queue Q1 not the exchange ex1. (I have already specified for the exchange in the URI)
As the error is -
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'auto_delete' for queue 'Q1' in vhost 'Test': received 'true' but current is 'false', class-id=50, method-id=10)
Here reply-code=406 indicates that the parameters of queues/exchanges are not matching with the actual configuration. Its because of the queues properties here.
As I don't have the access to the remote queues, I cannot change the properties of queues. (Example I stated here is localhost)
Note: I have a requirement of doing this using spring beans only.

Activemq Shutdown fails and then kills process

I am implementing replicated leveldb activemq setup. I have 3 instance of activemq running on same box. I am changing their rmiPort, amqpport and openwire port in config file.
config like lookslie this:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=" http://www.springframework.org /schema/beans" xmlns:amq=" http://activemq.apache.org/schema/core" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="activemq_8200" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry producerFlowControl="false" topic=">">
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
<policyEntry producerFlowControl="false" queue=">">
<deadLetterStrategy>
<!--
Use the prifix 'DLQ.' for the destination name, and make the DLQ a queue rather than a topic
-->
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true"/>
</deadLetterStrategy>
<!-- Use VM cursor for better latency
For more information, see:
http://activemq.apache.org/message-cursors.html
<pendingQueuePolicy>
<vmQueueCursor/>
</pendingQueuePolicy>
-->
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<persistenceAdapter>
<replicatedLevelDB bind="tcp://0.0.0.0:0" directory="${activemq.data}/leveldb" replicas="3" zkAddress="gwxdev05.northamerica.cerner.net:2181,gwxdev05.northamerica.cerner.net:2182,gwxdev05.northamerica.cerner.net:2183" zkPassword="password" zkPath="/opt/gwx/activemqdata"/>
</persistenceAdapter>
<systemUsage>
<systemUsage sendFailIfNoSpace="true">
<memoryUsage>
<memoryUsage limit="256 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="128 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:${openwirePort}?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:${amqpPort}?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook"/>
</shutdownHooks>
</broker>
<import resource="jetty.xml"/>
my instance file looks like this:
ACTIVEMQ_BASE=`cd "$ACTIVEMQ_BASE" && pwd`
## Add system properties for this instance here (if needed), e.g
#export ACTIVEMQ_OPTS_MEMORY="-Xms256M -Xmx1G"
#export ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY
-Dorg.apache.activemq.UseDedicatedTaskRunner=true
-Djava.util.logging.config.file=logging.properties"
export ACTIVEMQ_SUNJMX_CONTROL="-Dactivemq.jmx.url=service:jmx:rmi:///jndi/rmi://127.0.0.1:8100/jmxrmi"
#
ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=8100 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.authenticate=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
export ACTIVEMQ_SUNJMX_START=$ACTIVEMQ_SUNJMX_START
export ACTIVEMQ_HOME=/opt/gwx/apache-activemq-5.10-SNAPSHOT
export ACTIVEMQ_BASE=$ACTIVEMQ_BASE
export JAVA_HOME=/opt/gwx/apache-activemq-5.10-SNAPSHOT/jdk1.7.0_25
${ACTIVEMQ_HOME}/bin/activemq "$#"
Here is exception I get:
Connecting to pid: 2410
INFO: failed to resolve jmxUrl for pid:2410, using default JMX url Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason: java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused] java.lang.RuntimeException: Failed to execute stop task. Reason: java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused]
at
I checked firewall. It not issue.
Any idea what might be causing this issue.
Activemq version 5.10 snapshot
Java 1.7
OS linux 6.4
If it still helps someone:
When I had in bin/env this
export ACTIVEMQ_SUNJMX_CONTROL="-Dactivemq.jmx.url=service:jmx:rmi:///jndi/rmi://127.0.0.1:8100/jmxrmi"
#
ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=8100 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.authenticate=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
, it did not work, process failed even without logging.
I don't know why, but this method works(for AMQ 5.13): u add to xml this:
<managementContext>
<managementContext connectorPort="1099"/>
</managementContext>
and nothing like ACTIVEMQ_SUNJMX_START in env file

system-properties In standalone-full.xml

Jboss version: jboss-as-7.1.0.Final
can we add
<system-properties>
<property name="x" value="/opt/db/common"/>
</system-properties>
In standalone-full.xml?
I am getting below error:
20:54:35,726 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
20:54:35,884 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
20:54:35,942 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
20:54:36,575 INFO [org.jboss.as] JBAS015950: JBoss AS 7.1.0.Final "Thunder" stopped in 5ms
20:54:36,569 ERROR [org.jboss.as.controller] JBAS014601: Error booting the container: java.lang.RuntimeException: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:161) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_23]
Caused by: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:125) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:187) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:261) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[479,1]
Message: JBAS014789: Unexpected element '{urn:jboss:domain:1.1}system-properties' encountered
at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:85) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_1(StandaloneXml.java:350) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:126) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:100) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:117) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]
... 4 more
at [row,col]:[479,1] I am having below entry:
<system-properties>
<property name="x" value="/opt/db/common"/>
<property name="y" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0/files/config.xml"/>
<property name="z" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0"/>
<property name="m" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0/log"/>
<property name="n" value="Member1"/>
<property name="log4j.ignoreTCL" value="true"/>
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
IIRC it's been fixed upstream, but some versions require the <system-properties/> to be directly under the <extensions/> tag.
Try something like:
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.1">
<extensions>
...
</extensions>
<system-properties>
<property name="x" value="/opt/db/common"/>
<property name="y" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0/files/config.xml"/>
<property name="z" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0"/>
<property name="m" value="/opt/db/engine/work/q22222-161-1/engine/info/exye/2.0/log"/>
<property name="n" value="Member1"/>
<property name="log4j.ignoreTCL" value="true"/>
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
...
</server>

ActiveMQ as local JNDI tomcat ressource

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.

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.