Adding TransactionSynchronizationRegistry in weblogic-ejb-jar.xml - ejb-3.0

I'm trying to use 'TransactionSynchronizationRegistry' via EJB injection in a session bean. However during deployment on a weblogic App Server i got the error that 'TransactionSynchronizationRegistry' is not properly defined in weblogic-ejb-jar.xml. I tried to do that but with no success so far. I tried doing the following:
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar">
<weblogic-enterprise-bean>
<ejb-name>asdas</ejb-name>
<resource-description>
<res-ref-name>TransactionSynchronizationRegistry</res-ref-name>
<jndi-name>java:comp/env/TransactionSynchronizationRegistry</jndi-name>
</resource-description>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

I managed to make this work. I was doing the injection as such:
#Resource
TransactionSynchronizationRegistry trx;
so instead of modifying weblogic-ejb-jar.xml, i modified the injection to become as such:
#Resource (mappedName = "java:comp/TransactionSynchronizationRegistry")
TransactionSynchronizationRegistry trx;
It worked!

Related

Could not resolve placeholder 'XXX' in string value "${XXX}"

In my spring boot example, I'd like to read environment variables from my local machine(Win 7).
#Data
#Component
public class EnvironmentVariableSystemProperties {
#Value("${java.home}")
private String javaHome;
#Value("${DATASTORE.DATASET}")
private String datastoreDataset;
#Value("${SPRINGA}")
private String springConfigName;
}
It works well when reading java.home and DATASTORE.DATASET which have been added in my OS environment variables before.
I just added a new variable SPRINGA. When running spring boot example, I got the error:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'SPRINGA' in string value "${SPRINGA}".
Should I restart up my machine to make the variable work?
I just restarted Eclipse, but it didn't work.
Restarting Eclipse with the Restart in the Menu doesn't work.
Exiting Eclipse and Running it again works.
How weird it is!

How to get the host name in spring configuration file?

Is there any easy way to get the host name in spring configuration file ? Currently I am using Java code to get the host name and and auto wire the property in the bean . But looking for less coding approach if any !
Thanks
The following will give you the hostname in java
return InetAddress.getLocalHost().getHostName();
where InetAddress belongs to the java.net package. You can add that to your java configuration file. If you want to do it in xml, you can do the following
<bean id="localhostInetAddress"
class="java.net.InetAddress"
factory-method="getLocalHost"/>
<bean id="hostname"
factory-bean="localhostInetAddress"
factory-method="getHostName"/>

Deploy JMS Query using Arquillian

I'm using arquilian to test a JMS query. I've seen that i'm able to deploy a descriptor using the Descriptors class, like below:
#Deployment
public static Descriptor create() {
return Descriptors.create(HornetQDescriptor.class);
}
Ok, but I can't find the HornetQDescriptor class anywhere! I'm using Arquillian 1.1.7.Final, with ShrinkWrap Desriptors 2.0.0-Alpha-7 and Maven. Any help?
Ok, I think I found a trick...
I added a hornetq-jms.xml to src/test/resources and to my arquillian jar and it worked fine. It was something like that:
#Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addAsManifestResource("hornetq-jms.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
and one default hornetq xml:
<messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0">
<hornetq-server>
<jms-destinations>
<jms-queue name="myQueue">
<entry name="/queue/myQueue"/>
</jms-queue>
</jms-destinations>
</hornetq-server>
</messaging-deployment>
And it worked fine. Not the way I expected doing, but it worked anyway =)
What kind of server u used , embedded or managed .
I am tryin to use hornetq-jms.xml but the embedded server I use is throwing exception about the xmlns="urn:jboss:messaging-deployment:1.0" .
About the HornetQDescriptor there are examples from 2011's versio of the descriptor api : Check this git hub location
As far the Api is changed for example : Descriptor Api
org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-javaee » 2.0.0-alpha-9
The api is totally changed so the code above is not usable am afraid .
So can u give me more details what server u used and if it is embedded how u suceed to deploy the hornet - jms . xml

fsresource - runmode config stored in crx via xml

i'm using the fsresource sling extension to access the filesystem when working on JSP, JS, CSS and so on. When just yanking the bundle into the crx and configuring it via the OSGi console, everything works as expected. But when i try to add a new runmode (configurtion), the result is unsatisfying.
config/src/main/content/jcr_root/apps/samples/config/org.apache.sling.fsprovider.internal.FsResourceProvider.factory.config.xml
Is the path of the main configuration, which i'm using on a local instance to figure out, how to achieve the desired results, but the best i could get was an unbound configuration displayed in the
system/console/configMgr
The contents of the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
provider.roots="/apps/ui-samples"
provider.file="/Volumes/samples/ui/src/main/content/jcr_root/apps/ui-samples"
provider.checkinterval="1000"/>
Apparently, the i just thought too complicated about the name of the file.
org.apache.sling.fsprovider.internal.FsResourceProvider-samples.xml
for instance does the job.

OSGi bundle as external webservice client

I need to call an external webservice from my bundle which is deployed in apache felix container ( I can not use ServiceMix, fuse...)
I added the bundle cxf-dosgi (which can be downloaded from here) and put the following lines in my pom.xml:
<Require-Bundle>cxf-dosgi-ri-singlebundle-distribution</Require-Bundle>
<Import-Package>
javax.jws,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.ws,
META-INF.cxf,
org.apache.cxf,
org.apache.cxf.binding,
org.apache.cxf.binding.soap,
org.apache.cxf.binding.soap.spring,
org.apache.cxf.bus,
org.apache.cxf.bus.resource,
org.apache.cxf.bus.spring,
org.apache.cxf.buslifecycle,
org.apache.cxf.catalog,
org.apache.cxf.configuration,
org.apache.cxf.configuration.spring,
org.apache.cxf.endpoint,
org.apache.cxf.headers,
org.apache.cxf.management,
org.apache.cxf.phase,
org.apache.cxf.resource,
org.apache.cxf.transport,
org.apache.cxf.transport.http,
org.apache.cxf.transport.http.policy,
org.apache.cxf.transport.http_jetty,
org.apache.cxf.transports.http,
org.apache.cxf.workqueue,
org.apache.cxf.ws.policy.builder.jaxb,
org.apache.cxf.wsdl,
org.apache.cxf.wsdl11,
org.apache.cxf.jaxws.*,
*
</Import-Package>
I use the jaxws way to establish the communication:
QName SERVICE_NAME = new QName("http://test.com/", "MockImplService");
Service service = Service.create(new URL(endpointAddress + "?wsdl"), SERVICE_NAME);
mockService= service.getPort(IMock.class);
When I run the example I have the following exception:
Caused by: javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.axis2.jaxws.spi.Provider not found
at javax.xml.ws.spi.FactoryFinder$2.run(FactoryFinder.java:138)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:125)
at javax.xml.ws.spi.FactoryFinder.access$200(FactoryFinder.java:42)
at javax.xml.ws.spi.FactoryFinder$3.run(FactoryFinder.java:273)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:168)
at javax.xml.ws.spi.Provider.provider(Provider.java:39)
at javax.xml.ws.Service.<init>(Service.java:36)
at javax.xml.ws.Service.create(Service.java:116)
any idea please ?
Apache DOSGi is designed for exposing services as webservices, not for calling other webservices. Though, it probably contains some api to call other webservices.
Somehow the axis jaxws implementation is used. You probably have a axis2-jaxws-xxx.jar on your classpath. Try to remove it. The JRA jaxws will be used instead (which should be fine for axis and better for cxf).

Resources