JCA-Deployment-Connector- JNDI-Problem
murphyric Sep 23, 2005 9:07 AMHi,
I'm using JBOSS4.0.2.windowsXP(pro)
I deployed the rar file "MyHelloWorldRar.rar" and a JAR(SLSBean) which contains a SLSbean only , to use/connect to the Connectionfactory.
1) I'm not able to connect 'MyHelloWorldRar' adapter from the SLSB(code below).Something to do with the JNDI Lookup.
2) Should we pack both ra.xml & -ds.xml in the .rar file or -dx.xml should be deployed seperately as a file in the server\default\deploy directory?I have packed both xml's in the META-INF in RAR and had no errors on the console.But if I deploy seperately the -ds.xml file I have the below error;
Please help me on this issue, your help is greatly appreciated.
-----------------------------------------------------------------------------------
18:12:04,843 ERROR [MainDeployer] Could not initialise deployment: file:/E:/jbos
s-4.0.2/server/default/deploy/HelloWorld-ds.xml
org.jboss.deployment.DeploymentException: Could not parse dd; - nested throwable
: (org.xml.sax.SAXParseException: A pseudo attribute name is expected. )
at org.jboss.deployment.XSLSubDeployer.findDd(XSLSubDeployer.java:263)
at org.jboss.deployment.XSLSubDeployer.init(XSLSubDeployer.java:195)
at org.jboss.deployment.MainDeployer.init(MainDeployer.java:828)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:765)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
er.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
or.java:121)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
BeanOperationInterceptor.java:127)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
tScanner.java:325)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
canner.java:501)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
doScan(AbstractDeploymentScanner.java:204)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
loop(AbstractDeploymentScanner.java:215)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
run(AbstractDeploymentScanner.java:194)
Caused by: org.xml.sax.SAXParseException: A pseudo attribute name is expected.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.jboss.deployment.XSLSubDeployer.findDd(XSLSubDeployer.java:258)
... 22 more
-----------------------------------------------------------------------------------
The ra.xml file
-------------------------ra.xml------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN' 'http://java.sun.com/dtd/connector_1_0.dtd'>
<display-name>HelloWorld Resource Adapter</display-name>
HelloWorld Resource Adapter
<vendor-name>abc</vendor-name>
<spec-version>1.0</spec-version>
<eis-type>Helloworld</eis-type>
1.0
copy right
<license-required>true</license-required>
<managedconnectionfactory-class>
adapter.helloworld.ManagedConnectionFactoryImpl
</managedconnectionfactory-class>
<connectionfactory-interface>
adapter.helloworld.HWConnectionFactory
</connectionfactory-interface>
<connectionfactory-impl-class>
adapter.helloworld.ConnectionFactoryImpl
</connectionfactory-impl-class>
<connection-interface>
adapter.helloworld.HWConnection
</connection-interface>
<connection-impl-class>
adapter.helloworld.ConnectionImpl
</connection-impl-class>
<transaction-support>
NoTransaction
</transaction-support>
<authentication-mechanism>
<authentication-mechanism-type>
BasicPassword
</authentication-mechanism-type>
<credential-interface>
javax.resource.spi.security.PasswordCredential
</credential-interface>
</authentication-mechanism>
<reauthentication-support>false</reauthentication-support>
--------------------------------------------------------------------------------------
the hw-ds.xml file
------------------hw-ds.xml---------------------------------------------------------
<?xml version="1.0" encoding="UTF-8">
<connection-factories>
<no-tx-connection-factory>
<jndi-name>MyHelloWorldRar</jndi-name>
<adapter-display-name>MyHelloWorldRar</adapter-display-name>
<rar-name>MyHelloWorldRar.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
</no-tx-connection-factory>
</connection-factories>
--------------------------------------------------------------------------------------
the helloBean.java file
----------------------------helloBean.java---------statelesssessionbean--------
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
import javax.rmi.*;
import adapter.helloworld.*;
public class HelloBean implements SessionBean
{
/* ---- EJB-required methods------*/
Properties p=new Properties();
Context ctx;
private HWConnectionFactory m_cf;
HWConnection conn;
public void ejbCreate()
{
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put(Context.PROVIDER_URL,"localhost:1099");
try{
ctx=new InitialContext(p);
m_cf=(HWConnectionFactory)ctx.lookup("MyHelloWorldRar");
conn = m_cf.getConnection();
System.out.println("MyHelloWorldRarfound in EJBCREATE()");
}catch(Exception e)
{
System.out.println("Exception in Create..Lookup"+e.getMessage());
}
}
public void ejbRemove()
{
System.out.println(" EJBREMOVE()");
}
public void ejbActivate()
{
System.out.println(" EJBACTIVATE()");
}
public void ejbPassivate()
{
System.out.println("EJBPassivate()");
}
public void setSessionContext(SessionContext ctx)
{
System.out.println("SetSessionContext()");
}
public void unsetSessionContext()
{
System.out.println("SetSessionContext()");
try{
conn.close();
}catch(Exception e)
{ System.out.println("Exception in Create..Lookup"+e.getMessage());
}
}
/*------Business Methods-------------*/
public String hello(String name)
{
System.out.println("hello()");
String n="";
try{
n=conn.sayHello(name);
}catch(Exception e)
{
System.out.println("Exception in Create..Lookup"+e.getMessage());
}
return n;
}
}
-------------------------------------------------------------------------------------
Thanx in Advance