Main | Converting to Weblogic 10.3 - Part 1 »

October 06, 2008

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

JHandal

Hi

I'm going to the EJB 3 certification,your book have great examples and is easy reading.

I'm use to netbeans ,I'll deploy your examples in netbeans

and share with other readers,can we have a forum for running

the code in Netbeans and in parallel Weblogic?

Regards

JHandal
NY

someuser

Nice book. I think it's easy to use derby database with the book. But how do i switch all my database to other(e.g say mysql, or postgresql). What configurations i have to write. Please can you give me a complete example of how we can do that. The best example to do that would be the Chapter 4 (any example)

msikora

This is the procedure if you want to use an Oracle database rather than the default derby. The steps will be similar for mysql or postgresql.

1) Log on to GlassFish as an administrator. Define a JDBC connection pool, Oracle_Pool, say. Settings such as minimum and maximum connection pool size are specified, as well as the database URL. The database schema associated with the pool is also set.

2) Next define a JDBC datasource, with JNDI name jdbc/__Oracle say, which we associate with the Oracle_Pool connection pool just defined. This ends our session as glassfish administrators, the details of the datasource and connection pool created are held in the domain.xml file located in $GLASSFISH_HOME\domains\config.

We need a copy of the Oracle JDBC driver, classes12.jar, which can be obtained from Oracle corporation. Again mysql or postgresql will have their corresponding JDBC driver jar files. The driver is then copied to the $GLASSFISH_HOME\domains\domain1\lib\ext directory.

We now turn to the persistence.xml file and make sure the JTA datasource is specified as jdbc/__Oracle (the JNDI name we defined in step 2):


jdbc/__Oracle


That's it.

someuser

Thank you for the reply. Now, how can we use EJB Session Bean in a web project. The most favoriable solution for me is a login project(username, password with authentication persisted) from the web ui(jsf, struts, jsp, servlet any one). I saw many such projects but could not get them working.

Carlos

Michael Sikora Hi, I'm starting with his book "EJB 3 Developer Guide" and run the examples I have this error:
##############################################

C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1>ant all
Buildfile: build.xml

all:

clean:
[delete] Deleting directory C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1
\build
[mkdir] Created dir: C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1\build

[mkdir] Created dir: C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1\build
\lib

compile:
[javac] Compiling 3 source files to C:\EJB 3 Developer Guide\Chapter02\glass
fish\lab1\build

compile:

package-ejb:
[jar] Building jar: C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1\buil
d\TimeService.jar

deploy:
[exec] Uso: deploy [--terse=false] [--echo=false] [--interactive=true] [--h
ost localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwor
dfile file_name] [--virtualservers virtual_servers] [--contextroot context_root]
[--force=true] [--precompilejsp=false] [--verify=false] [--name component_name]
[--upload=true] [--retrieve local_dirpath] [--dbvendorname dbvendorname] [--cre
atetables=true|false | --dropandcreatetables=true|false] [--uniquetablenames=tru
e|false] [--deploymentplan deployment_plan] [--enabled=true] [--generatermistubs
=false] [--availabilityenabled=false] [--libraries jar_file[(pathseparator)jar_f
ile]*] [--target target(Default server)] [--property (name=value)[:name=value]*]
filepath
[exec] CLI019 Invalid number of operands. The number of operands must be equal to 1.

compile:

run-client:
[java] Exception in thread "main" javax.naming.NameNotFoundException: ejb30
.session.TimeService not found
[java] at com.sun.enterprise.naming.TransientContext.doLookup(Transient
Context.java:216)
[java] at com.sun.enterprise.naming.TransientContext.lookup(TransientCo
ntext.java:188)
[java] at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(Se
rialContextProviderImpl.java:74)
[java] at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.loo
kup(RemoteSerialContextProviderImpl.java:129)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(
ReflectiveTie.java:154)
[java] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherIm
pl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
[java] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherIm
pl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handl
eRequestRequest(CorbaMessageMediatorImpl.java:1846)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handl
eRequest(CorbaMessageMediatorImpl.java:1706)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handl
eInput(CorbaMessageMediatorImpl.java:1088)
[java] at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_
1_2.callback(RequestMessage_1_2.java:223)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handl
eRequest(CorbaMessageMediatorImpl.java:806)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispa
tch(CorbaMessageMediatorImpl.java:563)
[java] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWor
k(CorbaMessageMediatorImpl.java:2567)
[java] at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$Worke
rThread.run(ThreadPoolImpl.java:555)
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 4 seconds
C:\EJB 3 Developer Guide\Chapter02\glassfish\lab1>


##############################################
Could you help me with some clues.
Thanks ... Carlos Sanway.

PD: - Ant 1.7.1
- glassfish-installer-v2.1-b60e-windows.jar
- JAVA 1.6.0_13

binh quang

Hi,

I'm has read your book and it's a great book.

In Chapter02 lab2,I use dependency injection to execute TimeService stateless session bean. When run, console shows message :
"Exception in thread "main" java.lang.NullPointerException
at ejb30.client.Client.main(Client.java:13)."

I cannot fix error. Please help me.

Mujahed Syed

what version of glassfish did u use to deploy the code? except for chapter01/lab1 none of them are working for glassfish 3.1. Please assist.

The comments to this entry are closed.