Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

exception in running cmp in jboss4.0.2  RSS feed

 
Abhishek Srivastava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody

I have made database in access that consist of 4fields id,name,position,salary .first three are Text and last is number ,also id is primary key.

I set classpath with jbossall-client.jar as well as jboss-j2ee.jar files.

In META-INF,I put jboss.xml,ejb-jar.xml and jbosscmp-jdbc.xml.

This is the code in jbosscmp-jdbc.xml

<jbosscmp-jdbc>
<enterprise-beans>
<entity>
<ejb-name>abc</ejb-name>
<create-table>true</create-table>
<remove-table>true</remove-table>
<table-name>PlayerBean</table-name>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>name</column-name>
</cmp-field>


<cmp-field>
<field-name>position</field-name>
<column-name>position</column-name>
</cmp-field>

<cmp-field>
<field-name>salary</field-name>
<column-name>salary</column-name>

</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>

and i put msaccess-ds.xml in server-default-deploy directory with following changes:


<datasources>
<local-tx-datasource>
<jndi-name>MSAccessDS</jndi-name>
<!-- format of URL is "jdbc dbc SNNAME" -->
<connection-url>jdbc dbc:STG</connection-url>
<driver-class>sun.jdbc.odbc.JdbcOdbcDriver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>

</datasources>

and i made changes in standardjbosscmp-jdbc.xml of conf directory
as :


<jbosscmp-jdbc>

<defaults>
<datasource>java:/MSAccessDS</datasource>
<datasource-mapping>MS ACCESS</datasource-mapping>
</jbosscmp-jdbc>

Now if i made client as:

import javax.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;

public class CmpClient
{
public static void main(String s[])
{
try
{
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.InitialContextFactory");
prop.put(Context.PROVIDER_URL,"localhost:1099");
Context context=new InitialContext(prop);
Object object=context.lookup("cmp");
CmpHome home=(CmpHome)PortableRemoteObject.narrow(object,CmpHome.class);
CmpRemote remote=home.create("ao1","sachine","j2ee",1222);
System.out.println("id of customer"+remote.getId());
}
catch(Exception c)
{
System.out.println(c.getMessage());
}

}
}

and try to run this program ,it throws following RuntimeException
as the bean class CmpBean does not have id.

But i saw several times that program is running quite well in weblogic server .Now try to help me out in jboss server.May i am lacking in any process or files.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your client code is calling a remote EJB, and you say that RuntimeException is thrown. But the container will only do this when a bean has a local client. Please post all your EJB code, including interfaces, as well as the ejb-jar.xml file.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mr. java srivastava"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!