Hello Friends
I am stuck in a very strange kind of problem.
My application is having the following ejb3, jsf & JBoss-4.0.4.GA
I have got a jsp page which takes the user name & password of the user. The fields are binded to user object in the backing bean[scope is request]. When the user does a login the method in the backing bean is getting called. On doing a lookup[UserService userService = (UserService) context.lookup("UserServiceImpl/remote");] in the backing bean is throwing exception. But the same lookup works fine when tested in TestClass.
EXCEPTION:
javax.naming.CommunicationException [Root exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.net.MalformedURLException: no protocol: Deployment_5Dec/Delete/jboss-4.0.4.GA/server/default/deploy/Test.war/WEB-INF/classes/]
Code for doing the lookup
try
{
Hashtable <String,String> env = new Hashtable<String,String>();
env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.provider.url", "jnp://localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext(env);
UserService userService = (UserService)context.lookup("UserServiceImpl/remote");
user = userService.authenticateUser(user);
if(user != null && user.getUserId() != 0)
{
System.out.println("Logged in successfully");
}
}catch (Exception e)
{
e.printStackTrace();
}
The xml file of data source
mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mysql-ds.xml,v 1.3.2.3 2006/02/07 14:23:00 acoliver Exp $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html -->
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/test_db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>hello</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Thanks in Advance
Amit