[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Could not find datasource message in client JPA although
ezanih
do-not-reply at jboss.com
Fri Jan 2 04:46:01 EST 2009
Hi
I think I've narrowed down the possible JNDI naming problem to this few lines of code :-
| Properties p = new Properties();
| p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| p.put("java.naming.provider.url", "localhost:1099");
| p.put("java.naming.factory.url.pkgs", "org.jboss.naming.client");
|
| InitialContext ctx = new InitialContext();
| Bidder bidder = (Bidder) ctx.lookup(Bidder.class.getName());
| //Object obj = ctx.lookup("java:OracleXE1_DS");
| //DataSource obj = (DataSource) ctx.lookup("java:OracleXE1_DS");
|
It has to be one the 3 lines below the initial context instantiation line. Perhaps if you could just give me some pointers what each of those 3 lines do? Thxs!
As per the code above, I'm still getting the naming error as before :-(
Oh..I forgot to post the code for the Bidder.java entity which is just a standard JPA entity class :-
| package my.com.eperolehan.entities;
|
| import java.io.Serializable;
| import java.lang.String;
| import javax.persistence.*;
|
| /**
| * Entity implementation class for Entity: Bidder
| *
| */
| @Entity
| @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
| @Table(name="BIDDER")
| public class Bidder implements Serializable {
|
|
| @Id
| @GeneratedValue
| @Column(nullable=false)
| private int id;
| private int bidSessionId;
| private String bidderName;
| private static final long serialVersionUID = 1L;
|
|
| public Bidder() {
| super();
| }
| public int getId() {
| return this.id;
| }
|
| public void setId(int id) {
| this.id = id;
| }
| public int getBidSessionId() {
| return this.bidSessionId;
| }
|
| public void setBidSessionId(int bidSessionId) {
| this.bidSessionId = bidSessionId;
| }
| public String getBidderName() {
| return this.bidderName;
| }
|
| public void setBidderName(String bidderName) {
| this.bidderName = bidderName;
| }
|
| public String toString() {
|
| StringBuffer BidderInfo = new StringBuffer();
|
| BidderInfo.append("id");
| BidderInfo.append(" " );
| BidderInfo.append("BidSessionId");
| BidderInfo.append(" " );
| BidderInfo.append("BidderName");
| BidderInfo.append(" : " );
| BidderInfo.append(id);
| BidderInfo.append(" " );
| BidderInfo.append(bidSessionId);
| BidderInfo.append(" " );
| BidderInfo.append(bidderName);
| return BidderInfo.toString();
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4199178#4199178
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4199178
More information about the jboss-user
mailing list