You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by anamika gupta <an...@hcl.com> on 2011/09/08 10:07:34 UTC

Problem in context loading

Hi,

   I am building my applications using maven, but a strange thing happens.
In one of my java class , i have the code 

 app = new Application();
String[] paths = {"applicationContext.xml"};
appContext = new ClassPathXmlApplicationContext(paths);

So, as per my knowledge, it should search for "applicationContext.xml" in
the classes folder. but when i am building it with maven and deploy it on
the server, it starts looking for the "applicationContext.xml" in /WEB-INF
folder.
Can you please tell me why it happens.

As if i build it using the eclipse and deploy it on the server, it looks for
the same file in classes folder.

Can you please tell me what is the reaon for such discrepancy in the
behaviuor

Any help will be greatly appreciated

--
View this message in context: http://maven.40175.n5.nabble.com/Problem-in-context-loading-tp4781640p4781640.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Problem in context loading

Posted by Daniele De Francesco <dd...@gmail.com>.
Hi,

this sounds a little bit OT but you can try this:


app = new Application();
String[] paths = {"*classpath:*applicationContext.xml"};
appContext = new ClassPathXmlApplicationContext(paths);


however, this is a webapp I assume...you don't have to go through this code
with Spring in a webapp...

...then, as said by Jorg, go back to J2EE 101 :))

On Thu, Sep 8, 2011 at 10:31 AM, Jörg Schaible
<jo...@scalaris.com>wrote:

> Hi Anamika,
>
> anamika gupta wrote:
>
> > Hi,
> >
> >    I am building my applications using maven, but a strange thing
> happens.
> > In one of my java class , i have the code
> >
> >  app = new Application();
> > String[] paths = {"applicationContext.xml"};
> > appContext = new ClassPathXmlApplicationContext(paths);
> >
> > So, as per my knowledge, it should search for "applicationContext.xml" in
> > the classes folder. but when i am building it with maven and deploy it on
> > the server, it starts looking for the "applicationContext.xml" in
> /WEB-INF
> > folder.
> > Can you please tell me why it happens.
> >
> > As if i build it using the eclipse and deploy it on the server, it looks
> > for the same file in classes folder.
> >
> > Can you please tell me what is the reaon for such discrepancy in the
> > behaviuor
> >
> > Any help will be greatly appreciated
>
> Basically this has nothing to do with Maven and does not belong to this
> list. As a hint you should make yourself familiar with the JavaEE
> specification for web containers especially looking for the documented
> classloader behavior.
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Problem in context loading

Posted by Jörg Schaible <jo...@scalaris.com>.
Hi Anamika,

anamika gupta wrote:

> Hi,
> 
>    I am building my applications using maven, but a strange thing happens.
> In one of my java class , i have the code
> 
>  app = new Application();
> String[] paths = {"applicationContext.xml"};
> appContext = new ClassPathXmlApplicationContext(paths);
> 
> So, as per my knowledge, it should search for "applicationContext.xml" in
> the classes folder. but when i am building it with maven and deploy it on
> the server, it starts looking for the "applicationContext.xml" in /WEB-INF
> folder.
> Can you please tell me why it happens.
> 
> As if i build it using the eclipse and deploy it on the server, it looks
> for the same file in classes folder.
> 
> Can you please tell me what is the reaon for such discrepancy in the
> behaviuor
> 
> Any help will be greatly appreciated

Basically this has nothing to do with Maven and does not belong to this 
list. As a hint you should make yourself familiar with the JavaEE 
specification for web containers especially looking for the documented 
classloader behavior.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org