Using @Inject to inject one EJB into another sometimes causes exceptions when EJBContainer is closed

2012-03-15 Thread afryer
Recently when shutting down TomEE (4.0.0-beta2) I have been getting the
following exception...

SEVERE: Exception thrown while destroying bean instance : [Stateless2,
Name:null, WebBeans Type:ENTERPRISE, API
Types:[openejb.ejbs.Stateless2Service,java.lang.Object],
Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
java.lang.IllegalStateException: Bean 'Stateless2' has been undeployed.

The problem seems to be related to the use of the @Inject annotation and
doesn't happen if @EJB is used instead.  

I have created a test case to duplicate the error.  The classes are below...

@Local
public interface Stateless1Service {
public String toUpper(String input);
}

@Stateless
public class Stateless1 implements Stateless1Service {
// exception doesn't occur if @EJB is used here instead.
@Inject Stateless2Service stateless2;

@Override
public String toUpper(String input) {
return input.toUpperCase();
}
}

@Local
public interface Stateless2Service {
public String toLower(String input);
}

@Stateless
public class Stateless2 implements Stateless2Service {
@Override
public String toLower(String input) {
return input.toLowerCase();
}
}

@ManagedBean
public class OpenEjbContainerTest {

private EJBContainer ejbContainer;

@Inject Stateless1Service stateless1;

@Before
public void setUp() throws NamingException {
Properties p = new Properties();
p.put("openejb.deployments.classpath.include", ".*openejb.*");
p.put("openejb-test.openjpa.jdbc.SynchronizeMappings",
"buildSchema(ForeignKeys=false)");
ejbContainer = EJBContainer.createEJBContainer(p);
ejbContainer.getContext().bind("inject", this);
}

@After
public void cleanUp() {
if (ejbContainer != null) {
// Exception is thrown here
ejbContainer.close();
}
}

@Test
public void testToUpper() {
System.out.println("Testing toupper()...");
System.out.println("ToUpper of hello is " + 
stateless1.toUpper("hello"));
}
}



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Using-Inject-to-inject-one-EJB-into-another-sometimes-causes-exceptions-when-EJBContainer-is-closed-tp4474463p4474463.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Findings from moving a Tomcat 7.0.26 app to TomEE beta 1.0.0 plus

2012-02-27 Thread afryer
I had an issue with JSPs failing to recompile with 4.0.0-beta1 described 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-lt-development-gt-parameter-value-td4213081.html#a4216277
here .  The issue was caused by openejb overwriting the web.xml file with
its own version so no matter what values you changed, they were overwritten. 
This is fixed in beta2.

For the datasource, you can always deploy a META-INF/resources.xml with you
app to have openejb create Jta managed datasources that get used by
persistence units.



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Findings-from-moving-a-Tomcat-7-0-26-app-to-TomEE-beta-1-0-0-plus-tp4423955p4426616.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Configuring Data Source per Application

2012-02-23 Thread afryer
You can do this by creating META-INF/resources.xml file in your project.  An
example of the content of the resources.xml file is this...



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Configuring-Data-Source-per-Application-tp4414282p4415790.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openEJB fail on second test

2012-02-19 Thread afryer
Amber, that sounds really similar to the issue i just had described 
http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-td4396189.html
here .  In my case i had an ejb container instantiated just once and reused
across test cases which sounds similar to your issue.

The fix for me was to upgrade to use openejb 4.0.0-beta-2 and use the
@ManagedBean annotation on my test case classes.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openEJB-fail-on-second-test-tp4401889p4402907.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Injection fails in any class that didn't instantiate an embedded ejb container

2012-02-17 Thread afryer
Just upgraded to beta-2 and now @ManagedBean works.  I had to change the
context I was binding to, to get this to work.

Using @LocalClient i had to bind using this code...



Using @ManagedBean i have to bind like this...



That difference doesn't bother me at all.  Just putting it here for
reference in case other people have the same issue.  

Now using @ManagedBean the @Inject annotation is working :)

The upgrade to beta-2 is gold.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4397187.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Injection fails in any class that didn't instantiate an embedded ejb container

2012-02-17 Thread afryer
I'm using openejb-core 4.0.0-beta-1 for my test cases.

I was using @javax.annotation.ManagedBean but i haven't managed to get it to
work yet.  I'll keep trying tomorrow though.

I was aware that creating and destroying an EJBContainer per test case
removed the need for any annotations such as @ManagedBean or @LocalClient
but it also slows down the test case execution significantly.  I only have
stateless ejbs and so don't need to recreate the container for each test
case class.  I do have a DataSource resource created in the ejb container
but i blow away and rebuild the schema and repopulate it with data before
each test case rather than recreating the entire embedded ejb container.

Now that I have this working using @LocalClient, my test cases run
significantly faster, so i'm happy with the outcome.  I still wish it was
possible to inject using the @Inject annotation.  After reading your reply
saying @Inject should be possible, i retested it but it doesn't work. 
Nothing gets injected and i end up with NullPointerExceptions.

I'm sure there's a very good reason you can't inject into any class instance
that isn't annotated with @LocalClient or @ManagedBean .  Could anyone tell
me what it is because its something i've found myself wanting to do on a
couple of occasions now but always get thwarted by the "could not find meta
data" exception.  For example, i created a Servlet test case using HttpUnit
and i wanted to inject ejbs from an embedded tomee container into an
instance of a servlet that i created, but couldn't.


--
View this message in context: 
http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4397059.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Injection fails in any class that didn't instantiate an embedded ejb container

2012-02-17 Thread afryer
I didn't know about the @ManagedBean annotation. I got it to work using the
@LocalClient annotation and creating an empty
META-INF/application-client.xml file.  What's the difference between
@ManagedBean and @LocalClient?  I just tried using @ManagedBean but i still
got the same error as before (could not find meta data...).  

I did find that using @LocalClient i couldn't inject into my test case
classes using the @Inject annotation.  I had to use @EJB instead.  

--
View this message in context: 
http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396984.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Injection fails in any class that didn't instantiate an embedded ejb container

2012-02-16 Thread afryer
I am writing unit test cases for a group of stateless session ejbs and to
speed up test case execution, I want to create the embedded ejb container
once and use it across all the test case classes.  

An example of my test case structure is shown below.  Assuming MyFirstTest
runs first, then the injection will work for MyFirstTest.  The problem is
the injection fails for MySecondTest with the "Unable to find injection
meta-data for..." error message.  Why does the injection work in the class
that actually causes the EJBContainer to be instantiated and not in any
other class?





--
View this message in context: 
http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396189.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



javax.mail.Session resource and smtp authentication

2012-01-23 Thread afryer
i just wanted to check that i'm doing the right thing in regards to using a
javax.mail.Session resource with openejb.

I have a mail session resource configured as follows...



Initially i was confused by the documentation about what name should be used
for the password field (ie. password or mail.smtp.password) but now my
understanding is that it doesn't matter what it is called because it isn't
actually used by openejb.  

Is it correct that the password property is just configured with the
resource so you can access it later from the mail session to do the
authentication yourself?  In other words, is it true that openejb won't
setup the mail session to do authentication automatically and you have to
code the authentication yourself?

I ended up having the following code in a stateless ejb to set the mail
session up to do authentication.  Am i on the right track?  I thought it
would be nice if openejb set the mail session up to do the authentication
automatically.





--
View this message in context: 
http://openejb.979440.n4.nabble.com/javax-mail-Session-resource-and-smtp-authentication-tp4322915p4322915.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: How can i propagate security context from servlet layer to embedded openejb

2011-12-29 Thread afryer
I usually use container provided security, like a tomcat DataSourceRealm.  In
my application i programatically log the user on using the new
HttpServletRequest login method.  Lately I've started using openejb in
embedded mode, particularly when testing.  I am testing frameworks like
spring-test-mvc and ServletUnit where you can specify users and their roles
when invoking test cases.

I started wondering if a servlet filter could be created that would create a
new openejb InitialContext(), combined with a SecurityService that held a
reference to an HttpServletRequest so it could use the getUserPrincipal()
and isUserInRole() methods of the HttpServletRequest object in the ejb
context.  Maybe it could be called a ServletSecurityService or something,
that could be used for testing.  Its not really jaas or jacc.  I'm not sure
if there's another way to get the security context the same across servlets
and ejbs without using container specific adapters.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/How-can-i-propagate-security-context-from-servlet-layer-to-embedded-openejb-tp4241313p4242200.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: How can i propagate security context from servlet layer to embedded openejb

2011-12-28 Thread afryer
I just read it but don't know if it is relevent because in my code I don't do
lookups of the ejbs.  They are automatically injected into the spring
context, so i never have to explicitely get an InitialContext().

