• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB3 Entity Bean won't verify with Netbeans

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working with Netbeans 6.7.1 alongside a Glassfish server 2.1.
Java 1.6 is in the system

I have an enterprise application with a web application with a jsp page,
and a session bean. These guys are fine.

Now I am trying to create an Entity Bean persisting on the Derby DB
in the Glassfish server.

My Persistence Unit is "MyPu" and these are its contents :

Rooms.java, the entity bean, is this :

The real puzzle is that it compiles and it sometimes can even go with the GrandHotel.ear and
be successfully deployed, although it refuses to do any database inserts.
However when I run Verify on the Rooms module (Entity Bean) I get :

Error Name : Could not verify successfully.
Error Description : java.io.IOException: Cannot determine the Java EE module type for E:\NBProjects\Rooms\dist\Rooms.jar

at com.sun.enterprise.deployment.archivist.PluggableArchivistsHelper.getArchivistForArchive(PluggableArchivistsHelper.java:140)

at com.sun.enterprise.deployment.archivist.PluggableArchivistsHelper.getArchivistForArchive(PluggableArchivistsHelper.java:98)

at com.sun.enterprise.deployment.archivist.PluggableArchivistsHelper.getArchivistForArchive(PluggableArchivistsHelper.java:110)

at com.sun.enterprise.deployment.archivist.ArchivistFactory.getArchivistForArchive(ArchivistFactory.java:96)

at com.sun.enterprise.tools.verifier.VerificationHandler.initStandalone(VerificationHandler.java:219)

at com.sun.enterprise.tools.verifier.VerificationHandler.<init>(VerificationHandler.java:111)

at com.sun.enterprise.tools.verifier.Verifier.verify(Verifier.java:140)

at com.sun.enterprise.tools.verifier.Verifier.main(Verifier.java:114)

I see the message : Cannot determine the Java EE module type but
I have the @Entity annotation written in Rooms.java quite clearly. This error message is rather ambiguous to me.

Does the persistence unit connect to the database and create the ROOMS table I need, or must I do that elsewhere in code?

Can anybody point me in the right direction?


 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Dan,

The @Entity is part of the persistence API. Having @Entity in the class only indicates that the jar is a persistence unit, which is not an ejb jar.

From here

EJB3+ entity beans (@Entity) are POJOs and should be packaged as library jar.

From here

 
Dan Kempten
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that I need to do something else to make it verify under Netbeans?

Or are you saying that I can never verify it under Netbeans?

I have developed this Rooms.java (entity) under its own singular project module along with the persistence unit. Are you saying that I should not do this?

If so where in the Netbeans landscape does the entity class file and the persistence unit belong?

Should I put Rooms.java and the persisitence unit into the same module as its facade session bean?

Or should I put Rooms.java into the web component and the persisitence unit into the Enterprise application module?

"package as a library.jar" -- do you mean make a jar "outside" of Netbeans and slide it in somewhere in the Enterprise application?

There are no comprehensive examples of Entities (beans), only innumerable session beans.

 
Alaa Nassef
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest thing to do to make it verify in net beans is to create your entity, then right click on it and generate a session bean for it.
 
Dan Kempten
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you meant to say that I should make a Session bean and
right click on the package holding the Session bean. That and many other details finally fixed this aspect.

However it still does not write, although it can read records I enter by hand from another source.
It all verifies and deploys correctly but it cannot write any records.

Must there be certain values set in the persistence.xml by hand in order to
make it possible to write?

em.persist(room1); does nothing
 
Alaa Nassef
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan Kempten wrote:However it still does not write, although it can read records I enter by hand from another source.
It all verifies and deploys correctly but it cannot write any records.

Must there be certain values set in the persistence.xml by hand in order to
make it possible to write?

em.persist(room1); does nothing



Most probably this has to do with your configuration of transaction management. You have to open a transaction before calling persist, and commit the transaction after. You don't have to do that yourself. You Just need to do some configurations of the transaction manager. I didn't do that for EJBs since I usually use spring. I suggest that you open another thread for that.
 
Dan Kempten
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>Most probably this has to do with your configuration of transaction management

1. I found that the two interfaces for the session bean were not annotated at all and

2. also saw in an example that the entity bean was instantiated with a simple "new EntityBean()" in the JSP web app

3. After much agony I also found that I needed to annotate the session bean class with something like this :

@SomeSuch(mappedName="MyJNDIName") // I left the details at the academy

With that I could use InitialContext and lookup to instantiate the Session bean in the JSP web app.

4. I also found that one could also instantiate the POJO Entity bean within the Session Bean Class, again with "new EntityBean()",

but now I am finding that using this "new EntityBean()" three times in a row in the JSP only writes the first time into DB but

the second and third beans are ignored by the persistence mechanism. Perhaps counting to three is too much for a @Stateless bean

So it goes.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic