You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Jean-Louis MONTEIRO <je...@atosorigin.com> on 2008/11/24 18:08:26 UTC

Web application not well deployed

Hi all,

I'm using openejb 3.1 embedded in tomcat 5.5.17.
Deploying an application <Context docBase="path to webapp" path="/sample" />
works fine.
Using an empty path (ie. path="") can provide some unpredicted behavior
(injection in servlets, ...).

May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can be
enhanced.
I've noticed some lines
166: standardContext.setPath("/" + webApp.contextRoot);
255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
339: if (("/" + webAppInfo.contextRoot).equals(standardContext.getPath())) {

that should be changed to accept empty path.

Any comment ?
Can I open a JIRA ?
I will have a look into TomcatWebAppBuilder (deeper) to submit a patch if
you want.

Regards,
Jean-Louis
-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p20665147.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jonathan Gallimore <jo...@gmail.com>.
I opened a Jira issue: OPENEJB-997 for this and have committed this 
patch in revision 739591. Please let me know if there's any problems. 
Thanks for the patch Werni.

Regards

Jon

Jonathan Gallimore wrote:
> I've been having the same issue defining a custom realm in a 
> context.xml file which wasn't getting passed to Tomcat:
>
> <Context>
> <Realm className="org.apache.catalina.realm.JAASRealm"
>          appName="MyLoginRealm"
>          userClassNames="uk.me.jrg.app.Principal"
>          roleClassNames="uk.me.jrg.app.Group"
>          debug="99"
>          useContextClassLoader="true" />
>
> </Context>
>
>
> I tried doing this change in TomcatWebAppBuilder:
>
> Index: 
> assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
> ===================================================================
> --- 
> assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java    
> (revision 735837)
> +++ 
> assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java    
> (working copy)
> @@ -162,7 +162,14 @@
>          for (WebAppInfo webApp : appInfo.webApps) {
>              if (getContextInfo(webApp) == null) {
>                  StandardContext standardContext = new StandardContext();
> -                standardContext.addLifecycleListener(new 
> ContextConfig());
> +                String contextXmlFile = webApp.codebase + 
> "/META-INF/context.xml";
> +                if (new File(contextXmlFile).exists()) {
> +                    standardContext.setConfigFile(contextXmlFile);
> +                    standardContext.setOverride(true);
> +                }
> +                ContextConfig contextConfig = new ContextConfig();
> +                standardContext.addLifecycleListener(contextConfig);
> +
>                  standardContext.setPath("/" + webApp.contextRoot);
>                  standardContext.setDocBase(webApp.codebase);
>                  standardContext.setParentClassLoader(classLoader);
>
>
> which worked for me - would this work for you too?
>
> Does anyone else have an opinion on this change? I'm quite happy to 
> file a JIRA and get it committed.
>
> Cheers
>
> Jon
>
>
> werni wrote:
>> Hi,
>>
>> I have a similar problem with TomcatWebAppBuilder which is related to
>> user-defined contexts:
>>
>> In the method
>>
>> public void deployWebApps(AppInfo appInfo, ClassLoader classLoader);
>>
>> the standardContext is initialized as follows:
>>
>> if (getContextInfo(webApp) == null) {
>>     StandardContext standardContext = new StandardContext();
>>     standardContext.addLifecycleListener(new ContextConfig());
>>     standardContext.setPath("/" + webApp.contextRoot);
>>     standardContext.setDocBase(webApp.codebase);
>>     standardContext.setParentClassLoader(classLoader);
>>     standardContext.setDelegate(true);
>>
>> The problem in my opinion is the line
>>
>> standardContext.addLifecycleListener(new ContextConfig());
>>
>> i.e. the standardContext is initialized with an empty ContextConfig. If a
>> context.xml is defined for a WebApp (located in one of the standard places,
>> conf/Catalina/<host>/, META-INF/context.xml, ...) it is ignored. This is
>> very undesirable if a context.xml defines Resources, ...
>>
>> With the following hack the ContextConfig is initialized with
>> META-INF/context.xml:
>>
>> StandardContext standardContext = new StandardContext();
>> standardContext.setConfigFile(
>>     webApp.codebase + "/META-INF/context.xml"
>> );
>> WebAppContextConfig.initContext(standardContext);
>> standardContext.setPath("/" + webApp.contextRoot);
>> standardContext.setDocBase(webApp.codebase);
>> standardContext.setParentClassLoader(classLoader);
>> standardContext.setDelegate(true);
>>
>> and the helper class
>>
>> private static class WebAppContextConfig extends ContextConfig {
>>
>>     private void init(
>>         StandardContext standardContext
>>     ) {
>>         standardContext.addLifecycleListener(this);
>>         this.context = standardContext;
>>         boolean tmpOverride = standardContext.getOverride();
>>         standardContext.setOverride(true);
>>         this.contextConfig();            
>>         standardContext.setOverride(tmpOverride);
>>     }
>>     
>>     public static void initContext(
>>         StandardContext standardContext
>>     ) {
>>         WebAppContextConfig config = new WebAppContextConfig();
>>         config.init(standardContext);
>>     }
>>             
>> }
>>
>> Of course this is far from a clean solution. Any comments?
>>
>> Rgs,
>> -werni.
>>
>>
>>
>>
>>
>>   


Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jonathan Gallimore <jo...@gmail.com>.
I've been having the same issue defining a custom realm in a context.xml 
file which wasn't getting passed to Tomcat:

<Context>
<Realm className="org.apache.catalina.realm.JAASRealm"
         appName="MyLoginRealm"
         userClassNames="uk.me.jrg.app.Principal"
         roleClassNames="uk.me.jrg.app.Group"
         debug="99"
         useContextClassLoader="true" />

</Context>


I tried doing this change in TomcatWebAppBuilder:

Index: 
assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
===================================================================
--- 
assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java    
(revision 735837)
+++ 
assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java    
(working copy)
@@ -162,7 +162,14 @@
         for (WebAppInfo webApp : appInfo.webApps) {
             if (getContextInfo(webApp) == null) {
                 StandardContext standardContext = new StandardContext();
-                standardContext.addLifecycleListener(new ContextConfig());
+                String contextXmlFile = webApp.codebase + 
"/META-INF/context.xml";
+                if (new File(contextXmlFile).exists()) {
+                    standardContext.setConfigFile(contextXmlFile);
+                    standardContext.setOverride(true);
+                }
+                ContextConfig contextConfig = new ContextConfig();
+                standardContext.addLifecycleListener(contextConfig);
+
                 standardContext.setPath("/" + webApp.contextRoot);
                 standardContext.setDocBase(webApp.codebase);
                 standardContext.setParentClassLoader(classLoader);


which worked for me - would this work for you too?

Does anyone else have an opinion on this change? I'm quite happy to file 
a JIRA and get it committed.

Cheers

Jon


werni wrote:
> Hi,
>
> I have a similar problem with TomcatWebAppBuilder which is related to
> user-defined contexts:
>
> In the method
>
> public void deployWebApps(AppInfo appInfo, ClassLoader classLoader);
>
> the standardContext is initialized as follows:
>
> if (getContextInfo(webApp) == null) {
>     StandardContext standardContext = new StandardContext();
>     standardContext.addLifecycleListener(new ContextConfig());
>     standardContext.setPath("/" + webApp.contextRoot);
>     standardContext.setDocBase(webApp.codebase);
>     standardContext.setParentClassLoader(classLoader);
>     standardContext.setDelegate(true);
>
> The problem in my opinion is the line
>
> standardContext.addLifecycleListener(new ContextConfig());
>
> i.e. the standardContext is initialized with an empty ContextConfig. If a
> context.xml is defined for a WebApp (located in one of the standard places,
> conf/Catalina/<host>/, META-INF/context.xml, ...) it is ignored. This is
> very undesirable if a context.xml defines Resources, ...
>
> With the following hack the ContextConfig is initialized with
> META-INF/context.xml:
>
> StandardContext standardContext = new StandardContext();
> standardContext.setConfigFile(
>     webApp.codebase + "/META-INF/context.xml"
> );
> WebAppContextConfig.initContext(standardContext);
> standardContext.setPath("/" + webApp.contextRoot);
> standardContext.setDocBase(webApp.codebase);
> standardContext.setParentClassLoader(classLoader);
> standardContext.setDelegate(true);
>
> and the helper class
>
> private static class WebAppContextConfig extends ContextConfig {
>
>     private void init(
>         StandardContext standardContext
>     ) {
>         standardContext.addLifecycleListener(this);
>         this.context = standardContext;
>         boolean tmpOverride = standardContext.getOverride();
>         standardContext.setOverride(true);
>         this.contextConfig();            
>         standardContext.setOverride(tmpOverride);
>     }
>     
>     public static void initContext(
>         StandardContext standardContext
>     ) {
>         WebAppContextConfig config = new WebAppContextConfig();
>         config.init(standardContext);
>     }
>             
> }
>
> Of course this is far from a clean solution. Any comments?
>
> Rgs,
> -werni.
>
>
>
>
>
>   

Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by werni <wf...@omex.ch>.
Hi,

I have a similar problem with TomcatWebAppBuilder which is related to
user-defined contexts:

In the method

public void deployWebApps(AppInfo appInfo, ClassLoader classLoader);

the standardContext is initialized as follows:

if (getContextInfo(webApp) == null) {
    StandardContext standardContext = new StandardContext();
    standardContext.addLifecycleListener(new ContextConfig());
    standardContext.setPath("/" + webApp.contextRoot);
    standardContext.setDocBase(webApp.codebase);
    standardContext.setParentClassLoader(classLoader);
    standardContext.setDelegate(true);

The problem in my opinion is the line

standardContext.addLifecycleListener(new ContextConfig());

i.e. the standardContext is initialized with an empty ContextConfig. If a
context.xml is defined for a WebApp (located in one of the standard places,
conf/Catalina/<host>/, META-INF/context.xml, ...) it is ignored. This is
very undesirable if a context.xml defines Resources, ...

With the following hack the ContextConfig is initialized with
META-INF/context.xml:

StandardContext standardContext = new StandardContext();
standardContext.setConfigFile(
    webApp.codebase + "/META-INF/context.xml"
);
WebAppContextConfig.initContext(standardContext);
standardContext.setPath("/" + webApp.contextRoot);
standardContext.setDocBase(webApp.codebase);
standardContext.setParentClassLoader(classLoader);
standardContext.setDelegate(true);

and the helper class

private static class WebAppContextConfig extends ContextConfig {

    private void init(
        StandardContext standardContext
    ) {
        standardContext.addLifecycleListener(this);
        this.context = standardContext;
        boolean tmpOverride = standardContext.getOverride();
        standardContext.setOverride(true);
        this.contextConfig();            
        standardContext.setOverride(tmpOverride);
    }
    
    public static void initContext(
        StandardContext standardContext
    ) {
        WebAppContextConfig config = new WebAppContextConfig();
        config.init(standardContext);
    }
            
}

Of course this is far from a clean solution. Any comments?

Rgs,
-werni.





-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21567349.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jonathan Gallimore <jo...@gmail.com>.
Hi Jean-Louis,

Thanks for the info - you're right, this doesn't work for EAR files, but
does work for WAR files. I think it would be nice if we can make it work for
EAR files too - if there's no objection I'll have a go and see if I can
extend this functionality to work for EAR files too.

I've tested your patch using the webapp sample on both Tomcat 5.5 and Tomcat
6, and it looks good. I've just committed it (revision 732167).

Many thanks for the patch!

Cheers

Jon

On Tue, Jan 6, 2009 at 3:39 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:

>
> Jonathan,
>
> I tried this morning to see how to statically deploy an EAR/JAR file using
> a
> <Context .../> tag.
> I'm facing some problems because Tomcat only knows
> (org.apache.catalina.core.StandardContext:4014)
> 1. war files
> 2. exploded web applications (directories)
>
> So, using an EAR/JAR file always causes an IllegalArgumentException in
> org.apache.naming.resources.FileDirContext, line 140 (not a directory).
>
> We can create a hack in TomcatWebAppBuilder to explode EAR archives in
> webapps and dynamically change the docBase. It does not appear to be a
> clean
> solution. Moreover, what can we do with ejb jar files ?
>
> At the moment, only hot deployment works fine.
> Never mind, it's another topic (not related with the patch submitted for
> this JIRA).
>
> Feel free to share your thinking.
>
> Regards,
> JLouis
>
>
> Jean-Louis MONTEIRO wrote:
> >
> > Hi Jonathan
> >
> > I tried to find out the problem.
> > Here are some comments:
> >
> > Tomcat can deal with exploded web applications or with war files.
> > On top of that, OpenEJB can deal with ejb jars and ear.
> >
> > For war files, you can use hot deployments (putting the war file in the
> > HOST appBase directory).
> > Also, a context can be declared using a META-INF/context.xml file or
> using
> > <Context ... /> tag in the server.xml file.
> >
> > Both work as expected with or without openejb.
> > So to conclude, your test can not work because your docBase is
> referencing
> > an EAR file.
> >
> > That's why at the moment, it seems to me that the only possible way to
> > deploy an EAR using openEJB embedded in Tomcat is to copy the jar in the
> > HOST appBase.
> >
> > Perhaps we can hack something in standard Tomcat deployments to extend
> > native Tomcat mechanisms.
> >
> > When Tomcat finds out a <Context .../> tag referencing a WAR file outside
> > standard HOST appBase, it explodes and declare the WAR in Host appBase.
> > --> We can easily imagine the same mechanism for ejb jars and ear files.
> > It's quite easy to implement using the Catalina lifecycle INIT_EVENT (ie.
> > init() method of the TomcatWebAppBuilder).
> >
> > For example, can you try renaming your ear to war ?
> >
> > Any comments ?
> > Am I wrong ?
> >
> > Regards,
> > JLouis
> >
> >
> > Jonathan Gallimore-2 wrote:
> >>
> >> How are you structuring your webapp that you're pointing to with your
> >> Context configuration? I've just had a go with this to have a look at
> >> your
> >> patch with an EAR file and and EAR extracted into a directory, and
> >> couldn't
> >> deploy either of them.
> >>
> >> I added this to my <Host> in server.xml:
> >>
> >> <Context docBase="/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear"
> >> path="/people" />
> >>
> >> and in the OpenEJB log I get:
> >>
> >> 2008-12-30 20:55:31,572 - INFO  - Configuring enterprise application:
> >> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
> >> 2008-12-30 20:55:31,580 - INFO  - Enterprise application
> >> "/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear" loaded.
> >> 2008-12-30 20:55:31,580 - INFO  - Assembling app:
> >> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
> >> 2008-12-30 20:55:31,580 - INFO  - Deployed
> >> Application(path=/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear)
> >>
> >> but nothing else - no messages about deploying my bean, or anything like
> >> that.
> >>
> >> Have I configured something wrong, or is my app packaged differently to
> >> yours?
> >>
> >> Cheers
> >>
> >> Jon
> >>
> >> On Tue, Dec 16, 2008 at 11:23 AM, Jean-Louis MONTEIRO <
> >> jean-louis.monteiro@atosorigin.com> wrote:
> >>
> >>>
> >>> OK,
> >>>
> >>> I proposed a patch to the related JIRA.
> >>> https://issues.apache.org/jira/browse/OPENEJB-975
> >>>
> >>> Regards,
> >>> JLouis
> >>>
> >>>
> >>> Jean-Louis MONTEIRO wrote:
> >>> >
> >>> > Dain,
> >>> >
> >>> > Yes, you can do that to define a default application.
> >>> > Extract from the documentation
> >>> > (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
> >>> > [...]
> >>> > If you specify a context path of an empty string (""), you are
> >>> defining
> >>> > the default web application for this Host, which will process all
> >>> requests
> >>> > not assigned to other Contexts.
> >>> > [...]
> >>> >
> >>> > OK, I will have a look deeper and open a JIRA (with a patch).
> >>> >
> >>> > Regards,
> >>> > Jean-Louis
> >>> >
> >>> >
> >>> >
> >>> > Dain Sundstrom wrote:
> >>> >>
> >>> >> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
> >>> >>
> >>> >>>
> >>> >>> Hi all,
> >>> >>>
> >>> >>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
> >>> >>> Deploying an application <Context docBase="path to webapp" path="/
> >>> >>> sample" />
> >>> >>> works fine.
> >>> >>> Using an empty path (ie. path="") can provide some unpredicted
> >>> >>> behavior
> >>> >>> (injection in servlets, ...).
> >>> >>>
> >>> >>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module
> can
> >>> >>> be
> >>> >>> enhanced.
> >>> >>> I've noticed some lines
> >>> >>> 166: standardContext.setPath("/" + webApp.contextRoot);
> >>> >>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
> >>> >>> 339: if (("/" +
> >>> >>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
> >>> >>>
> >>> >>> that should be changed to accept empty path.
> >>> >>>
> >>> >>> Any comment ?
> >>> >>
> >>> >> Sounds good.  I didn't know you could do that in tomcat :)
> >>> >>
> >>> >>> Can I open a JIRA ?
> >>> >>
> >>> >> Yep, and attach the patch (make sure to select the button to license
> >>> >> the patch to apache).
> >>> >>
> >>> >>> I will have a look into TomcatWebAppBuilder (deeper) to submit a
> >>> >>> patch if
> >>> >>> you want.
> >>> >>>
> >>> >>
> >>> >> -dain
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031357.html
> >>> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21312793.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>
>

Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Jonathan,

I tried this morning to see how to statically deploy an EAR/JAR file using a
<Context .../> tag.
I'm facing some problems because Tomcat only knows
(org.apache.catalina.core.StandardContext:4014)
1. war files
2. exploded web applications (directories)

So, using an EAR/JAR file always causes an IllegalArgumentException in
org.apache.naming.resources.FileDirContext, line 140 (not a directory).

We can create a hack in TomcatWebAppBuilder to explode EAR archives in
webapps and dynamically change the docBase. It does not appear to be a clean
solution. Moreover, what can we do with ejb jar files ?

At the moment, only hot deployment works fine.
Never mind, it's another topic (not related with the patch submitted for
this JIRA).

Feel free to share your thinking.

Regards,
JLouis


Jean-Louis MONTEIRO wrote:
> 
> Hi Jonathan
> 
> I tried to find out the problem.
> Here are some comments:
> 
> Tomcat can deal with exploded web applications or with war files.
> On top of that, OpenEJB can deal with ejb jars and ear.
> 
> For war files, you can use hot deployments (putting the war file in the
> HOST appBase directory).
> Also, a context can be declared using a META-INF/context.xml file or using
> <Context ... /> tag in the server.xml file.
> 
> Both work as expected with or without openejb.
> So to conclude, your test can not work because your docBase is referencing
> an EAR file.
> 
> That's why at the moment, it seems to me that the only possible way to
> deploy an EAR using openEJB embedded in Tomcat is to copy the jar in the
> HOST appBase. 
> 
> Perhaps we can hack something in standard Tomcat deployments to extend
> native Tomcat mechanisms.
> 
> When Tomcat finds out a <Context .../> tag referencing a WAR file outside
> standard HOST appBase, it explodes and declare the WAR in Host appBase.
> --> We can easily imagine the same mechanism for ejb jars and ear files.
> It's quite easy to implement using the Catalina lifecycle INIT_EVENT (ie.
> init() method of the TomcatWebAppBuilder).
> 
> For example, can you try renaming your ear to war ?
> 
> Any comments ?
> Am I wrong ?
> 
> Regards,
> JLouis
> 
> 
> Jonathan Gallimore-2 wrote:
>> 
>> How are you structuring your webapp that you're pointing to with your
>> Context configuration? I've just had a go with this to have a look at
>> your
>> patch with an EAR file and and EAR extracted into a directory, and
>> couldn't
>> deploy either of them.
>> 
>> I added this to my <Host> in server.xml:
>> 
>> <Context docBase="/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear"
>> path="/people" />
>> 
>> and in the OpenEJB log I get:
>> 
>> 2008-12-30 20:55:31,572 - INFO  - Configuring enterprise application:
>> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
>> 2008-12-30 20:55:31,580 - INFO  - Enterprise application
>> "/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear" loaded.
>> 2008-12-30 20:55:31,580 - INFO  - Assembling app:
>> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
>> 2008-12-30 20:55:31,580 - INFO  - Deployed
>> Application(path=/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear)
>> 
>> but nothing else - no messages about deploying my bean, or anything like
>> that.
>> 
>> Have I configured something wrong, or is my app packaged differently to
>> yours?
>> 
>> Cheers
>> 
>> Jon
>> 
>> On Tue, Dec 16, 2008 at 11:23 AM, Jean-Louis MONTEIRO <
>> jean-louis.monteiro@atosorigin.com> wrote:
>> 
>>>
>>> OK,
>>>
>>> I proposed a patch to the related JIRA.
>>> https://issues.apache.org/jira/browse/OPENEJB-975
>>>
>>> Regards,
>>> JLouis
>>>
>>>
>>> Jean-Louis MONTEIRO wrote:
>>> >
>>> > Dain,
>>> >
>>> > Yes, you can do that to define a default application.
>>> > Extract from the documentation
>>> > (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
>>> > [...]
>>> > If you specify a context path of an empty string (""), you are
>>> defining
>>> > the default web application for this Host, which will process all
>>> requests
>>> > not assigned to other Contexts.
>>> > [...]
>>> >
>>> > OK, I will have a look deeper and open a JIRA (with a patch).
>>> >
>>> > Regards,
>>> > Jean-Louis
>>> >
>>> >
>>> >
>>> > Dain Sundstrom wrote:
>>> >>
>>> >> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
>>> >>
>>> >>>
>>> >>> Hi all,
>>> >>>
>>> >>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
>>> >>> Deploying an application <Context docBase="path to webapp" path="/
>>> >>> sample" />
>>> >>> works fine.
>>> >>> Using an empty path (ie. path="") can provide some unpredicted
>>> >>> behavior
>>> >>> (injection in servlets, ...).
>>> >>>
>>> >>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can
>>> >>> be
>>> >>> enhanced.
>>> >>> I've noticed some lines
>>> >>> 166: standardContext.setPath("/" + webApp.contextRoot);
>>> >>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
>>> >>> 339: if (("/" +
>>> >>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>>> >>>
>>> >>> that should be changed to accept empty path.
>>> >>>
>>> >>> Any comment ?
>>> >>
>>> >> Sounds good.  I didn't know you could do that in tomcat :)
>>> >>
>>> >>> Can I open a JIRA ?
>>> >>
>>> >> Yep, and attach the patch (make sure to select the button to license
>>> >> the patch to apache).
>>> >>
>>> >>> I will have a look into TomcatWebAppBuilder (deeper) to submit a
>>> >>> patch if
>>> >>> you want.
>>> >>>
>>> >>
>>> >> -dain
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031357.html
>>> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21312793.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Hi Jonathan

I tried to find out the problem.
Here are some comments:

Tomcat can deal with exploded web applications or with war files.
On top of that, OpenEJB can deal with ejb jars and ear.

For war files, you can use hot deployments (putting the war file in the HOST
appBase directory).
Also, a context can be declared using a META-INF/context.xml file or using
<Context ... /> tag in the server.xml file.

Both work as expected with or without openejb.
So to conclude, your test can not work because your docBase is referencing
an EAR file.

That's why at the moment, it seems to me that the only possible way to
deploy an EAR using openEJB embedded in Tomcat is to copy the jar in the
HOST appBase. 

Perhaps we can hack something in standard Tomcat deployments to extend
native Tomcat mechanisms.

When Tomcat finds out a <Context .../> tag referencing a WAR file outside
standard HOST appBase, it explodes and declare the WAR in Host appBase.
--> We can easily imagine the same mechanism for ejb jars and ear files.
It's quite easy to implement using the Catalina lifecycle INIT_EVENT (ie.
init() method of the TomcatWebAppBuilder).

For example, can you try renaming your ear to war ?

Any comments ?
Am I wrong ?

Regards,
JLouis


Jonathan Gallimore-2 wrote:
> 
> How are you structuring your webapp that you're pointing to with your
> Context configuration? I've just had a go with this to have a look at your
> patch with an EAR file and and EAR extracted into a directory, and
> couldn't
> deploy either of them.
> 
> I added this to my <Host> in server.xml:
> 
> <Context docBase="/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear"
> path="/people" />
> 
> and in the OpenEJB log I get:
> 
> 2008-12-30 20:55:31,572 - INFO  - Configuring enterprise application:
> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
> 2008-12-30 20:55:31,580 - INFO  - Enterprise application
> "/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear" loaded.
> 2008-12-30 20:55:31,580 - INFO  - Assembling app:
> /home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
> 2008-12-30 20:55:31,580 - INFO  - Deployed
> Application(path=/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear)
> 
> but nothing else - no messages about deploying my bean, or anything like
> that.
> 
> Have I configured something wrong, or is my app packaged differently to
> yours?
> 
> Cheers
> 
> Jon
> 
> On Tue, Dec 16, 2008 at 11:23 AM, Jean-Louis MONTEIRO <
> jean-louis.monteiro@atosorigin.com> wrote:
> 
>>
>> OK,
>>
>> I proposed a patch to the related JIRA.
>> https://issues.apache.org/jira/browse/OPENEJB-975
>>
>> Regards,
>> JLouis
>>
>>
>> Jean-Louis MONTEIRO wrote:
>> >
>> > Dain,
>> >
>> > Yes, you can do that to define a default application.
>> > Extract from the documentation
>> > (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
>> > [...]
>> > If you specify a context path of an empty string (""), you are defining
>> > the default web application for this Host, which will process all
>> requests
>> > not assigned to other Contexts.
>> > [...]
>> >
>> > OK, I will have a look deeper and open a JIRA (with a patch).
>> >
>> > Regards,
>> > Jean-Louis
>> >
>> >
>> >
>> > Dain Sundstrom wrote:
>> >>
>> >> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
>> >>
>> >>>
>> >>> Hi all,
>> >>>
>> >>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
>> >>> Deploying an application <Context docBase="path to webapp" path="/
>> >>> sample" />
>> >>> works fine.
>> >>> Using an empty path (ie. path="") can provide some unpredicted
>> >>> behavior
>> >>> (injection in servlets, ...).
>> >>>
>> >>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can
>> >>> be
>> >>> enhanced.
>> >>> I've noticed some lines
>> >>> 166: standardContext.setPath("/" + webApp.contextRoot);
>> >>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
>> >>> 339: if (("/" +
>> >>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>> >>>
>> >>> that should be changed to accept empty path.
>> >>>
>> >>> Any comment ?
>> >>
>> >> Sounds good.  I didn't know you could do that in tomcat :)
>> >>
>> >>> Can I open a JIRA ?
>> >>
>> >> Yep, and attach the patch (make sure to select the button to license
>> >> the patch to apache).
>> >>
>> >>> I will have a look into TomcatWebAppBuilder (deeper) to submit a
>> >>> patch if
>> >>> you want.
>> >>>
>> >>
>> >> -dain
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031357.html
>> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21300204.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: [JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jonathan Gallimore <jo...@gmail.com>.
How are you structuring your webapp that you're pointing to with your
Context configuration? I've just had a go with this to have a look at your
patch with an EAR file and and EAR extracted into a directory, and couldn't
deploy either of them.

I added this to my <Host> in server.xml:

<Context docBase="/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear"
path="/people" />

and in the OpenEJB log I get:

2008-12-30 20:55:31,572 - INFO  - Configuring enterprise application:
/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
2008-12-30 20:55:31,580 - INFO  - Enterprise application
"/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear" loaded.
2008-12-30 20:55:31,580 - INFO  - Assembling app:
/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear
2008-12-30 20:55:31,580 - INFO  - Deployed
Application(path=/home/jgallimore/PersonEAR-1.0-SNAPSHOT.ear)

but nothing else - no messages about deploying my bean, or anything like
that.

Have I configured something wrong, or is my app packaged differently to
yours?

Cheers

Jon

On Tue, Dec 16, 2008 at 11:23 AM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:

>
> OK,
>
> I proposed a patch to the related JIRA.
> https://issues.apache.org/jira/browse/OPENEJB-975
>
> Regards,
> JLouis
>
>
> Jean-Louis MONTEIRO wrote:
> >
> > Dain,
> >
> > Yes, you can do that to define a default application.
> > Extract from the documentation
> > (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
> > [...]
> > If you specify a context path of an empty string (""), you are defining
> > the default web application for this Host, which will process all
> requests
> > not assigned to other Contexts.
> > [...]
> >
> > OK, I will have a look deeper and open a JIRA (with a patch).
> >
> > Regards,
> > Jean-Louis
> >
> >
> >
> > Dain Sundstrom wrote:
> >>
> >> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
> >>
> >>>
> >>> Hi all,
> >>>
> >>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
> >>> Deploying an application <Context docBase="path to webapp" path="/
> >>> sample" />
> >>> works fine.
> >>> Using an empty path (ie. path="") can provide some unpredicted
> >>> behavior
> >>> (injection in servlets, ...).
> >>>
> >>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can
> >>> be
> >>> enhanced.
> >>> I've noticed some lines
> >>> 166: standardContext.setPath("/" + webApp.contextRoot);
> >>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
> >>> 339: if (("/" +
> >>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
> >>>
> >>> that should be changed to accept empty path.
> >>>
> >>> Any comment ?
> >>
> >> Sounds good.  I didn't know you could do that in tomcat :)
> >>
> >>> Can I open a JIRA ?
> >>
> >> Yep, and attach the patch (make sure to select the button to license
> >> the patch to apache).
> >>
> >>> I will have a look into TomcatWebAppBuilder (deeper) to submit a
> >>> patch if
> >>> you want.
> >>>
> >>
> >> -dain
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031357.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>
>

[JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
OK,

I proposed a patch to the related JIRA.
https://issues.apache.org/jira/browse/OPENEJB-975

Regards,
JLouis


Jean-Louis MONTEIRO wrote:
> 
> Dain,
> 
> Yes, you can do that to define a default application.
> Extract from the documentation
> (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
> [...]
> If you specify a context path of an empty string (""), you are defining
> the default web application for this Host, which will process all requests
> not assigned to other Contexts.
> [...]
> 
> OK, I will have a look deeper and open a JIRA (with a patch).
> 
> Regards,
> Jean-Louis
> 
> 
> 
> Dain Sundstrom wrote:
>> 
>> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
>> 
>>>
>>> Hi all,
>>>
>>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
>>> Deploying an application <Context docBase="path to webapp" path="/ 
>>> sample" />
>>> works fine.
>>> Using an empty path (ie. path="") can provide some unpredicted  
>>> behavior
>>> (injection in servlets, ...).
>>>
>>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can  
>>> be
>>> enhanced.
>>> I've noticed some lines
>>> 166: standardContext.setPath("/" + webApp.contextRoot);
>>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
>>> 339: if (("/" +  
>>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>>>
>>> that should be changed to accept empty path.
>>>
>>> Any comment ?
>> 
>> Sounds good.  I didn't know you could do that in tomcat :)
>> 
>>> Can I open a JIRA ?
>> 
>> Yep, and attach the patch (make sure to select the button to license  
>> the patch to apache).
>> 
>>> I will have a look into TomcatWebAppBuilder (deeper) to submit a  
>>> patch if
>>> you want.
>>>
>> 
>> -dain
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031357.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


[JIRA OPENEJB-975]Re: Web application not well deployed

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
OK,

I proposed a patch to the related JIRA.
https://issues.apache.org/jira/browse/OPENEJB-975

Regards,
JLouis


Jean-Louis MONTEIRO wrote:
> 
> Dain,
> 
> Yes, you can do that to define a default application.
> Extract from the documentation
> (http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
> [...]
> If you specify a context path of an empty string (""), you are defining
> the default web application for this Host, which will process all requests
> not assigned to other Contexts.
> [...]
> 
> OK, I will have a look deeper and open a JIRA (with a patch).
> 
> Regards,
> Jean-Louis
> 
> 
> 
> Dain Sundstrom wrote:
>> 
>> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
>> 
>>>
>>> Hi all,
>>>
>>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
>>> Deploying an application <Context docBase="path to webapp" path="/ 
>>> sample" />
>>> works fine.
>>> Using an empty path (ie. path="") can provide some unpredicted  
>>> behavior
>>> (injection in servlets, ...).
>>>
>>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can  
>>> be
>>> enhanced.
>>> I've noticed some lines
>>> 166: standardContext.setPath("/" + webApp.contextRoot);
>>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
>>> 339: if (("/" +  
>>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>>>
>>> that should be changed to accept empty path.
>>>
>>> Any comment ?
>> 
>> Sounds good.  I didn't know you could do that in tomcat :)
>> 
>>> Can I open a JIRA ?
>> 
>> Yep, and attach the patch (make sure to select the button to license  
>> the patch to apache).
>> 
>>> I will have a look into TomcatWebAppBuilder (deeper) to submit a  
>>> patch if
>>> you want.
>>>
>> 
>> -dain
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p21031355.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: Web application not well deployed

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Dain,

Yes, you can do that to define a default application.
Extract from the documentation
(http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):
[...]
If you specify a context path of an empty string (""), you are defining the
default web application for this Host, which will process all requests not
assigned to other Contexts.
[...]

OK, I will have a look deeper and open a JIRA (with a patch).

Regards,
Jean-Louis



Dain Sundstrom wrote:
> 
> On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:
> 
>>
>> Hi all,
>>
>> I'm using openejb 3.1 embedded in tomcat 5.5.17.
>> Deploying an application <Context docBase="path to webapp" path="/ 
>> sample" />
>> works fine.
>> Using an empty path (ie. path="") can provide some unpredicted  
>> behavior
>> (injection in servlets, ...).
>>
>> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can  
>> be
>> enhanced.
>> I've noticed some lines
>> 166: standardContext.setPath("/" + webApp.contextRoot);
>> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
>> 339: if (("/" +  
>> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>>
>> that should be changed to accept empty path.
>>
>> Any comment ?
> 
> Sounds good.  I didn't know you could do that in tomcat :)
> 
>> Can I open a JIRA ?
> 
> Yep, and attach the patch (make sure to select the button to license  
> the patch to apache).
> 
>> I will have a look into TomcatWebAppBuilder (deeper) to submit a  
>> patch if
>> you want.
>>
> 
> -dain
> 
> 

-- 
View this message in context: http://www.nabble.com/Web-application-not-well-deployed-tp20665147p20696386.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.


Re: Web application not well deployed

Posted by Dain Sundstrom <da...@iq80.com>.
On Nov 24, 2008, at 11:08 AM, Jean-Louis MONTEIRO wrote:

>
> Hi all,
>
> I'm using openejb 3.1 embedded in tomcat 5.5.17.
> Deploying an application <Context docBase="path to webapp" path="/ 
> sample" />
> works fine.
> Using an empty path (ie. path="") can provide some unpredicted  
> behavior
> (injection in servlets, ...).
>
> May be TomcatWebAppBuilder of the openejb-tomcat-catalina module can  
> be
> enhanced.
> I've noticed some lines
> 166: standardContext.setPath("/" + webApp.contextRoot);
> 255: if (("/" + w.contextRoot).equals(standardContext.getPath())) {
> 339: if (("/" +  
> webAppInfo.contextRoot).equals(standardContext.getPath())) {
>
> that should be changed to accept empty path.
>
> Any comment ?

Sounds good.  I didn't know you could do that in tomcat :)

> Can I open a JIRA ?

Yep, and attach the patch (make sure to select the button to license  
the patch to apache).

> I will have a look into TomcatWebAppBuilder (deeper) to submit a  
> patch if
> you want.
>

-dain