I'm looking at the SecurityService documentation and wonder if a new
SecurityService might be the way to go.  Would it be possible to create a
SecurityService that uses the Servlet request to get the username and roles? 
Something that was independant of the actual servlet container used, so it
didn't matter if it was tomcat, jetty, weblogic etc. because it only used
the servlet api?  Would this be possible?

--
View this message in context: 
http://openejb.979440.n4.nabble.com/How-can-i-propagate-security-context-from-servlet-layer-to-embedded-openejb-tp4241313p4241392.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


How can i propagate security context from servlet layer to embedded openejb

2011-12-28 Thread afryer
Up to now, i have run my webapp in a tomee instance which has openejb
integrated at the container level.  Using it this way the security context
is seamlessly transferred between the servlet layer and the ejbs, so the
user and roles are the same all the way through.

Recently I have been testing my webapp using openejb in embedded mode with
spring.  I'm now finding that my user has a security context in the servlet
layer, but in the ejbs it has a principal username of "guest".

Is there some special configuration required when using openejb in embedded
mode, to propagate the security context from the servlet layer to the
embedded openejb layer? 

My spring servlet-context.xml file is below...



--
View this message in context: 
http://openejb.979440.n4.nabble.com/How-can-i-propagate-security-context-from-servlet-layer-to-embedded-openejb-tp4241313p4241313.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-20 Thread afryer
That fixed my issue.  I can now modify jsps and view the modifications
immediately in my browser.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4220220.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


tomee increased memory consumption

2011-12-20 Thread afryer
I have a linux virtual server with only 512M of Ram, running my app that uses
a build of tomee from around July or September this year (I can give
specifics if required).  The java process uses about 300M of Ram with this
version of tomee.  Last night I downloaded
apache-tomee-1.0.0-beta-1-webprofile.tar.gz and tried running my app inside
of it but couldn't because I ran out of memory.  It seems something has
changed that uses significantly more memory than before (> 100M more).  I
haven't investigated exactly what this could be at this stage.  I'm just
wondering if the dev guys are aware of something that might cause this to
happen?

On a related note, if I'm not using components, like JSF, is it easy to
remove that from the tomee stack?  Is it just a case of removing the jar
files?

--
View this message in context: 
http://openejb.979440.n4.nabble.com/tomee-increased-memory-consumption-tp4219667p4219667.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-19 Thread afryer
Whats the link to the snapshot build?  I'm after either the openejb war file
or tomee.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4216277.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-19 Thread afryer
lol

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4216227.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-19 Thread afryer
Thanks for that.  I always wondered why I couldn't modify JSPs without a
server reboot before but always thought it was my eclipse settings or
something.  Glad to have finally worked it out.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4216038.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-18 Thread afryer
I tried it outside of eclipse, with a clean tomee install.  I when edited
conf/web.xml, changed the *development* value to true, booted up tomee and
it gets changed back to false.  Doesn't make any difference if i use a
javaagent or not.  

How can I configure JspServlet to be in development mode when using openejb?

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4213190.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


openejb overwrites tomcat conf/web.xml JspServlet parameter value

2011-12-18 Thread afryer
I'm using eclipse wtp for development and have a tomee server setup for
testing my code changes.  When I publish changes and start my server, the
JSPs display fine.  The problem is, if I modify a JSP and it gets published,
I can't see the changes unless I completely restart the server.

I discovered the configuration of the org.apache.jasper.servlet.JspServlet
in web.xml for tomee has the *development* parameter value explicitely set
to *false*.  I changed that to *true* in my web.xml thinking I'd solved my
problem.  I published my change and verified the web.xml in the wtp folder
(.metadata/.plugins/org.eclipse.wst.server.core/tmp1/conf/web.xml).  It
looked right because *development* was now set to *true*.  Then I started
the server from eclipse and a strange thing happened.  The *development*
parameter magically went back to being *false*.

I couldn't work out how this happened.  I downloaded a clean tomcat 7.23
instance, created the server and tested again.  It was fine and the
JspServlet could be run in development mode.  I then just added the openejb
module to this server and then every time i started the server, development
mode got set to false.

My conclusion is that openejb wont let you run the JspServlet in development
mode.  Is this true and if so, why?

--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-overwrites-tomcat-conf-web-xml-JspServlet-development-parameter-value-tp4213081p4213081.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: tomee-embedded test case best practice?

2011-11-29 Thread afryer
After much head banging I managed to work out how to create an almost
identical war file to deploy using arquillian.  I'm posting the code here
because I found it pretty difficult to work out how to do this...

