You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by David Goodenough <da...@linkchoose.co.uk> on 2015/04/06 16:19:42 UTC
jax-rs packaging question
I have a JAX-RS application, and if I can I want to use the no-xml
configuration with annotations instead.
So I have written the main stateless EJB with @Path, which
has an @POST annotated method on it, and a second class
derived from Application which has an @ApplicationPath annotation.
The Application has an overridden method:-
@Override public Set<Class<?>>getClasses() {
Set<Class<?>>s = new HashSet<Class<?>>();
s.add(Ejb.class);
return s;
}
I then put the whole lot in a war file which contains just those
classes and a few others that I reference from the @POST method.
They all make reference to libraries that are in the {tomee}/lib
directory. In the war file is also a persistence.xml which defines
the postgresql driver and the JDBC connection info (the driver is
included in the war file)
I finally put the war file in its own directory in the webapps directory
and start tomee (using bin/startup.sh).
In the log file I get information which seems to say that it has
found everything:-
INFO - REST Application: http://localhost:8080/test/* ->
uk.co.dga.test.App
INFO - Service URI: http://localhost:8080/test/ejb -> EJB
uk.co.dga.test.Ejb
INFO - POST http://localhost:8080/test/ejb/ -> Reply
process(JAXBElement<Request>)
So it seems to have found both classes.
Then however is starts to complain:-
SEVERE - Error waiting for multi-thread deployment of directories to complete
java.util.concurrent.ExecutionException: java.lang.InternalError:
LocalBeanProxyFactory.createProxy: java.lang.reflect.InvocationTargetException
and a whole stack trace ending with as the inner most part:-
Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
at
org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186)
at
org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
... 26 more
How can it have found it and not found it?
David
Re: jax-rs packaging question
Posted by David Goodenough <da...@linkchoose.co.uk>.
One other thing which I suppose might be relevant, I compiled
this with java-8. So I suppose one of the classloaders might
not be loading the new class file format properly?
David
On Monday 06 April 2015 16:35:22 David Goodenough wrote:
> No static blocks in the code. Here is a really basic test:-
>
> RestApp.java
>
> package uk.co.dga.test;
>
> import java.util.HashSet;
> import java.util.Set;
>
> import javax.ws.rs.ApplicationPath;
> import javax.ws.rs.core.Application;
>
> @ApplicationPath("/*")
> public class RestApp extends Application {
> @Override public Set<Class<?>>getClasses() {
> Set<Class<?>>s = new HashSet<Class<?>>();
> s.add(RestEjb.class);
> return s;
> }
> }
>
> RestEjb.java
>
> package uk.co.dga.test;
>
> import javax.ejb.Stateless;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
>
> @Stateless
> @Path("/test")
> public class RestEjb {
> @POST
> @Produces(MediaType.TEXT_PLAIN)
> public String process() {
> return "Hello World";
> }
> }
>
> and the file structure in webapps/test is:-
>
> webapps/test/
>
> |-- HelloWorld
> |
> | |-- META-INF
> | |
> | | `-- MANIFEST.MF
> |
> | `-- WEB-INF
> |
> | |-- classes
> | |
> | | `-- uk
> | |
> | | `-- co
> | |
> | | `-- dga
> | |
> | | `-- test
> | |
> | | |-- RestApp.class
> | |
> | | `-- RestEjb.class
> |
> | `-- lib
>
> `-- HelloWorld.war
>
> David
>
> On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> > Hi
> >
> > Can it be a static block failing or something like that?
> >
> > Can you share a project showing it?
> > I have a JAX-RS application, and if I can I want to use the no-xml
> > configuration with annotations instead.
> >
> > So I have written the main stateless EJB with @Path, which
> > has an @POST annotated method on it, and a second class
> > derived from Application which has an @ApplicationPath annotation.
> > The Application has an overridden method:-
> >
> > @Override public Set<Class<?>>getClasses() {
> >
> > Set<Class<?>>s = new HashSet<Class<?>>();
> > s.add(Ejb.class);
> > return s;
> > }
> >
> > I then put the whole lot in a war file which contains just those
> > classes and a few others that I reference from the @POST method.
> > They all make reference to libraries that are in the {tomee}/lib
> > directory. In the war file is also a persistence.xml which defines
> > the postgresql driver and the JDBC connection info (the driver is
> > included in the war file)
> >
> > I finally put the war file in its own directory in the webapps directory
> > and start tomee (using bin/startup.sh).
> >
> > In the log file I get information which seems to say that it has
> > found everything:-
> >
> > INFO - REST Application: http://localhost:8080/test/* ->
> > uk.co.dga.test.App
> > INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> > uk.co.dga.test.Ejb
> > INFO - POST http://localhost:8080/test/ejb/ -> Reply
> > process(JAXBElement<Request>)
> >
> > So it seems to have found both classes.
> >
> > Then however is starts to complain:-
> >
> > SEVERE - Error waiting for multi-thread deployment of directories to
> > complete
> > java.util.concurrent.ExecutionException: java.lang.InternalError:
> > LocalBeanProxyFactory.createProxy:
> > java.lang.reflect.InvocationTargetException
> >
> > and a whole stack trace ending with as the inner most part:-
> >
> > Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> >
> > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186
> > )
> >
> > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> >
> > ... 26 more
> >
> > How can it have found it and not found it?
> >
> > David
Re: jax-rs packaging question
Posted by David Goodenough <da...@linkchoose.co.uk>.
On Monday 06 April 2015 21:58:51 Romain Manni-Bucau wrote:
> 2015-04-06 21:36 GMT+02:00 David Goodenough <
>
> david.goodenough@linkchoose.co.uk>:
> > Attached is the war file, which fails every time for me.
>
> I get a HTTP 200 + the good response string deploying your war.
Yes it does without the *, but it still throws the exception in
logs/catalina.out
>
> > The @Post method does have a body, all it does is return a string.
> >
> > I met the * somewhere online, I think on an oracle site. I will see if I
> > can
> > find it.
>
> I'm sure it is valid, just it is not handled in tomee:
> https://issues.apache.org/jira/browse/TOMEE-1542. That said not using a
> star is exactly the same.
I have removed it. With the * it does not, but as that should not be there
I will simply avoid it in the future.
David
>
> > David
> >
> > On Monday 06 April 2015 21:14:53 Romain Manni-Bucau wrote:
> > > Please provide a sample *reproducing* the error. This one doesnt + @POST
> > > without body doesn't make much sense.
> > >
> > > Side note: don't add a star at the end of @ApplicationPath mapping
> > > please
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> | Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> >
> > https://github.com/rmannibucau>
> >
> > > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > >
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-06 17:35 GMT+02:00 David Goodenough <
> > >
> > > david.goodenough@linkchoose.co.uk>:
> > > > No static blocks in the code. Here is a really basic test:-
> > > >
> > > > RestApp.java
> > > >
> > > > package uk.co.dga.test;
> > > >
> > > > import java.util.HashSet;
> > > > import java.util.Set;
> > > >
> > > > import javax.ws.rs.ApplicationPath;
> > > > import javax.ws.rs.core.Application;
> > > >
> > > > @ApplicationPath("/*")
> > > > public class RestApp extends Application {
> > > >
> > > > @Override public Set<Class<?>>getClasses() {
> > > >
> > > > Set<Class<?>>s = new HashSet<Class<?>>();
> > > > s.add(RestEjb.class);
> > > > return s;
> > > > }
> > > >
> > > > }
> > > >
> > > > RestEjb.java
> > > >
> > > > package uk.co.dga.test;
> > > >
> > > > import javax.ejb.Stateless;
> > > > import javax.ws.rs.POST;
> > > > import javax.ws.rs.Path;
> > > > import javax.ws.rs.Produces;
> > > > import javax.ws.rs.core.MediaType;
> > > >
> > > > @Stateless
> > > > @Path("/test")
> > > > public class RestEjb {
> > > >
> > > > @POST
> > > > @Produces(MediaType.TEXT_PLAIN)
> > > > public String process() {
> > > >
> > > > return "Hello World";
> > > > }
> > > >
> > > > }
> > > >
> > > > and the file structure in webapps/test is:-
> > > >
> > > > webapps/test/
> > > >
> > > > |-- HelloWorld
> > > > |
> > > > | |-- META-INF
> > > > | |
> > > > | | `-- MANIFEST.MF
> > > > |
> > > > | `-- WEB-INF
> > > > |
> > > > | |-- classes
> > > > | |
> > > > | | `-- uk
> > > > | |
> > > > | | `-- co
> > > > | |
> > > > | | `-- dga
> > > > | |
> > > > | | `-- test
> > > > | |
> > > > | | |-- RestApp.class
> > > > | |
> > > > | | `-- RestEjb.class
> > > > |
> > > > | `-- lib
> > > >
> > > > `-- HelloWorld.war
> > > >
> > > > David
> > > >
> > > > On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> > > > > Hi
> > > > >
> > > > > Can it be a static block failing or something like that?
> > > > >
> > > > > Can you share a project showing it?
> > > > > I have a JAX-RS application, and if I can I want to use the no-xml
> > > > > configuration with annotations instead.
> > > > >
> > > > > So I have written the main stateless EJB with @Path, which
> > > > > has an @POST annotated method on it, and a second class
> > > > > derived from Application which has an @ApplicationPath annotation.
> > > > > The Application has an overridden method:-
> > > > >
> > > > > @Override public Set<Class<?>>getClasses() {
> > > > >
> > > > > Set<Class<?>>s = new HashSet<Class<?>>();
> > > > > s.add(Ejb.class);
> > > > > return s;
> > > > > }
> > > > >
> > > > > I then put the whole lot in a war file which contains just those
> > > > > classes and a few others that I reference from the @POST method.
> > > > > They all make reference to libraries that are in the {tomee}/lib
> > > > > directory. In the war file is also a persistence.xml which defines
> > > > > the postgresql driver and the JDBC connection info (the driver is
> > > > > included in the war file)
> > > > >
> > > > > I finally put the war file in its own directory in the webapps
> >
> > directory
> >
> > > > > and start tomee (using bin/startup.sh).
> > > > >
> > > > > In the log file I get information which seems to say that it has
> > > > > found everything:-
> > > > >
> > > > > INFO - REST Application: http://localhost:8080/test/* ->
> > > > > uk.co.dga.test.App
> > > > > INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> > > > > uk.co.dga.test.Ejb
> > > > > INFO - POST http://localhost:8080/test/ejb/ ->
> >
> > Reply
> >
> > > > > process(JAXBElement<Request>)
> > > > >
> > > > > So it seems to have found both classes.
> > > > >
> > > > > Then however is starts to complain:-
> > > > >
> > > > > SEVERE - Error waiting for multi-thread deployment of directories to
> > > > > complete
> > > > > java.util.concurrent.ExecutionException: java.lang.InternalError:
> > > > > LocalBeanProxyFactory.createProxy:
> > > > > java.lang.reflect.InvocationTargetException
> > > > >
> > > > > and a whole stack trace ending with as the inner most part:-
> > > > >
> > > > > Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> > > > >
> > > > > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186
> >
> > > > )
> > > >
> > > > > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> >
> > > > > ... 26 more
> > > > >
> > > > > How can it have found it and not found it?
> > > > >
> > > > > David
> >
> > r
Re: jax-rs packaging question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
2015-04-06 21:36 GMT+02:00 David Goodenough <
david.goodenough@linkchoose.co.uk>:
> Attached is the war file, which fails every time for me.
>
>
I get a HTTP 200 + the good response string deploying your war.
> The @Post method does have a body, all it does is return a string.
>
> I met the * somewhere online, I think on an oracle site. I will see if I
> can
> find it.
>
>
I'm sure it is valid, just it is not handled in tomee:
https://issues.apache.org/jira/browse/TOMEE-1542. That said not using a
star is exactly the same.
> David
>
> On Monday 06 April 2015 21:14:53 Romain Manni-Bucau wrote:
> > Please provide a sample *reproducing* the error. This one doesnt + @POST
> > without body doesn't make much sense.
> >
> > Side note: don't add a star at the end of @ApplicationPath mapping please
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> | Blog
> > <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau>
> > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-06 17:35 GMT+02:00 David Goodenough <
> >
> > david.goodenough@linkchoose.co.uk>:
> > > No static blocks in the code. Here is a really basic test:-
> > >
> > > RestApp.java
> > >
> > > package uk.co.dga.test;
> > >
> > > import java.util.HashSet;
> > > import java.util.Set;
> > >
> > > import javax.ws.rs.ApplicationPath;
> > > import javax.ws.rs.core.Application;
> > >
> > > @ApplicationPath("/*")
> > > public class RestApp extends Application {
> > >
> > > @Override public Set<Class<?>>getClasses() {
> > >
> > > Set<Class<?>>s = new HashSet<Class<?>>();
> > > s.add(RestEjb.class);
> > > return s;
> > > }
> > >
> > > }
> > >
> > > RestEjb.java
> > >
> > > package uk.co.dga.test;
> > >
> > > import javax.ejb.Stateless;
> > > import javax.ws.rs.POST;
> > > import javax.ws.rs.Path;
> > > import javax.ws.rs.Produces;
> > > import javax.ws.rs.core.MediaType;
> > >
> > > @Stateless
> > > @Path("/test")
> > > public class RestEjb {
> > >
> > > @POST
> > > @Produces(MediaType.TEXT_PLAIN)
> > > public String process() {
> > >
> > > return "Hello World";
> > > }
> > >
> > > }
> > >
> > > and the file structure in webapps/test is:-
> > >
> > > webapps/test/
> > >
> > > |-- HelloWorld
> > > |
> > > | |-- META-INF
> > > | |
> > > | | `-- MANIFEST.MF
> > > |
> > > | `-- WEB-INF
> > > |
> > > | |-- classes
> > > | |
> > > | | `-- uk
> > > | |
> > > | | `-- co
> > > | |
> > > | | `-- dga
> > > | |
> > > | | `-- test
> > > | |
> > > | | |-- RestApp.class
> > > | |
> > > | | `-- RestEjb.class
> > > |
> > > | `-- lib
> > >
> > > `-- HelloWorld.war
> > >
> > > David
> > >
> > > On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> > > > Hi
> > > >
> > > > Can it be a static block failing or something like that?
> > > >
> > > > Can you share a project showing it?
> > > > I have a JAX-RS application, and if I can I want to use the no-xml
> > > > configuration with annotations instead.
> > > >
> > > > So I have written the main stateless EJB with @Path, which
> > > > has an @POST annotated method on it, and a second class
> > > > derived from Application which has an @ApplicationPath annotation.
> > > > The Application has an overridden method:-
> > > >
> > > > @Override public Set<Class<?>>getClasses() {
> > > >
> > > > Set<Class<?>>s = new HashSet<Class<?>>();
> > > > s.add(Ejb.class);
> > > > return s;
> > > > }
> > > >
> > > > I then put the whole lot in a war file which contains just those
> > > > classes and a few others that I reference from the @POST method.
> > > > They all make reference to libraries that are in the {tomee}/lib
> > > > directory. In the war file is also a persistence.xml which defines
> > > > the postgresql driver and the JDBC connection info (the driver is
> > > > included in the war file)
> > > >
> > > > I finally put the war file in its own directory in the webapps
> directory
> > > > and start tomee (using bin/startup.sh).
> > > >
> > > > In the log file I get information which seems to say that it has
> > > > found everything:-
> > > >
> > > > INFO - REST Application: http://localhost:8080/test/* ->
> > > > uk.co.dga.test.App
> > > > INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> > > > uk.co.dga.test.Ejb
> > > > INFO - POST http://localhost:8080/test/ejb/ ->
> Reply
> > > > process(JAXBElement<Request>)
> > > >
> > > > So it seems to have found both classes.
> > > >
> > > > Then however is starts to complain:-
> > > >
> > > > SEVERE - Error waiting for multi-thread deployment of directories to
> > > > complete
> > > > java.util.concurrent.ExecutionException: java.lang.InternalError:
> > > > LocalBeanProxyFactory.createProxy:
> > > > java.lang.reflect.InvocationTargetException
> > > >
> > > > and a whole stack trace ending with as the inner most part:-
> > > >
> > > > Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> > > >
> > > > at
> > >
> > >
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186
> > > )
> > >
> > > > at
> > >
> > >
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> > >
> > > > ... 26 more
> > > >
> > > > How can it have found it and not found it?
> > > >
> > > > David
> r
Re: jax-rs packaging question
Posted by David Goodenough <da...@linkchoose.co.uk>.
Attached is the war file, which fails every time for me.
The @Post method does have a body, all it does is return a string.
I met the * somewhere online, I think on an oracle site. I will see if I can
find it.
David
On Monday 06 April 2015 21:14:53 Romain Manni-Bucau wrote:
> Please provide a sample *reproducing* the error. This one doesnt + @POST
> without body doesn't make much sense.
>
> Side note: don't add a star at the end of @ApplicationPath mapping please
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> | Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau>
> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-06 17:35 GMT+02:00 David Goodenough <
>
> david.goodenough@linkchoose.co.uk>:
> > No static blocks in the code. Here is a really basic test:-
> >
> > RestApp.java
> >
> > package uk.co.dga.test;
> >
> > import java.util.HashSet;
> > import java.util.Set;
> >
> > import javax.ws.rs.ApplicationPath;
> > import javax.ws.rs.core.Application;
> >
> > @ApplicationPath("/*")
> > public class RestApp extends Application {
> >
> > @Override public Set<Class<?>>getClasses() {
> >
> > Set<Class<?>>s = new HashSet<Class<?>>();
> > s.add(RestEjb.class);
> > return s;
> > }
> >
> > }
> >
> > RestEjb.java
> >
> > package uk.co.dga.test;
> >
> > import javax.ejb.Stateless;
> > import javax.ws.rs.POST;
> > import javax.ws.rs.Path;
> > import javax.ws.rs.Produces;
> > import javax.ws.rs.core.MediaType;
> >
> > @Stateless
> > @Path("/test")
> > public class RestEjb {
> >
> > @POST
> > @Produces(MediaType.TEXT_PLAIN)
> > public String process() {
> >
> > return "Hello World";
> > }
> >
> > }
> >
> > and the file structure in webapps/test is:-
> >
> > webapps/test/
> >
> > |-- HelloWorld
> > |
> > | |-- META-INF
> > | |
> > | | `-- MANIFEST.MF
> > |
> > | `-- WEB-INF
> > |
> > | |-- classes
> > | |
> > | | `-- uk
> > | |
> > | | `-- co
> > | |
> > | | `-- dga
> > | |
> > | | `-- test
> > | |
> > | | |-- RestApp.class
> > | |
> > | | `-- RestEjb.class
> > |
> > | `-- lib
> >
> > `-- HelloWorld.war
> >
> > David
> >
> > On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> > > Hi
> > >
> > > Can it be a static block failing or something like that?
> > >
> > > Can you share a project showing it?
> > > I have a JAX-RS application, and if I can I want to use the no-xml
> > > configuration with annotations instead.
> > >
> > > So I have written the main stateless EJB with @Path, which
> > > has an @POST annotated method on it, and a second class
> > > derived from Application which has an @ApplicationPath annotation.
> > > The Application has an overridden method:-
> > >
> > > @Override public Set<Class<?>>getClasses() {
> > >
> > > Set<Class<?>>s = new HashSet<Class<?>>();
> > > s.add(Ejb.class);
> > > return s;
> > > }
> > >
> > > I then put the whole lot in a war file which contains just those
> > > classes and a few others that I reference from the @POST method.
> > > They all make reference to libraries that are in the {tomee}/lib
> > > directory. In the war file is also a persistence.xml which defines
> > > the postgresql driver and the JDBC connection info (the driver is
> > > included in the war file)
> > >
> > > I finally put the war file in its own directory in the webapps directory
> > > and start tomee (using bin/startup.sh).
> > >
> > > In the log file I get information which seems to say that it has
> > > found everything:-
> > >
> > > INFO - REST Application: http://localhost:8080/test/* ->
> > > uk.co.dga.test.App
> > > INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> > > uk.co.dga.test.Ejb
> > > INFO - POST http://localhost:8080/test/ejb/ -> Reply
> > > process(JAXBElement<Request>)
> > >
> > > So it seems to have found both classes.
> > >
> > > Then however is starts to complain:-
> > >
> > > SEVERE - Error waiting for multi-thread deployment of directories to
> > > complete
> > > java.util.concurrent.ExecutionException: java.lang.InternalError:
> > > LocalBeanProxyFactory.createProxy:
> > > java.lang.reflect.InvocationTargetException
> > >
> > > and a whole stack trace ending with as the inner most part:-
> > >
> > > Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> > >
> > > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186
> > )
> >
> > > at
> >
> > org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> >
> > > ... 26 more
> > >
> > > How can it have found it and not found it?
> > >
> > > David
r
Re: jax-rs packaging question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Please provide a sample *reproducing* the error. This one doesnt + @POST
without body doesn't make much sense.
Side note: don't add a star at the end of @ApplicationPath mapping please
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
2015-04-06 17:35 GMT+02:00 David Goodenough <
david.goodenough@linkchoose.co.uk>:
> No static blocks in the code. Here is a really basic test:-
>
> RestApp.java
>
> package uk.co.dga.test;
>
> import java.util.HashSet;
> import java.util.Set;
>
> import javax.ws.rs.ApplicationPath;
> import javax.ws.rs.core.Application;
>
> @ApplicationPath("/*")
> public class RestApp extends Application {
> @Override public Set<Class<?>>getClasses() {
> Set<Class<?>>s = new HashSet<Class<?>>();
> s.add(RestEjb.class);
> return s;
> }
> }
>
> RestEjb.java
>
> package uk.co.dga.test;
>
> import javax.ejb.Stateless;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
>
> @Stateless
> @Path("/test")
> public class RestEjb {
> @POST
> @Produces(MediaType.TEXT_PLAIN)
> public String process() {
> return "Hello World";
> }
> }
>
> and the file structure in webapps/test is:-
>
> webapps/test/
> |-- HelloWorld
> | |-- META-INF
> | | `-- MANIFEST.MF
> | `-- WEB-INF
> | |-- classes
> | | `-- uk
> | | `-- co
> | | `-- dga
> | | `-- test
> | | |-- RestApp.class
> | | `-- RestEjb.class
> | `-- lib
> `-- HelloWorld.war
>
> David
>
>
> On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> > Hi
> >
> > Can it be a static block failing or something like that?
> >
> > Can you share a project showing it?
> > I have a JAX-RS application, and if I can I want to use the no-xml
> > configuration with annotations instead.
> >
> > So I have written the main stateless EJB with @Path, which
> > has an @POST annotated method on it, and a second class
> > derived from Application which has an @ApplicationPath annotation.
> > The Application has an overridden method:-
> >
> > @Override public Set<Class<?>>getClasses() {
> > Set<Class<?>>s = new HashSet<Class<?>>();
> > s.add(Ejb.class);
> > return s;
> > }
> >
> > I then put the whole lot in a war file which contains just those
> > classes and a few others that I reference from the @POST method.
> > They all make reference to libraries that are in the {tomee}/lib
> > directory. In the war file is also a persistence.xml which defines
> > the postgresql driver and the JDBC connection info (the driver is
> > included in the war file)
> >
> > I finally put the war file in its own directory in the webapps directory
> > and start tomee (using bin/startup.sh).
> >
> > In the log file I get information which seems to say that it has
> > found everything:-
> >
> > INFO - REST Application: http://localhost:8080/test/* ->
> > uk.co.dga.test.App
> > INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> > uk.co.dga.test.Ejb
> > INFO - POST http://localhost:8080/test/ejb/ -> Reply
> > process(JAXBElement<Request>)
> >
> > So it seems to have found both classes.
> >
> > Then however is starts to complain:-
> >
> > SEVERE - Error waiting for multi-thread deployment of directories to
> > complete
> > java.util.concurrent.ExecutionException: java.lang.InternalError:
> > LocalBeanProxyFactory.createProxy:
> > java.lang.reflect.InvocationTargetException
> >
> > and a whole stack trace ending with as the inner most part:-
> >
> > Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> > at
> >
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186)
> > at
> >
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> > ... 26 more
> >
> > How can it have found it and not found it?
> >
> > David
>
>
Re: jax-rs packaging question
Posted by David Goodenough <da...@linkchoose.co.uk>.
No static blocks in the code. Here is a really basic test:-
RestApp.java
package uk.co.dga.test;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/*")
public class RestApp extends Application {
@Override public Set<Class<?>>getClasses() {
Set<Class<?>>s = new HashSet<Class<?>>();
s.add(RestEjb.class);
return s;
}
}
RestEjb.java
package uk.co.dga.test;
import javax.ejb.Stateless;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Stateless
@Path("/test")
public class RestEjb {
@POST
@Produces(MediaType.TEXT_PLAIN)
public String process() {
return "Hello World";
}
}
and the file structure in webapps/test is:-
webapps/test/
|-- HelloWorld
| |-- META-INF
| | `-- MANIFEST.MF
| `-- WEB-INF
| |-- classes
| | `-- uk
| | `-- co
| | `-- dga
| | `-- test
| | |-- RestApp.class
| | `-- RestEjb.class
| `-- lib
`-- HelloWorld.war
David
On Monday 06 April 2015 17:17:47 Romain Manni-Bucau wrote:
> Hi
>
> Can it be a static block failing or something like that?
>
> Can you share a project showing it?
> I have a JAX-RS application, and if I can I want to use the no-xml
> configuration with annotations instead.
>
> So I have written the main stateless EJB with @Path, which
> has an @POST annotated method on it, and a second class
> derived from Application which has an @ApplicationPath annotation.
> The Application has an overridden method:-
>
> @Override public Set<Class<?>>getClasses() {
> Set<Class<?>>s = new HashSet<Class<?>>();
> s.add(Ejb.class);
> return s;
> }
>
> I then put the whole lot in a war file which contains just those
> classes and a few others that I reference from the @POST method.
> They all make reference to libraries that are in the {tomee}/lib
> directory. In the war file is also a persistence.xml which defines
> the postgresql driver and the JDBC connection info (the driver is
> included in the war file)
>
> I finally put the war file in its own directory in the webapps directory
> and start tomee (using bin/startup.sh).
>
> In the log file I get information which seems to say that it has
> found everything:-
>
> INFO - REST Application: http://localhost:8080/test/* ->
> uk.co.dga.test.App
> INFO - Service URI: http://localhost:8080/test/ejb -> EJB
> uk.co.dga.test.Ejb
> INFO - POST http://localhost:8080/test/ejb/ -> Reply
> process(JAXBElement<Request>)
>
> So it seems to have found both classes.
>
> Then however is starts to complain:-
>
> SEVERE - Error waiting for multi-thread deployment of directories to
> complete
> java.util.concurrent.ExecutionException: java.lang.InternalError:
> LocalBeanProxyFactory.createProxy:
> java.lang.reflect.InvocationTargetException
>
> and a whole stack trace ending with as the inner most part:-
>
> Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
> at
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186)
> at
> org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
> ... 26 more
>
> How can it have found it and not found it?
>
> David
Re: jax-rs packaging question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
Can it be a static block failing or something like that?
Can you share a project showing it?
I have a JAX-RS application, and if I can I want to use the no-xml
configuration with annotations instead.
So I have written the main stateless EJB with @Path, which
has an @POST annotated method on it, and a second class
derived from Application which has an @ApplicationPath annotation.
The Application has an overridden method:-
@Override public Set<Class<?>>getClasses() {
Set<Class<?>>s = new HashSet<Class<?>>();
s.add(Ejb.class);
return s;
}
I then put the whole lot in a war file which contains just those
classes and a few others that I reference from the @POST method.
They all make reference to libraries that are in the {tomee}/lib
directory. In the war file is also a persistence.xml which defines
the postgresql driver and the JDBC connection info (the driver is
included in the war file)
I finally put the war file in its own directory in the webapps directory
and start tomee (using bin/startup.sh).
In the log file I get information which seems to say that it has
found everything:-
INFO - REST Application: http://localhost:8080/test/* ->
uk.co.dga.test.App
INFO - Service URI: http://localhost:8080/test/ejb -> EJB
uk.co.dga.test.Ejb
INFO - POST http://localhost:8080/test/ejb/ -> Reply
process(JAXBElement<Request>)
So it seems to have found both classes.
Then however is starts to complain:-
SEVERE - Error waiting for multi-thread deployment of directories to
complete
java.util.concurrent.ExecutionException: java.lang.InternalError:
LocalBeanProxyFactory.createProxy:
java.lang.reflect.InvocationTargetException
and a whole stack trace ending with as the inner most part:-
Caused by: java.lang.ClassNotFoundException: uk.co.dga.test.Ejb
at
org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186)
at
org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
... 26 more
How can it have found it and not found it?
David