javax.naming.NameNotFoundException: remote not bound
Bonjour à tous,
je sais que le meme titre de post se trouve juste en dessous de celui-ci mais le problème est un poil différent et l'on m'a dit d'ouvrir une nouvelle discussion.
Je vous expose le probleme, je développe sous netbeans 5.5 et JBoss 4.0.5.
Nous developpons une application dont la database existe deja et se trouve sous mysql. J'ai donc installé la db sur mon ordi et a partir de celle-ci, j'ai créé mes entity grace a netbeans (menu: create entity from database) . J'ai ensuite créé ma persistence Unit avec une nouvelle data source pour mysql. Apres cela j'ai créé mes sessions beans pour mes entity et jusque la tout va bien.
Le premier probleme est arrivé qd j'ai voulu ecrire un petit client utilisant le jndi context, voir ici.
Ensuite sont arrivés les problemes de '-' (tirets) dans les noms de mes table sql :marteau:
Ensuite, le code des entity généré a partir de la db etait assez bizarre:
Code:
1 2 3 4 5
| @OneToMany(cascade = CascadeType.ALL, mappedBy = "reqPersonsA")
private Collection<PersonsLanguages> personsLanguagesCollection;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "reqPersonsA1")
private Collection<PersonsLanguages> personsLanguagesCollection1; |
Il m'a créé dans casi toutes mes classes des variables en double apparemment, se terminant par '1'...
Autre exemple ici:
Code:
1 2 3 4 5 6 7 8
| @JoinColumn(name = "CONTACT", referencedColumnName = "ID")
@ManyToOne
private Representatives contact;
@JoinColumn(name = "CONTACT", referencedColumnName = "ID")
@ManyToOne
private Representatives contact1; |
J'ai donc mis en commentaire tous les bouts de code qui avait l'air en double car j'avais alors des noms de colonnes redondant dans mes tables et netbeans plantait lors du déployement.
Une fois le code corrigé, et que mon projet se déployait enfin correctement, je retombe sur mon premier probleme qui est maintenant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| javax.naming.NameNotFoundException: remote not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:613)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at client.InitDB.main(InitDB.java:23) |
Et la je seche completement, je ne vois pas d'ou vient l'erreur. Voici le code des classes impliquées:
Mon client:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| package client;
import bo.ReqPersonsA;
import dao.ReqPersonsAFacadeLocal;
import java.util.Hashtable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class InitDB {
// @EJB private static JoueurDao jB;
public static void main(String[] args) {
try {
Context jndiContext = getInitialContext();
Object ref = jndiContext.lookup("EAW2/ReqPersonsAFacade/remote");
ReqPersonsAFacadeLocal rpdao = (ReqPersonsAFacadeLocal) ref;
ReqPersonsA rp1 = new ReqPersonsA();
rp1.setName("Alejandro");
rp1.setForname("Alonzo");
rp1.setMaidenName("DeBosque");
rp1.setAliase("El chiquito");
rp1.setSex('M');
rp1.setNationality("Spain");
rpdao.create(rp1);
rp1.setId(rp1.getId());
System.out.println("Ajout personne ok");
} catch (javax.naming.NamingException ne) {
ne.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "localhost:1099");
return new InitialContext(env);
}
} |
ReqPersonsAFacade
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
package dao;
import bo.ReqPersonsA;
import java.util.List;
import javax.ejb.Remote;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
*
* @author imacx
*/
@Stateless
public class ReqPersonsAFacade implements ReqPersonsAFacadeLocal {
@PersistenceContext
private EntityManager em;
/** Creates a new instance of ReqPersonsAFacade */
public ReqPersonsAFacade() {
}
public void create(ReqPersonsA reqPersonsA) {
em.persist(reqPersonsA);
}
public void edit(ReqPersonsA reqPersonsA) {
em.merge(reqPersonsA);
}
public void destroy(ReqPersonsA reqPersonsA) {
em.merge(reqPersonsA);
em.remove(reqPersonsA);
}
public ReqPersonsA find(Object pk) {
return (ReqPersonsA) em.find(ReqPersonsA.class, pk);
}
public List findAll() {
return em.createQuery("select object(o) from ReqPersonsA as o").getResultList();
}
} |
ReqPersonsAFacadeLocal
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| package dao;
import bo.ReqPersonsA;
import java.util.List;
import javax.ejb.Local;
import javax.ejb.Remote;
/**
*
* @author imacx
*/
@Local
public interface ReqPersonsAFacadeLocal {
void create(ReqPersonsA reqPersonsA);
void edit(ReqPersonsA reqPersonsA);
void destroy(ReqPersonsA reqPersonsA);
ReqPersonsA find(Object pk);
List findAll();
} |
ReqPersonsA
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
|
package bo;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* Entity class ReqPersonsA
*
* @author imacx
*/
@Entity
@Table(name = "req_persons_a")
public class ReqPersonsA implements Serializable {
@Id
@Column(name = "ID", nullable = false)
private Integer id;
@Column(name = "NAME")
private String name;
@Column(name = "FORNAME")
private String forname;
@Column(name = "MAIDEN_NAME")
private String maidenName;
@Column(name = "ALIASE")
private String aliase;
@Column(name = "SEX")
private Character sex;
@Column(name = "NATIONALITY")
private String nationality;
@Column(name = "BIRTH_DATE")
@Temporal(TemporalType.DATE)
private Date birthDate;
@Column(name = "BIRTH_PLACE")
private String birthPlace;
@Lob
@Column(name = "PHOTO")
private byte [] photo;
@Lob
@Column(name = "DISTINCTIVE_MARKS")
private String distinctiveMarks;
@Lob
@Column(name = "FINGERPRINTS")
private byte [] fingerprints;
@Lob
@Column(name = "ADN")
private String adn;
@Lob
@Column(name = "ADDRESS")
private String address;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "reqPersonsA")
private Collection<PersonsLanguages> personsLanguagesCollection;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "reqPersonsA1")
// private Collection<PersonsLanguages> personsLanguagesCollection1;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "personId")
private Collection<EuArrestWarrant> euArrestWarrantCollection;
/** Creates a new instance of ReqPersonsA */
public ReqPersonsA() {
}
/**
* Creates a new instance of ReqPersonsA with the specified values.
* @param id the id of the ReqPersonsA
*/
public ReqPersonsA(Integer id) {
this.id = id;
}
/**
* Gets the id of this ReqPersonsA.
* @return the id
*/
public Integer getId() {
return this.id;
}
/**
* Sets the id of this ReqPersonsA to the specified value.
* @param id the new id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Gets the name of this ReqPersonsA.
* @return the name
*/
public String getName() {
return this.name;
}
/**
* Sets the name of this ReqPersonsA to the specified value.
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the forname of this ReqPersonsA.
* @return the forname
*/
public String getForname() {
return this.forname;
}
/**
* Sets the forname of this ReqPersonsA to the specified value.
* @param forname the new forname
*/
public void setForname(String forname) {
this.forname = forname;
}
/**
* Gets the maidenName of this ReqPersonsA.
* @return the maidenName
*/
public String getMaidenName() {
return this.maidenName;
}
/**
* Sets the maidenName of this ReqPersonsA to the specified value.
* @param maidenName the new maidenName
*/
public void setMaidenName(String maidenName) {
this.maidenName = maidenName;
}
/**
* Gets the aliase of this ReqPersonsA.
* @return the aliase
*/
public String getAliase() {
return this.aliase;
}
/**
* Sets the aliase of this ReqPersonsA to the specified value.
* @param aliase the new aliase
*/
public void setAliase(String aliase) {
this.aliase = aliase;
}
/**
* Gets the sex of this ReqPersonsA.
* @return the sex
*/
public Character getSex() {
return this.sex;
}
/**
* Sets the sex of this ReqPersonsA to the specified value.
* @param sex the new sex
*/
public void setSex(Character sex) {
this.sex = sex;
}
/**
* Gets the nationality of this ReqPersonsA.
* @return the nationality
*/
public String getNationality() {
return this.nationality;
}
/**
* Sets the nationality of this ReqPersonsA to the specified value.
* @param nationality the new nationality
*/
public void setNationality(String nationality) {
this.nationality = nationality;
}
/**
* Gets the birthDate of this ReqPersonsA.
* @return the birthDate
*/
public Date getBirthDate() {
return this.birthDate;
}
/**
* Sets the birthDate of this ReqPersonsA to the specified value.
* @param birthDate the new birthDate
*/
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
/**
* Gets the birthPlace of this ReqPersonsA.
* @return the birthPlace
*/
public String getBirthPlace() {
return this.birthPlace;
}
/**
* Sets the birthPlace of this ReqPersonsA to the specified value.
* @param birthPlace the new birthPlace
*/
public void setBirthPlace(String birthPlace) {
this.birthPlace = birthPlace;
}
/**
* Gets the photo of this ReqPersonsA.
* @return the photo
*/
public byte [] getPhoto() {
return this.photo;
}
/**
* Sets the photo of this ReqPersonsA to the specified value.
* @param photo the new photo
*/
public void setPhoto(byte [] photo) {
this.photo = photo;
}
/**
* Gets the distinctiveMarks of this ReqPersonsA.
* @return the distinctiveMarks
*/
public String getDistinctiveMarks() {
return this.distinctiveMarks;
}
/**
* Sets the distinctiveMarks of this ReqPersonsA to the specified value.
* @param distinctiveMarks the new distinctiveMarks
*/
public void setDistinctiveMarks(String distinctiveMarks) {
this.distinctiveMarks = distinctiveMarks;
}
/**
* Gets the fingerprints of this ReqPersonsA.
* @return the fingerprints
*/
public byte [] getFingerprints() {
return this.fingerprints;
}
/**
* Sets the fingerprints of this ReqPersonsA to the specified value.
* @param fingerprints the new fingerprints
*/
public void setFingerprints(byte [] fingerprints) {
this.fingerprints = fingerprints;
}
/**
* Gets the adn of this ReqPersonsA.
* @return the adn
*/
public String getAdn() {
return this.adn;
}
/**
* Sets the adn of this ReqPersonsA to the specified value.
* @param adn the new adn
*/
public void setAdn(String adn) {
this.adn = adn;
}
/**
* Gets the address of this ReqPersonsA.
* @return the address
*/
public String getAddress() {
return this.address;
}
/**
* Sets the address of this ReqPersonsA to the specified value.
* @param address the new address
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Gets the personsLanguagesCollection of this ReqPersonsA.
* @return the personsLanguagesCollection
*/
public Collection<PersonsLanguages> getPersonsLanguagesCollection() {
return this.personsLanguagesCollection;
}
/**
* Sets the personsLanguagesCollection of this ReqPersonsA to the specified value.
* @param personsLanguagesCollection the new personsLanguagesCollection
*/
public void setPersonsLanguagesCollection(Collection<PersonsLanguages> personsLanguagesCollection) {
this.personsLanguagesCollection = personsLanguagesCollection;
}
// /**
// * Gets the personsLanguagesCollection1 of this ReqPersonsA.
// * @return the personsLanguagesCollection1
// */
// public Collection<PersonsLanguages> getPersonsLanguagesCollection1() {
// return this.personsLanguagesCollection1;
// }
//
// /**
// * Sets the personsLanguagesCollection1 of this ReqPersonsA to the specified value.
// * @param personsLanguagesCollection1 the new personsLanguagesCollection1
// */
// public void setPersonsLanguagesCollection1(Collection<PersonsLanguages> personsLanguagesCollection1) {
// this.personsLanguagesCollection1 = personsLanguagesCollection1;
// }
/**
* Gets the euArrestWarrantCollection of this ReqPersonsA.
* @return the euArrestWarrantCollection
*/
public Collection<EuArrestWarrant> getEuArrestWarrantCollection() {
return this.euArrestWarrantCollection;
}
/**
* Sets the euArrestWarrantCollection of this ReqPersonsA to the specified value.
* @param euArrestWarrantCollection the new euArrestWarrantCollection
*/
public void setEuArrestWarrantCollection(Collection<EuArrestWarrant> euArrestWarrantCollection) {
this.euArrestWarrantCollection = euArrestWarrantCollection;
}
/**
* Returns a hash code value for the object. This implementation computes
* a hash code value based on the id fields in this object.
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
int hash = 0;
hash += (this.id != null ? this.id.hashCode() : 0);
return hash;
}
/**
* Determines whether another object is equal to this ReqPersonsA. The result is
* <code>true</code> if and only if the argument is not null and is a ReqPersonsA object that
* has the same id field values as this object.
* @param object the reference object with which to compare
* @return <code>true</code> if this object is the same as the argument;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof ReqPersonsA)) {
return false;
}
ReqPersonsA other = (ReqPersonsA)object;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
return true;
}
/**
* Returns a string representation of the object. This implementation constructs
* that representation based on the id fields.
* @return a string representation of the object.
*/
@Override
public String toString() {
return "bo.ReqPersonsA[id=" + id + "]";
}
} |
Viendrait-elle du chemin que j'utilise qd je fais mon lookup?
Code:
Object ref = jndiContext.lookup("EAW2/ReqPersonsAFacade/remote");
Merci pour votre aide