@Deployment
public static WebArchive createTestArchive() {
WebArchive war = ShrinkWrap.create(WebArchive.class, 
"test.war");

// adds every dependency from the pom.xml with a scope of 
compile
war.addAsLibraries(
DependencyResolvers
.use(MavenDependencyResolver.class)
.includeDependenciesFromPom("pom.xml")
.resolveAs(JavaArchive.class, new 
ScopeFilter("compile"))
);

// add any other jars in the src folder.  Could make this 
generic.
war.addAsLibrary(new
File("src/main/webapp/WEB-INF/lib/jquery-ui-1.8.9.jar"));

// adds everything in target/classes to the war file 
WEB-INF/classes
folder
war.addAsResource(new File("target/classes"), "");

// add everything in /src/main/webapp but filter out .svn 
directory
JavaArchive webappFolder = ShrinkWrap.create(JavaArchive.class,
"webappFolder.jar");

webappFolder.as(ExplodedImporter.class).importDirectory("src/main/webapp");
war.merge(webappFolder, "", new Filter() {
@Override
public boolean include(ArchivePath ap) {
String path = ap.get();
return (!path.contains(".svn") && 
!path.contains("context.xml"));
}

});

// uncomment this if you want to examine the war file
//war.as(ZipExporter.class).exportTo(new File("test.war"));

return war;
}

--
View this message in context: 
http://openejb.979440.n4.nabble.com/tomee-embedded-test-case-best-practice-tp4117711p4122164.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


tomee-embedded test case best practice?

2011-11-28 Thread afryer
I'm currently trying to setup automated integration testing of my webapp
which uses ejbs and have been looking at some of the arquillian examples 
https://svn.apache.org/repos/asf/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun
here .

It looks like there's a couple of ways to startup an embedded tomee server
and i was wondering if any way was preferrable to another.

In MoviesHtmlUnitTest.java, the tomee server is started without arquillian
using this code...

@BeforeClass public static void start() throws IOException {
webApp = createWebApp();
Properties p = new Properties();
p.setProperty(EJBContainer.APP_NAME, "moviefun");
p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web
feature
p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT,
"");
container = EJBContainer.createEJBContainer(p);
}

In MoviesSeleniumTest.java, the tomee server is started like this...

@Deployment(testable = false)
public static WebArchive createDeployment() {
WebArchive archive = ShrinkWrap.create(WebArchive.class,
"moviefun.war")
.addClasses(ActionServlet.class, SetupServlet.class, 
Movie.class,
MovieController.class, Movies.class, MoviesImpl.class, MoviesRemote.class,
JsfUtil.class, PaginationHelper.class, ExampleDataProducer.class,
Examples.class, Setup.class)
.addAsResource(new 
ClassLoaderAsset("META-INF/ejb-jar.xml") ,
"META-INF/ejb-jar.xml")
.addAsResource(new 
ClassLoaderAsset("META-INF/persistence.xml") ,
"META-INF/persistence.xml")
.addAsLibraries(new
File("target/test-libs/commons-beanutils.jar"),
new 
File("target/test-libs/commons-codec.jar"),
new 
File("target/test-libs/commons-collections.jar"),
new 
File("target/test-libs/commons-digester.jar"),
new 
File("target/test-libs/commons-logging.jar"),
new File("target/test-libs/jstl.jar"),
new File("target/test-libs/log4j.jar"),
new 
File("target/test-libs/standard.jar"));

addResources("src/main/webapp", "", archive);
System.out.println(archive.toString(true));
return archive;
}

The first way looks simpler to me, but I'm wondering if I'm missing some
benefit provided by the arquillian way.

Also is there an easy way to just use the .war file created in the target
folder and have that deployed in tomee-embedded.  Programmatically creating
the archive seems like hard work to me if the war file has already been
created, but again being new to all this, i could have easily missed the
point.  I also don't get why you have to manually copy the dependent jars
when you have already specified the jars you need in your maven depedencies. 
This is probably more arquillian related questions than openejb questions
but appreciate any directions or tips i can get since i know openejb dev
guys are working on this sort of integration testing capability.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/tomee-embedded-test-case-best-practice-tp4117711p4117711.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Should javax.mail api be included in javaee-api 6.0-2?

2011-11-27 Thread afryer
I have a test case in a project that uses javax.mail that uses embedded
openejb (openejb-core 4.0.0-beta-1).  I found that to get openejb to work in
the test case, I had to change my maven dependencies from using
javax:javaee-web-api:6.0 to use org.apache.openejb:javaee-api:6.0-2.  I then
discovered that this no longer included the javax.mail api, so my build
started failing.

