-----Original Message-----
From: David Blevins [mailto:[email protected]]
Sent: Monday, June 22, 2009 9:02 PM
To: [email protected]
Subject: Re: jndi lookup
No applications have been discovered in your classpath. I recommend
the META-INF/ejb-jar.xml approach described here:
http://openejb.apache.org/3.0/application-discovery-via-the-classpath.ht
ml
If you're having trouble determining if the META-INF/ejb-jar.xml file
for your ejb module is in the classpath, a little debug code like this
in your test setup will help you see what OpenEJB sees (which may be
nothing):
Enumeration<URL> ejbJars =
this.getClass().getClassLoader().getResources("META-INF/ejb-jar.xml");
while (ejbJars.hasMoreElements()) {
URL url = ejbJars.nextElement();
System.out.println("app = " + url);
}
Regarding the logging, we have an embedded.logging.properties file
packed in our openejb-core jar that we use to configure the logging.
You shouldn't need to create your own -- although that's fine. You
can also put logging tweaks right in your InitialContext properties
like so:
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
p.put("log4j.rootLogger", "fatal,C");
p.put("log4j.category.OpenEJB", "warn");
p.put("log4j.category.OpenEJB.options", "info");
p.put("log4j.category.OpenEJB.server", "info");
p.put("log4j.category.OpenEJB.startup", "info");
p.put("log4j.category.OpenEJB.startup.service", "warn");
p.put("log4j.category.OpenEJB.startup.config", "info");
p.put("log4j.category.OpenEJB.hsql", "info");
p.put("log4j.category.CORBA-Adapter", "info");
p.put("log4j.category.Transaction", "warn");
p.put("log4j.category.org.apache.activemq", "error");
p.put("log4j.category.org.apache.geronimo", "error");
p.put("log4j.category.openjpa", "error");
p.put("log4j.appender.C", "org.apache.log4j.ConsoleAppender");
p.put("log4j.appender.C.layout", "org.apache.log4j.SimpleLayout");
Context context = new InitialContext(p);
Essentially, everything starting with "log4j." gets applied as
overrides on top of the embedded.logging.properties we find in the
classpath. This makes it possible to easily tweak the log levels
while debugging a particular test, for example.
Note, that InitialContext properties can also be supplied in a
jndi.properties file in the classpath. So all the above is possible
and more, for example:
--[jndi.properties]--
# set the initial context factory
java.naming.factory.initial =
org.apache.openejb.client.LocalInitialContextFactory
# change some logging
log4j.category.OpenEJB.options = debug
log4j.category.OpenEJB.startup = debug
log4j.category.OpenEJB.startup.config = debug
# create some resources
movieDatabase = new://Resource?type=DataSource
movieDatabase.JdbcDriver = org.hsqldb.jdbcDriver
movieDatabase.JdbcUrl = jdbc:hsqldb:mem:moviedb
# override properties on your "movie-unit" persistence unit
movie-unit.hibernate.dialect = org.hibernate.dialect.HSQLDialect
# set some openejb flags
openejb.jndiname.format = {ejbName}/{interfaceClass}
openejb.descriptors.output = true
openejb.validation.output.level = verbose
---------------------
Hope this helps!
-David
On Jun 22, 2009, at 2:19 PM, Gul Onural wrote:
I use openejb in intravm mode. I thought it was called embedded mode.
So, I have created an embedded.logging.properties under
src/test/resources and here is the output, but I am not sure it gives
anything to help me understand the issue.
Can anyone see something to help understanding the jndi lookup issue
here ?
Gul
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running provision.samplestateless.impl.SampleStatelessTest
DEBUG - Using default 'openejb.nobanner=true'
Apache OpenEJB 3.1.1 build: 20090530-06:18
http://openejb.apache.org/
INFO -
************************************************************************
********
OpenEJB http://openejb.apache.org/
Startup: 6/22/09 5:02 PM
Copyright 1999-2008 (C) Apache OpenEJB Project, All Rights Reserved.
Version: 3.1.1
Build date: 20090530
Build time: 06:18
************************************************************************
********
DEBUG - Using default
'openejb.assembler=org.apache.openejb.assembler.classic.Assembler'
DEBUG - Instantiating assembler class
org.apache.openejb.assembler.classic.Assembler
DEBUG - Using default 'openejb.jndiname.failoncollision=true'
DEBUG - Using default
'openejb.configurator=org.apache.openejb.config.ConfigurationFactory'
DEBUG - Using default 'openejb.validation.skip=false'
DEBUG - Using default 'openejb.deploymentId.format={ejbName}'
DEBUG - Using default 'openejb.debuggable-vm-hackery=false'
DEBUG - Using default 'openejb.webservices.enabled=true'
DEBUG - Using default 'openejb.vendor.config=geronimo, glassfish,
jboss,
weblogic' Possible values are: geronimo, glassfish, jboss, weblogic
INFO - Cannot find the configuration file [conf/openejb.xml]. Will
attempt to create one for the beans deployed.
DEBUG - Using default
'openejb.provider.default=org.apache.openejb.embedded'
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
DEBUG - Using default 'openejb.deployments.classpath=true'
DEBUG - Using default 'openejb.deployments.classpath.include='
DEBUG - Using default 'openejb.deployments.classpath.exclude=.*'
DEBUG - Using default
'openejb.deployments.classpath.require.descriptor=false'
DEBUG - Using default
'openejb.deployments.classpath.filter.descriptors=false'
DEBUG - Using default
'openejb.deployments.classpath.filter.systemapps=true'
DEBUG - Inspecting classpath for applications: 0 urls.
DEBUG - URLs after filtering: 017
INFO - Using 'openejb.deployments.classpath.ear=true'
INFO - Configuring enterprise application: classpath.ear
DEBUG - Using default 'openejb.descriptors.output=false'
INFO - Using 'openejb.validation.output.level=VERBOSE'
INFO - Enterprise application "classpath.ear" loaded.
INFO - Creating TransactionManager(id=Default Transaction Manager)
DEBUG - defaultTransactionTimeoutSeconds=600
DEBUG - TxRecovery=false
DEBUG - bufferSizeKb=32
DEBUG - checksumEnabled=true
DEBUG - adler32Checksum=true
DEBUG - flushSleepTimeMilliseconds=50
DEBUG - logFileDir=txlog
DEBUG - logFileExt=log
DEBUG - logFileName=howl
DEBUG - maxBlocksPerFile=-1
DEBUG - maxBuffers=0
DEBUG - maxLogFiles=2
DEBUG - minBuffers=4
DEBUG - threadsWaitingForceThreshold=-1
DEBUG - createService.success
INFO - Creating SecurityService(id=Default Security Service)
INFO - Assembling app: classpath.ear
DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible
values are: none, annotations, enums
INFO - Deployed Application(path=classpath.ear)
DEBUG - Containers : 0
DEBUG - Deployments : 0
DEBUG - SecurityService :
org.apache.openejb.core.security.SecurityServiceImpl
DEBUG - TransactionManager:
org.apache.geronimo.transaction.manager.GeronimoTransactionManager
DEBUG - OpenEJB Container System ready.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.266
sec <<< FAILURE!
Results :
Tests in error:
testSampleStatelessRemoteInterface
(generic.samplestateless.impl.SampleSt
atelessTest)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
-----Original Message-----
From: David Blevins [mailto:[email protected]]
Sent: Monday, June 22, 2009 4:58 PM
To: [email protected]
Subject: Re: jndi lookup
Should be printed to System.out.
The output should look similar to the log lines at the end of this
example: http://openejb.apache.org/3.0/simple-stateless-example.html
-David
On Jun 22, 2009, at 1:36 PM, Gul Onural wrote:
I am using openejb in embedded configuration. Where is the
openejb.log
populated in embedded configuration ?
I don't see that file anywhere in my environment.
Gul
-----Original Message-----
From: Jean-Louis MONTEIRO [mailto:jean-
[email protected]]
Sent: Monday, June 22, 2009 4:33 PM
To: [email protected]
Subject: Re: jndi lookup
Hi,
can you give us the openejb.log file ?
If you cannot lookup the session bean, either the bean name is wrong
either
a deployment error prevented openejb to publish anything.
thanks,
Gul Onural wrote:
I am trying to get the jndi lookup working with openejb for a test
class. The test class is very simple. I don't use any jndi
formatting,
and using the default.
However my test case is failing when in the JNDI lookup. I set the
openejb.validation.output.level to VERBOSE, but it doesn't really
show
anything
to help me to understand the issue.
I am using Junit 4.5 and openejb 3.1.1. In my test class setUp
method
:
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
properties.setProperty("openejb.validation.output.level",
"VERBOSE");
properties.setProperty("openejb.deployments.classpath", "true");
initialContext = new InitialContext(properties);
In a test method in my test class:
Object object =
initialContext.lookup("SampleStatelessBeanRemote");
assertNotNull(object);
assertTrue(object instanceof SampleStatelessRemote);
SampleStatelessRemote ssr = (SampleStatelessRemote) object;
assertEquals("Hello from Sample Stateless Session Bean",
ssr.echo());
The SessionBean (SampleStatelessBean) uses annotations and based on
my
understanding from the documentation, iopenejb looks into the
class
path and discovers
annotations. My session bean remote and local interfaces as well as
bean
implementation classes are in test classpath. The session bean
doesn't
use
any annotation properties such as name or mappedName.
Stack trace is below.
Is there anything else I can do to debug the issue ? How can I get
more
debug log from the openejb to further debug this ?
Gul
------------------------------------------------------------------------
-------
Test set: generic.samplestateless.impl.SampleStatelessTest
------------------------------------------------------------------------
-------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
1.922
sec <<< FAILURE!
testSampleStatelessRemoteInterface
(generic.samplestateless.impl.SampleSt
atelessTest) Time elapsed: 1.796 sec <<< ERROR!
javax.naming.NameNotFoundException: Name
"SampleStatelessBeanRemote"
not
found.
at
org
.apache
.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:1
98)
at
org
.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:
155
)
at
org
.apache
.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.
java:115)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
generic
.samplestateless.impl.SampleStatelessTest.testSampleStatelessRemo
teInterface(SampleStatelessTest.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMet
hod.java:44)
at
org
.junit
.internal.runners.model.ReflectiveCallable.run(ReflectiveCallab
le.java:15)
at
org
.junit
.runners.model.FrameworkMethod.invokeExplosively(FrameworkMetho
d.java:41)
at
org
.junit
.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod
.java:20)
at
org
.junit
.internal.runners.statements.RunBefores.evaluate(RunBefores.jav
a:28)
at
org
.junit
.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org
.junit
.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner
.java:73)
at
org
.junit
.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner
.java:46)
at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at
org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org
.junit
.internal.runners.statements.RunBefores.evaluate(RunBefores.jav
a:28)
at
org
.junit
.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org
.apache
.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.jav
a:62)
at
org
.apache
.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSe
t(AbstractDirectoryTestSuite.java:140)
at
org
.apache
.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Abstr
actDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org
.apache
.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Suref
ireBooter.java:345)
at
org
.apache
.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
:1009)
---------------------------------------------------------------------
This transmission (including any attachments) may contain
confidential
information, privileged material (including material protected by
the
solicitor-client or other applicable privileges), or constitute
non-public
information. Any use of this information by anyone other than the
intended
recipient is prohibited. If you have received this transmission in
error,
please immediately reply to the sender and delete this information
from
your system. Use, dissemination, distribution, or reproduction of
this
transmission by unintended recipients is not authorized and may be
unlawful.
-----
Jean-Louis
--
View this message in context:
http://www.nabble.com/jndi-lookup-tp24154795p24154888.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
---------------------------------------------------------------------
This transmission (including any attachments) may contain
confidential information, privileged material (including material
protected by the solicitor-client or other applicable privileges),
or constitute non-public information. Any use of this information by
anyone other than the intended recipient is prohibited. If you have
received this transmission in error, please immediately reply to the
sender and delete this information from your system. Use,
dissemination, distribution, or reproduction of this transmission by
unintended recipients is not authorized and may be unlawful.
---------------------------------------------------------------------
This transmission (including any attachments) may contain
confidential information, privileged material (including material
protected by the solicitor-client or other applicable privileges),
or constitute non-public information. Any use of this information by
anyone other than the intended recipient is prohibited. If you have
received this transmission in error, please immediately reply to the
sender and delete this information from your system. Use,
dissemination, distribution, or reproduction of this transmission by
unintended recipients is not authorized and may be unlawful.
---------------------------------------------------------------------
This transmission (including any attachments) may contain
confidential information, privileged material (including material
protected by the solicitor-client or other applicable privileges),
or constitute non-public information. Any use of this information by
anyone other than the intended recipient is prohibited. If you have
received this transmission in error, please immediately reply to the
sender and delete this information from your system. Use,
dissemination, distribution, or reproduction of this transmission by
unintended recipients is not authorized and may be unlawful.