-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 
Author Message
 Post subject: Chapter 2: 2.2.3 Introducing EJB components
PostPosted: Wed Mar 28, 2007 6:35 am 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
Hello Hibernate -

page 80, first paragraph:
Quote:
...and copy all included configuration files to your WORKDIR/src
directory.


As a neophyte I'm not sure how to interpret this instruction practically.
My best guess is to copy only those files from the ~\server\default\conf
directory and no others. Is this correct?

If this assumption is correct, should the conf directory structure be
stripped out with files in subdirectories, eg
~\props\jbossws-roles.properties, insterted directly in ~\src, or
should the server conf directory contents be copied in verbatum?

Also, WORKDIR and JBoss server dir both have a jndi.properties
file. The value for the java.naming.factory.initial property
differs between the two with the WORKDIR version value set
to org.jnp.interfaces.LocalOnlyContextFactory and the
JBoss server version set to org.jnp.interfaces.NamingContextFactory,
additionally cautioning
Quote:
# DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING


I dont know what I am doing. How should this potential conflict be handled,
eg should the server version be copied into the WORKDIR space, or ?

Please advise.


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.2 GA

Mapping documents: HSQLDB 1.8.0

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Quote:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 7:43 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please read the chapter again. It does not say: "Install JBoss Application Server". It says "Install the embeddable server for EJB3". See this thread:

http://forum.hibernate.org/viewtopic.php?t=972608

Just download the working code with all server software included from http://caveatemptor.hibernate.org

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 11:03 am 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
Thank you.

Still on helloworld-ejb3, using unedited helloworld-ejb3 install files.
Downloaded and unzipped jboss-EJB_3.0_RC1.zip.
Copied all files across to WORKDIR lib & src. Compiles ok. db startup ok.

run yields:

Code:
     [java] 15:25:28,078  INFO LocalTxDataSource:117 - Bound datasource to JNDI name 'java:/HelloWorldDS'
     [java] Exception in thread "main" javax.naming.NameNotFoundException: MessageHandlerBean not bound
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
     [java]     at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
     [java]     at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
     [java]     at hello.HelloWorld.main(Unknown Source)
     [java] Java Result: 1


file embedded-jboss-beans.xml mentioned on page 84 not in
EJB_3.0_RC1.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 11:38 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do NOT download anything else but the helloworld example package. It has everything you need. Just unpack it. You do NOT have to install anything else. Follow the README.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 12:36 pm 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
OK. followed readme. same result (jdk1.6.0). so rebuilt my lab rat machine from scratch, wipe disk, winxp re-install etc.

installed these packages:
jdk1.5.0_11
apache-ant-1.6.5
hsqldb_1_8_0_7
hibernate-3.2.2.ga
jpwh-gettingstarted-061110

no edting/alterations.

result:
Code:
C:\helloworld\helloworld-ejb3>ant run
Buildfile: build.xml

compile:

copymetafiles:
     [copy] Copying 7 files to C:\helloworld\helloworld-ejb3\build

run:
     [java] 17:11:41,248  INFO LocalTxDataSource:117 - Bound datasource to JNDI name 'java:/HelloWorldDS'
     [java] Exception in thread "main" javax.naming.NameNotFoundException: MessageHandlerBean not bound
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
     [java]     at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
     [java]     at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:351)
     [java]     at hello.HelloWorld.main(Unknown Source)
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 8 seconds


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 2:54 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You do NOT have to install any libraries. I wonder why I can't get this through. JDK 5.0, Ant ready, unzip the archive, run it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 6:11 am 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
Oops, sorry.

hsqldb_1_8_0_7 and hibernate-3.2.2.ga arent installed as in
included in path or classpath only downloaded (in case I
got to the point where debugging and src would be useful).
I'll remove them altogether then and have another go.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 8:09 am 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
Same result with only ant, java5 installed. What information can I
supply to help resolve this issue?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 11:36 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You could use the last version, which has been online for three months:

http://www.hibernate.org/hib_files/cave ... 061211.zip

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 11:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh sorry, this is not the Getting Started. I will check that again too...

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 11:43 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It's a Microsoft Windows issue. Until I release a one-line fix for the braindead Windows path separator, read the comments in HelloWorld.java and replace the FAST scanning method with the SLOW scanning method by commenting/uncommenting the appropriate lines.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 12:09 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please try this for me on Windows:

http://www.hibernate.org/hib_files/jpwh ... 070401.zip

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 03, 2007 2:20 pm 
Newbie

Joined: Sat Mar 24, 2007 9:38 am
Posts: 8
Location: London
Thanks, I'll give it a go.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 6:38 pm 
Newbie

Joined: Tue Dec 18, 2007 7:42 am
Posts: 19
Roxello wrote:
OK. followed readme. same result (jdk1.6.0). so rebuilt my lab rat machine from scratch, wipe disk, winxp re-install etc.

installed these packages:
jdk1.5.0_11
apache-ant-1.6.5
hsqldb_1_8_0_7
hibernate-3.2.2.ga
jpwh-gettingstarted-061110

no edting/alterations.

result:
Code:
C:\helloworld\helloworld-ejb3>ant run
Buildfile: build.xml

compile:

copymetafiles:
     [copy] Copying 7 files to C:\helloworld\helloworld-ejb3\build

run:
     [java] 17:11:41,248  INFO LocalTxDataSource:117 - Bound datasource to JNDI name 'java:/HelloWorldDS'
     [java] Exception in thread "main" javax.naming.NameNotFoundException: MessageHandlerBean not bound
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
     [java]     at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
     [java]     at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:351)
     [java]     at hello.HelloWorld.main(Unknown Source)
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 8 seconds


------ END OF Roxello's QUOTE ----------

I had the same problem. And found 2 possible causes:

1)
I noticed that the problem did not occure when using the ANT build file provided in the examples, but did occur when running it manually from Eclipse without ANT.
When the ANT java task attribute
Code:
fork="true"

is removed from the build file, the problem does occur.
Ant doc about the fork attribute: "if enabled triggers the class execution in another VM (disabled by default)".

2)
If I run it from the command line (outside Eclipse), I have to use the full absolute classpath. For example, this will fail (NameNotFoundException):
(Current directory is c:\java\build)
Code:
java -cp "..\lib\*;." hello.HelloWorld

and this will succeed:
Code:
java -cp "..\lib\*;c:\java\build" hello.HelloWord



The EJB3StandaloneBootstrap.scanClasspath() method in the main method of HelloWorld must also be set correctly.
In my case it will succeed when using:
(Current directory is c:\java\build\)
Code:
EJB3StandaloneBootstrap.scanClasspath("build");

(Which is a bit strange because I'm already in the "build" dir. Specifing it again makes no sense to me, but without it, it will fail.)
but fails when using the absolute path something like:
Code:
EJB3StandaloneBootstrap.scanClasspath("c:/java/build".replace("/", File.separator));


Also note that the jboss docs say:
Quote:
public static void scanClasspath(java.lang.String paths)
Scan java.class.path System property for jars that contain EJB3 files.
This is unportable and unreliable. Use with caution.


---

Edit:
the most simple solution:
You can simply change the scanclasspath to:
Code:
EJB3StandaloneBootstrap.scanClasspath();


Then you don't have to use the "fork" attribute; Eclipse and other IDE's can run it directly; and command line doesn't require the absolute path, so that this will also work:
Code:
java -cp "../lib/*;." hello.HelloWorld


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.