• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

exception in running cmp in jboss4.0.2

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic