I've done Spring and log4j within an .aar file. I've also got multiple .aars running independently with their own log4j and Spring setups.

Things I had to do were:

1. Make sure log4j.jar is not in the axis2/WEB-INF/lib folder.
2. Set the axis 2 logger to non log4j logging and remove the axis2 log4j.properties from the axis2/WEB-INF/classes folder.
3. I configure log4j in the init method of my skeleton classes, as you can be sure at that point that the correct classloader is available - I think the Spring init phase is using a different classloader to the one you need.
4. If I'm using either Ibatis or Hibernate inside the .aar I have to explode it to the services folder - otherwise you get resource not found exceptions for the mapping files.

A snippet from my skeleton init() methods:

Properties props = new Properties();
props.load( DataHubAuthenticationServiceSkeleton.class.getClassLoader().getResourceAsStream( "log4j.properties"));
PropertyConfigurator.configure( props);



Upul Godage wrote:
http://ws.apache.org/axis2/faq.html#b1

This link has details about Axis2 class loading behaviour.

Upul


On 10/9/07, Upul Godage <[EMAIL PROTECTED]> wrote:
Hi Eric,

In your code, Spring ClassPathXmlApplicationContext uses a classloader taken from  service.getClassLoader() but log4j doesn't.

Try the same classloader given to Spring for the log4j,

ClassLoader classLoader = service.getClassLoader();
URL url = "" style="font-weight: bold;">classLoader
.getResource("config_ws/log4j.xml");

Hope this helps.

Upul



On 10/8/07, Eric_K < [EMAIL PROTECTED]> wrote:


Hi Upul,

Thanks for responding. The below is correct.My .aar looks like the
following:

.aar
    |_com
    |_config_ws
    |   |_applicationContext.xml
    |   |_log4j.xml
    |_META-INF

The below code for my springinit.java works fine for the loading the
applicationContext, but I think that axis has a problem with loading the
log4j as it can't recognize the directory structure in the aar. Is there a
similar call to the getSystemResource that can locate within the classpath?

thanks,

Eric


Upul Godage wrote:
>
> Hi,
>
> Looks like URL url = "" ("config_ws/log4j.xml");
> returned null. Is the location correct?
>
> Upul
>
>
> On 10/6/07, Eric_K < [EMAIL PROTECTED]> wrote:
>>
>>
>> hi folks,
>>
>> I'm trying to determine if there's a simple method of enabling log4j
>> logging
>> inside axis2, more specifically inside the AAR. I am running the
>> following
>> inside my springinit.java and receiving the below failure. Do I need to
>> use
>> the .mar example for the logging module or is there another common way to
>> get log4J running?
>>
>> <code>
>>
>>     public void startUp(ConfigurationContext ignore, AxisService service)
>> {
>>         //Load and configure log4j.
>>         URL url = ""> >>         DOMConfigurator.configure(url);
>>
>>         ClassLoader classLoader = service.getClassLoader();
>>         ClassPathXmlApplicationContext appCtx = new
>>             ClassPathXmlApplicationContext(new String[]
>> {"config_ws/applicationContext.xml"}, false);
>>         appCtx.setClassLoader(classLoader);
>>         appCtx.refresh ();
>>         if (logger.isDebugEnabled()) {
>>             logger.debug("\n\nstartUp() set spring classloader via
>> axisService.getClassLoader() ... ");
>>         }
>>     }
>>
>> </code>
>>
>> the following produces the following error... long... sorry.
>>
>>
>> --------------------
>>
>>
>> Error: org.apache.axis2.deployment.DeploymentException: Processing
>> Operations Modules with an error of null at
>>
>> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup
>> (ArchiveReader.java:147)
>> at
>> org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java
>> :79)
>> at
>> org.apache.axis2.deployment.DeploymentEngine.doDeploy (
>> DeploymentEngine.java:582)
>> at
>> org.apache.axis2.deployment.repository.util.WSInfoList.update(
>> WSInfoList.java:201)
>> at
>> org.apache.axis2.deployment.RepositoryListener.update (
>> RepositoryListener.java:271)
>> at
>> org.apache.axis2.deployment.RepositoryListener.checkServices(
>> RepositoryListener.java:189)
>> at
>> org.apache.axis2.deployment.DeploymentEngine.loadServices (
>> DeploymentEngine.java:110)
>> at
>> org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(
>> WarBasedAxisConfigurator.java:257)
>> at
>>
>> org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext
>> (ConfigurationContextFactory.java:74)
>> at
>> org.apache.axis2.transport.http.AxisServlet.initConfigContext(
>> AxisServlet.java:486)
>> at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:406)
>> at
>> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java
>> :1139)
>> at
>> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
>> at
>> org.apache.catalina.core.StandardContext.loadOnStartup(
>> StandardContext.java :3956)
>> at org.apache.catalina.core.StandardContext.start(StandardContext.java
>> :4230)
>> at
>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java
>> :760)
>> at
>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
>> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
>> at
>> org.apache.catalina.startup.HostConfig.deployWAR (HostConfig.java:825) at
>> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714) at
>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490) at
>> org.apache.catalina.startup.HostConfig.start (HostConfig.java:1138) at
>> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
>> at
>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
>> LifecycleSupport.java :120)
>> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
>> at
>> org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at
>> org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1014) at
>> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at
>> org.apache.catalina.core.StandardService.start(StandardService.java:448)
>> at
>> org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at
>> org.apache.catalina.startup.Catalina.start(Catalina.java:552) at
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
>> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
>> java.lang.reflect.Method.invoke(Unknown Source) at
>> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295) at
>> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) Caused by:
>> org.apache.axis2.deployment.DeploymentException : Processing Operations
>> Modules with an error of null at
>> org.apache.axis2.deployment.ServiceGroupBuilder.populateServiceGroup(
>> ServiceGroupBuilder.java:103)
>> at
>>
>> org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup
>> (ArchiveReader.java:106)
>> at
>>
>> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup
>> (ArchiveReader.java:140)
>> ... 36 more Caused by: org.apache.axis2.deployment.DeploymentException:
>> Processing Operations Modules with an error of null at
>> org.apache.axis2.deployment.ServiceBuilder.populateService (
>> ServiceBuilder.java:381)
>> at
>> org.apache.axis2.deployment.ServiceGroupBuilder.populateServiceGroup(
>> ServiceGroupBuilder.java:98)
>> ... 38 more Caused by: org.apache.axis2.deployment.DeploymentException at
>> org.apache.axis2.deployment.ServiceBuilder.loadServiceLifeCycleClass(
>> ServiceBuilder.java:458)
>> at
>> org.apache.axis2.deployment.ServiceBuilder.populateService(
>> ServiceBuilder.java:176)
>> ... 39 more Caused by: java.lang.NullPointerException at
>> org.apache.log4j.xml.DOMConfigurator$2.toString(DOMConfigurator.java:615)
>> at
>> org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:715)
>> at
>> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
>> at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java
>> :743)
>> at com.rocketgaming.ws.SpringInit.startUp(Unknown Source) at
>> org.apache.axis2.deployment.ServiceBuilder.loadServiceLifeCycleClass(
>> ServiceBuilder.java:454)
>> ... 40 more
>>
>>
>> ---------------------------
>>
>>
>> many thanks in advance,
>>
>> Eric
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Logging-%2B-axis2-tf4580678.html#a13075879
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Logging-%2B-axis2-tf4580678.html#a13102049
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-- 

Anthony
------------------------------------- 
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand
 
[EMAIL PROTECTED]
Ph  +64 4 472 8818
Fax +64 4 472 8811
------------------------------------- 
www.bcsoft.co.nz
--------------------------------------------------------------- 
This email may contain confidential or privileged information, 
and is intended for use only by the addressee, or addressees. 
If you are not the intended recipient please advise the sender 
immediately and do not copy, use or disclose the contents to 
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses 
received with this email, or to any changes made to the original 
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black 
Coffee Software Ltd.
--------------------------------------------------------------- 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to