I tried adding the standard javax.mail:mail:1.4.4 dependency, but then
embedded openejb couldn't create the default mail session, so I eventually
ended up using geronimo-javamail_1.4_mail which got everything working
again.

My question is, shouldn't the javaee-api:6.0-2 already include the
javax.mail api?

--
View this message in context: 
http://openejb.979440.n4.nabble.com/Should-javax-mail-api-be-included-in-javaee-api-6-0-2-tp4113924p4113924.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Accessing an EJB by name from a servlet init method fails in collapsed ear if is specified for the servlet

2011-08-30 Thread afryer
I just tested the snapshot build with my app, and you did fix it.  Nice work.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/Accessing-an-EJB-by-name-from-a-servlet-init-method-fails-in-collapsed-ear-if-load-on-startup-is-spet-tp3604528p3780272.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Accessing an EJB by name from a servlet init method fails in collapsed ear if is specified for the servlet

2011-08-07 Thread afryer
Can you refer me to the spec where it says the environment naming context
should not be accessible in callbacks like @PostConstruct?  I'm searching
through the javaee_platform_6_0-fr-spec.pdf and servlet-3_0-pfd-spec.pdf and
can't find mention of that.  In fact i think it says @PostConstruct gets
called when after the class constructor and after all resources have been
injected, implying that the environment naming context would be populated at
that point.  Although its possible i'm missing something because I haven't
read the spec with a fine tooth comb and it doesn't seem to explicitely
detail the lifecycle, my impression is that the environment should be
populated before the servlet init method is called.

javaee_platform-6_0-fr-spec.pdf...


> *EE.5.3.4 Java EE Product Provider’s Responsibilities*
> The Java EE Product Provider has the following responsibilities:
> ...
> •Implement the java:comp, java:module, java:app and java:global
> environment naming contexts, and provide them to the application component
> instances at runtime. The naming context must include all the entries
> declared by the Application Component Provider, with their values supplied
> in the deployment descriptor or set by the Deployer. The environment
> naming context must allow the Deployer to create subcontexts if they are
> needed by an application component. Certain entries in the naming context
> may have to be initialized with the values of other entries, specifically
> when the “lookup” facility is used. In this case, it is an error if there
> are any circular dependencies between entries. Similarly, it is an error
> if looking up the specified JNDI name results in a resource whose type is
> not compatible with the entry being created. The deployment tool may allow
> the deployer to correct either of these classes of errors and continue the
> deployment.
> 

--
View this message in context: 
http://openejb.979440.n4.nabble.com/Accessing-an-EJB-by-name-from-a-servlet-init-method-fails-in-collapsed-ear-if-load-on-startup-is-spet-tp3604528p3726049.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: missing required persistence.xml (apache-tomee-tomcat-7.0.6-3.2-SNAPSHOT)

2011-06-21 Thread afryer
I just did an svn update on the trunk and rebuilt tomee to make sure i had
the latest changes.  I'm still getting this problem.  The error i'm seeing
in openejb.log is

2011-06-22 10:22:00,042 - ERROR - FAIL ... TournamentImpl:  Missing required
persistence.xml for @PersistenceContext ref "entityManager" to unit
"poker-entities"

This looks to me like openejb is trying to create the Stateless session ejb
TournamentImpl but is failing because it can't inject the entityManager
because it doesn't exist.  

I have structured my webapp such that my entity beans are contained in a jar
file (poker-entities.jar) and my stateless session ejbs are contained in
another jar file (poker-ejbs.jar), both jars contained in the WEB-INF/lib
folder of my web application (war file).  In my poker-entities.jar file i
have a persistence.xml file in the META-INF folder.  It seems like openejb
is not finding this persistence.xml in my jar file anymore or its finding
the ejb jar first and trying to instantiate it before it got to the entity
jar file.  I say "anymore" because it used to work with an earlier version
of openejb that i built from the trunk ages ago (around December or
January).  I tried renaming my jar files so the entity jar file would be
first when ordered by name but it didn't make any difference.

To work around this problem, i have to put a persistence.xml file in the
META-INF folder of the web application war file and use the 
element in that persistence.xml to specify the
WEB-INF/lib/poker-entities.jar.  This works ok but is not ideal.  I would
like to be able to go back to having openejb automatically find the
poker-entities.jar file in WEB-INF/lib and create the entity manager that
way.






