In fact this is a continuation of
http://www.nabble.com/How-to-set-parameter-to-invoke-EJB-t1711935.html
My EJB Business interface is as follows:
----------------------------------------------------
public interface HelloWorldBI{
String sayHello(int num, String s) throws IOException;
}
My servicemix.xml is as follows:
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:eip="http://servicemix.apache.org/eip/1.0"
xmlns:http="http://servicemix.apache.org/http/1.0"
xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
xmlns:my="http://servicemix.apache.org/demo">
<sm:container id="jbi" useMBeanServer="true"
createMBeanServer="true" dumpStats="true" statsInterval="10">
<sm:activationSpecs>
<sm:activationSpec componentName="jsrEjbBC"
service="my:jsrEjbBC" endpoint="jsrEjbBC">
<sm:component>
<jsr181:component>
<jsr181:endpoints>
<jsr181:endpoint annotations="none"
service="my:jsrEjbEP" endpoint="jsrEjbEP">
<jsr181:pojo>
<bean
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="jndiName"
value="esb-statelessSession-TraderHome"/>
<property name="businessInterface"
value="examples.webservices.basic.statelessSession.HelloWorldBI"/>
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property
name="lookupHomeOnStartup">
<value>false</value>
</property>
</bean>
</jsr181:pojo>
</jsr181:endpoint>
</jsr181:endpoints>
</jsr181:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec componentName="proxyPojoBC"
service="my:proxyPojoBC" endpoint="proxyPojoBC">
<sm:component>
<jsr181:component>
<jsr181:endpoints>
<jsr181:endpoint pojoClass="ProxyPojoService"
annotations="none" service="my:proxyPojoService" endpoint="proxyPojoService"
serviceInterface="ProxyPojo"/>
</jsr181:endpoints>
</jsr181:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec componentName="ejbHttpBridge"
service="my:ejbHttpBridge">
<sm:component>
<bean xmlns="http://xbean.org/schemas/spring/1.0"
class="EjbHttpBridge" >
<constructor-arg ref="jbi"/>
<property name="name">
<value>1</value>
</property>
</bean>
</sm:component>
</sm:activationSpec>
<sm:activationSpec>
<sm:component>
<http:component>
<http:endpoints>
<http:endpoint service="my:ejbHttpBridge"
role="consumer"
defaultOperation="echo"
locationURI="http://localhost:8192/Service/"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
soap="true"/>
</http:endpoints>
</http:component>
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<!-- bean
Other code goes here
</bean -->
</beans>
My EjbHttpBridge.java is as follows:
------------------------------------------------
public class EjbHttpBridge extends TransformComponentSupport implements
MessageExchangeListener{
private JBIContainer container;
private HelloWorldBI helloWorldBIProxy;
public EjbHttpBridge(JBIContainer container){
log("EjbHttpBridge.EjbHttpBridge(JBIContainer)...");
this.container = container;
}
protected boolean transform(MessageExchange exchange, NormalizedMessage
in,
NormalizedMessage out) throws MessagingException {
String result = null;
log("EjbHttpBridge(" + name + ").transform01.
exchange.getService() = " +
exchange.getService());
try {
DefaultServiceMixClient client = new
DefaultServiceMixClient(container);
InOut me = client.createInOutExchange();
me.setInterfaceName(new
QName("http://xfire.jsr181.servicemix.apache.org", "ProxyPojoPortType"));
me.getInMessage().setContent(new StringSource("<echo
xmlns='http://jsr181.servicemix.apache.org'><echoin0>I will send actual
params later</echoin0></echo>"));
client.sendSync(me);
if (me.getError() != null) {
me.getError().printStackTrace();
}
client.done(me);
} catch (Exception e) {
e.printStackTrace();
throw new MessagingException(e.getMessage());
}
log("EjbHttpBridge(" + name + ").transform. End");
return true;
}
}
My ProxyPojo.java is as follows:
------------------------------------------
public interface ProxyPojo {
public String invoke();
}
My ProxyPojoService.java is as follows:
----------------------------------------------------
public class ProxyPojoService implements ProxyPojo {
private ComponentContext context;
private HelloWorldBI proxy;
public void setContext(ComponentContext context) throws Exception {
log("ProxyPojoService.setContext...");
this.context = context;
if (context != null) {
try {
log("ProxyPojoService.setContext. Creating
XFire...");
XFire xfire = Jsr181LifeCycle.createXFire(context);
QName service = new
QName("http://servicemix.apache.org/demo", "jsrEjbEP");
log("ProxyPojoService.setContext. Creating proxy...");
proxy = (HelloWorldBI) JbiProxy.create(xfire, context, null,
service, null, HelloWorldBI.class);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
public String invoke() {
log("ProxyPojoService.invoke...");
String returnString = null;
try{
//My assumption: Later I will retreive actual params
from
// ComponentContext and send through proxy.
returnString = proxy.sayHello(1, "Mike");
}
catch(Exception e){
e.printStackTrace();
}
return returnString;
}
}
The exception I am getting while bringing the ESB up is:
------------------------------------------------------------------------------
D:\ServiceMixTest>D:\Applns\ServiceMix\incubating-servicemix-3.0-SNAPSHOT_2006-05-27\bin\servicemix
servicemix.xml
Apache ServiceMix ESB: 3.0-SNAPSHOT
Loading Apache ServiceMix from file: servicemix.xml
log4j:WARN Continuable parsing error 47 and column 23
log4j:WARN An element with the identifier "FILE" must appear in the
document.
log4j:ERROR No appender named [FILE] could be found.
EjbHttpBridge.EjbHttpBridge(JBIContainer)...
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=ManagementContext
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=EnvironmentContext
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=Registry
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=DefaultBroker
INFO - JBIContainer - Activating component for:
[container=ServiceMix,name=#Subsc
riptionManager#] with service: null component:
[EMAIL PROTECTED]
da0a
INFO - ComponentMBeanImpl - Initializing component:
#SubscriptionManager#
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=InstallationService
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=DeploymentService
INFO - DeploymentService - Restoring service assemblies
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=AutoDeploymentService
DEBUG - AutoDeploymentService - State file doesn't exist:
D:\ServiceMixTest\rootDir\install
.xml
DEBUG - AutoDeploymentService - State file doesn't exist:
D:\ServiceMixTest\rootDir\deploy.
xml
DEBUG - ManagementContext - Registering system service:
org.apache.servicemix:Container
Name=ServiceMix,Type=SystemService,Name=AdminCommandsService
INFO - JBIContainer - ServiceMix JBI Container
(http://servicemix.org/) name: Ser
viceMix running version: 3.0-SNAPSHOT
INFO - JBIContainer - Activating component for:
[container=ServiceMix,name=jsrEjb
BC] with service: {http://servicemix.apache.org/demo}jsrEjbBC component:
org.apache.servicemix.jsr18
[EMAIL PROTECTED]
INFO - ComponentMBeanImpl - Initializing component: jsrEjbBC
DEBUG - Jsr181SpringComponent - Initializing component
DEBUG - JBIContainer - No transaction manager found from
naming context: scheme ja
va not recognized
DEBUG - Jsr181SpringComponent -
DEBUG - Jsr181SpringComponent - Component initialized
INFO - JBIContainer - Activating component for:
[container=ServiceMix,name=proxyP
ojoBC] with service: {http://servicemix.apache.org/demo}proxyPojoBC
component: org.apache.servicemix
[EMAIL PROTECTED]
INFO - ComponentMBeanImpl - Initializing component: proxyPojoBC
DEBUG - Jsr181SpringComponent - Initializing component
DEBUG - Jsr181SpringComponent -
DEBUG - Jsr181SpringComponent - Component initialized
INFO - JBIContainer - Activating component for:
[container=ServiceMix,name=ejbHtt
pBridge] with service: {http://servicemix.apache.org/demo}ejbHttpBridge
component: [EMAIL PROTECTED]
9b3f
INFO - ComponentMBeanImpl - Initializing component:
ejbHttpBridge
DEBUG - ComponentContextImpl - Component: ejbHttpBridge activated
endpoint: {http://servic
emix.apache.org/demo}ejbHttpBridge : ejbHttpBridge
DEBUG - EndpointRegistry - Endpoint
ServiceEndpoint[service={http://servicemix.apache.
org/demo}ejbHttpBridge,endpoint=ejbHttpBridge] has no service description
INFO - JBIContainer - Activating component for:
[container=ServiceMix,name=ID:TVM
KVML19213-2193-1149433490147-0:0] with service: null component:
org.apache.servicemix.http.HttpSprin
[EMAIL PROTECTED]
INFO - ComponentMBeanImpl - Initializing component:
ID:TVMKVML19213-2193-1149433490147-
0:0
DEBUG - HttpSpringComponent - Initializing component
DEBUG - HttpSpringComponent - Component initialized
DEBUG - Jsr181SpringComponent - Starting component
DEBUG - ComponentContextImpl - Component: jsrEjbBC activated
endpoint: {http://servicemix.
apache.org/demo}jsrEjbEP : jsrEjbEP
DEBUG - Jsr181SpringComponent - Querying service description for
ServiceEndpoint[service={h
ttp://servicemix.apache.org/demo}jsrEjbEP,endpoint=jsrEjbEP]
DEBUG - EndpointRegistry - Endpoint
ServiceEndpoint[service={http://servicemix.apache.
org/demo}jsrEjbEP,endpoint=jsrEjbEP] implements interface
{http://servicemix.apache.org/demo}jsrEjbE
PPortType
DEBUG - Jsr181SpringComponent - Unable to inject ComponentContext:
$Proxy0.setContext(javax
.jbi.component.ComponentContext)
DEBUG - Jsr181SpringComponent - Component started
DEBUG - Jsr181SpringComponent - Starting component
DEBUG - ComponentContextImpl - Component: proxyPojoBC activated
endpoint: {http://servicem
ix.apache.org/demo}proxyPojoService : proxyPojoService
DEBUG - Jsr181SpringComponent - Querying service description for
ServiceEndpoint[service={h
ttp://servicemix.apache.org/demo}proxyPojoService,endpoint=proxyPojoService]
DEBUG - EndpointRegistry - Endpoint
ServiceEndpoint[service={http://servicemix.apache.
org/demo}proxyPojoService,endpoint=proxyPojoService] implements interface
{http://servicemix.apache.
org/demo}proxyPojoServicePortType
ProxyPojoService.setContext...
ProxyPojoService.setContext. Creating XFire...
ProxyPojoService.setContext. Creating proxy...
DEBUG - Jsr181SpringComponent - Querying service description for
ServiceEndpoint[service={h
ttp://servicemix.apache.org/demo}jsrEjbEP,endpoint=jsrEjbEP]
DEBUG - Jsr181SpringComponent - Querying service description for
ServiceEndpoint[service={h
ttp://servicemix.apache.org/demo}jsrEjbEP,endpoint=jsrEjbEP]
org.apache.ws.commons.schema.XmlSchemaException: Couldn't map prefix 'ns5'
to a namespace
at
org.apache.ws.commons.schema.SchemaBuilder.handleElement(SchemaBuilder.java:1466)
at
org.apache.ws.commons.schema.SchemaBuilder.handleSequence(SchemaBuilder.java:988)
at
org.apache.ws.commons.schema.SchemaBuilder.handleComplexType(SchemaBuilder.java:568)
at
org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:113)
at
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:273)
at
org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.visit(WSDLServiceBuilder.java:350)
at
org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.build(WSDLServiceBuilder.java:180)
at
org.codehaus.xfire.client.Client.initFromDefinition(Client.java:260)
at
org.apache.servicemix.jsr181.xfire.JbiProxy$JBIClient.<init>(JbiProxy.java:147)
at
org.apache.servicemix.jsr181.xfire.JbiProxy.getProxy(JbiProxy.java:78)
at
org.apache.servicemix.jsr181.xfire.JbiProxy.create(JbiProxy.java:49)
at ProxyPojoService.setContext(ProxyPojoService.java:30)
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:585)
at
org.apache.servicemix.jsr181.Jsr181Endpoint.injectContext(Jsr181Endpoint.java:167)
at
org.apache.servicemix.jsr181.Jsr181Endpoint.activate(Jsr181Endpoint.java:148)
at
org.apache.servicemix.common.ServiceUnit.start(ServiceUnit.java:49)
at
org.apache.servicemix.jsr181.Jsr181SpringComponent$LifeCycle.doStart(Jsr181SpringComponen
t.java:77)
at
org.apache.servicemix.common.BaseLifeCycle.start(BaseLifeCycle.java:198)
at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(ComponentMBeanImpl.java:28
5)
at
org.apache.servicemix.jbi.framework.ComponentRegistry.setInitialRunningStateFromStart(Com
ponentRegistry.java:149)
at
org.apache.servicemix.jbi.framework.ComponentRegistry.start(ComponentRegistry.java:72)
at
org.apache.servicemix.jbi.framework.Registry.start(Registry.java:114)
at
org.apache.servicemix.jbi.container.JBIContainer.start(JBIContainer.java:551)
at
org.apache.servicemix.jbi.container.SpringJBIContainer.afterPropertiesSet(SpringJBIContai
ner.java:78)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMe
thods(AbstractAutowireCapableBeanFactory.java:1059)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(A
bstractAutowireCapableBeanFactory.java:363)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory
.java:226)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory
.java:147)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingle
tons(DefaultListableBeanFactory.java:275)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicatio
nContext.java:320)
at
org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(FileSystemXmlAppli
cationContext.java:149)
at
org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(FileSystemXmlAppli
cationContext.java:100)
at org.apache.servicemix.Main.main(Main.java:80)
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:585)
at
org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
at org.codehaus.classworlds.Launcher.main(Launcher.java:461)
DEBUG - Jsr181SpringComponent - Unable to inject ComponentContext:
null
DEBUG - Jsr181SpringComponent - Component started
DEBUG - HttpSpringComponent - Starting component
INFO - log - Logging to
[EMAIL PROTECTED] via org.m
ortbay.log.Slf4jLog
DEBUG - HttpSpringComponent - Retrieving proxied endpoint
definition
INFO - log - jetty 6.0.0beta15
DEBUG - ServerManager - Dispatching job:
org.mortbay.jetty.AbstractConnector$Accept
[EMAIL PROTECTED]
INFO - log - Started SelectChannelConnector @
localhost:8192
DEBUG - HttpSpringComponent - Component started
DEBUG - AutoDeploymentService - Monitoring directory
D:\ServiceMixTest\rootDir\install for
new or modified archives
DEBUG - AutoDeploymentService - Monitoring directory
D:\ServiceMixTest\rootDir\deploy for n
ew or modified archives
Terminate batch job (Y/N)?
My Queries/Assumptions to be validated:
-------------------------------------------------------
1. Cause for the ERROR - XmlSchemaException: Couldn't map prefix 'ns5' to a
namespace
2. In ProxyPojoService, I have reference to ComponentContext. From that, can
I retrieve XML formatted input message, bind them to Java classes and send
as parameters through proxy to EJB. If this approach not right, alternate
suggestions.
Thanks for continuous help.
- Mike
--
View this message in context:
http://www.nabble.com/JbiProxy-to-invoke-EJB---Couldn%27t-map-prefix-%27ns5%27-to-a-namespace-t1731101.html#a4703349
Sent from the ServiceMix - User forum at Nabble.com.