--
View this message in context: 
http://openejb.979440.n4.nabble.com/missing-required-persistence-xml-apache-tomee-tomcat-7-0-6-3-2-SNAPSHOT-tp3329814p3615730.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: missing required persistence.xml (apache-tomee-tomcat-7.0.6-3.2-SNAPSHOT)

2011-06-20 Thread afryer
I've just come across this problem in the trunk build.  Hope this gets fixed
soon.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/missing-required-persistence-xml-apache-tomee-tomcat-7-0-6-3-2-SNAPSHOT-tp3329814p3613276.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Accessing an EJB by name from a servlet init method fails in collapsed ear if is specified for the servlet

2011-06-16 Thread afryer
I have a war file that contains 2 jar files in WEB-INF/lib, one for entity
beans and one for stateless session ejbs (ie. collapsed ear file).

I am deploying this war file to tomcat + openejb.  In one of my servlets, I
want to access one of the stateless session ejbs in the init() method of the
servlet.  So in my web.xml I have the following declaration where the
stateless session EJB (com.pokersquid.poker.ejbs.PaymentSettingLocal) is
contained in one of the jar files in WEB-INF/lib...

< !-- fragment of web.xml -->


  PaymentSettingLocal
  Session
  com.pokersquid.poker.ejbs.PaymentSettingLocal


Now if I don't specify the  value on my servlet, everything
works fine.  It CAN access the ejb by doing a name lookup on
"java:comp/env/PaymentSettingLocal" because the servlet is only initialized
when the first request for it happens, which is after all the ejbs have been
initialized and named in the jndi tree.

The problem occurs when I want to specify
1 for the servlet.  In that case, there
is nothing in the jndi tree at that point.  It looks like the jndi is only
populated AFTER the container creates servlets.

I have verified this by creating a servlet that prints out the jndi tree in
its init() method and also in the doGet() method.  If i configure this
servlet to load-on-startup, the init() method prints out nothing, but when I
subsequently call the doGet method, the jndi tree IS populated with the
names I have configured using  in the web.xml.

Therefore my question is, should it be possible to access an EJB from the
init() method of a servlet when the servlet is configured to
load-on-startup?  



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Accessing-an-EJB-by-name-from-a-servlet-init-method-fails-in-collapsed-ear-if-load-on-startup-is-spet-tp3604528p3604528.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: collapsed ear ejb and web application load order

2011-05-26 Thread afryer
Found the issue.  The problem was i didn't specify the .  So
this works...



  MyEjb
  Session
  com.acme.MyEjbLocal


--
View this message in context: 
http://openejb.979440.n4.nabble.com/collapsed-ear-ejb-and-web-application-load-order-tp3465111p3554247.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


collapsed ear ejb and web application load order

2011-04-20 Thread afryer
I have tomcat + openejb and am deploying a collapsed ear (war) file that has
2 jars in WEB-INF/lib for the JPA entities and Stateless Session EJBs.

I have just been trying to access one of the EJBs from my web application
and I wanted to put in a local ejb reference in my web.xml as follows...


MyEjb
com.acme.MyEjbLocal


When I put this in web.xml, tomcat always fails to start because it can't
resolve the ejb reference to an actual ejb.  To work around this, I created
a servlet and used the @EJB annotation instead.  Having read the "Getting
Things" page in the documentation
(http://openejb.apache.org/3.0/basics-getting-things.html), I think the
 in web.xml should be identical to the @EJB annotation in a
servlet.  

I think what is going wrong is that the web.xml is being processed and the
context is being setup BEFORE openejb kicks in and creates the EJBs.  The
reason the servlet works is probably because the annotations are processed
AFTER openejb has created the EJBs (note this is only a guess on my part so
could be completely wrong).

In other words what I think is happening is this...

1/ tomcat looks at web.xml, initializes servlets and filters and resolves
resource and ejb references
2/ tomcat+openejb parses jar files in WEB-INF/lib to create ejbs
3/ tomcat+openejb annotation parser does dependency injection and creates
EJB references in the local context.

What I think should happen is 

1/ tomcat+openejb parses jar files in WEB-INF/lib to create ejbs
2/ tomcat looks at web.xml, initializes servlets and filters and resolves
resource and ejb references
3/ tomcat+openejb annotation parser does dependency injection and creates
EJB references in the local context.


--
View this message in context: 
http://openejb.979440.n4.nabble.com/collapsed-ear-ejb-and-web-application-load-order-tp3465111p3465111.html
Sent from the OpenEJB User mailing list archive at Nabble.com.