I don’t think so. I suspect that 
org.apache.logging.log4j.core.osgi.Activator.java is not finding your plugin 
but I am not sure why.

Ralph

> On Feb 4, 2016, at 11:38 AM, Nipuni Piyabasi Perera <nipuni880...@gmail.com> 
> wrote:
> 
> Thanks for the input.
> 
> Yes the issue may be different than what I have mentioned. I suspected that
> the issue is related to Log4j2Plugins.dat file as the appender is working
> fine in non-OSGi environment, and the only different I could find was
> that Log4j2Plugins.dat
> file comparing the  two jars. May be I am missing some plugin that I need
> to add in pom.xml.
> 
> Thanks,
> Nipuni
> 
> On Fri, Feb 5, 2016 at 12:00 AM, Ralph Goers <ralph.go...@dslextreme.com>
> wrote:
> 
>> Actually, I just looked at the code and there is a class that should be
>> looking at your bundle to locate any plugins you may have. I am actually
>> not very familiar with that code so I wonder if one of the other committers
>> could provide insight on what might be causing it not to work.
>> 
>> Ralph
>> 
>>> On Feb 4, 2016, at 11:06 AM, Ralph Goers <ralph.go...@dslextreme.com>
>> wrote:
>>> 
>>> I don’t believe that issue is related to your problem.
>>> 
>>> When Log4j loads plugins it can only find plugins on whatever class path
>> it has available to it.  If it is in a different OSGi bundle than your
>> plugin it may not see it.  In short, Log4j has to be able to find
>> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat for
>> Log4j and the same file for your plugin. Log4j’s file is embedded in the
>> log4j-core jar. Yours will be in whatever jar you are producing. There is a
>> process for “shading” your code with Log4j’s that will cause them to be
>> combined, but I am afraid I don’t know exactly where that is documented. If
>> you want your stuff in a separate bundle from Log4j’s then you need to
>> figure out how to get the stuff in your bundle on Log4j’s classpath.
>>> 
>>> Ralph
>>> 
>>>> On Feb 4, 2016, at 10:39 AM, Nipuni Piyabasi Perera <
>> nipuni880...@gmail.com> wrote:
>>>> 
>>>> Hi all,
>>>> 
>>>> Above mentioned issue is reported and fixed in[1]. I have tried to use
>>>> log4j2- 2.0.1 (as this is the fix version of the jira) in my OSGi
>>>> environment. But I still see the same CLASS_NOT_FOUND error while it
>> works
>>>> fine in non-OSGi environment.
>>>> 
>>>> [1] https://issues.apache.org/jira/browse/LOG4J2-741
>>>> 
>>>> Thanks,
>>>> Nipuni
>>>> 
>>>> On Thu, Feb 4, 2016 at 9:24 AM, Nipuni Piyabasi Perera <
>>>> nipuni880...@gmail.com> wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> Thank you very much for the reply.
>>>>> 
>>>>> Initially I got error [1] when I am trying to test the appender in
>>>>> non-OSGi environment. This was due to not passing the correct number of
>>>>> parameters to the factory method. I have updated my log4j2.xml and then
>>>>> could solve the issue[1] in non-OSGi env. I have applied the same
>>>>> configuration to OSGi environment as well.
>>>>> 
>>>>> Now I am seeing error[2],which seems to be a class loading issue as you
>>>>> have mentioned. I did added the plugin processor in my pom.xml but
>> still
>>>>> seeing the same issue. While comparing the OSGi bundle and the
>> non-OSGi jar
>>>>> I could see that the Log4j2Plugins.dat file is missing in the OSGi
>> bundle. I
>>>>> have added the package name to configuration element as well. (as per
>> the
>>>>> pom.xml [3] I am using log4j2 2.5)
>>>>> 
>>>>> [1] Unable to invoke factory method in class ...
>>>>> [2] ERROR Error processing element HTTPSocket: CLASS_NOT_FOUND
>>>>> [3] Adding the plugin section of my pom.xml
>>>>> 
>>>>> <plugins>
>>>>>  <plugin>
>>>>>      <groupId>org.apache.felix</groupId>
>>>>>      <artifactId>maven-scr-plugin</artifactId>
>>>>>      <version>1.9.0</version>
>>>>>      <executions>
>>>>>          <execution>
>>>>>              <id>generate-scr-scrdescriptor</id>
>>>>>              <goals>
>>>>>                  <goal>scr</goal>
>>>>>              </goals>
>>>>>          </execution>
>>>>>      </executions>
>>>>>  </plugin>
>>>>>  <plugin>
>>>>>      <groupId>org.apache.maven.plugins</groupId>
>>>>>      <artifactId>maven-compiler-plugin</artifactId>
>>>>>      <version>3.1</version>
>>>>>      <executions>
>>>>>          <execution>
>>>>>              <id>log4j-plugin-processor</id>
>>>>>              <goals>
>>>>>                  <goal>compile</goal>
>>>>>              </goals>
>>>>>              <phase>process-classes</phase>
>>>>>              <configuration>
>>>>>                  <proc>only</proc>
>>>>>                  <annotationProcessors>
>>>>> 
>> <annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</annotationProcessor>
>>>>>                  </annotationProcessors>
>>>>>              </configuration>
>>>>>          </execution>
>>>>>      </executions>
>>>>>  </plugin>
>>>>>  <plugin>
>>>>>      <groupId>org.apache.felix</groupId>
>>>>>      <artifactId>maven-bundle-plugin</artifactId>
>>>>>      <extensions>true</extensions>
>>>>>      <configuration>
>>>>>          <instructions>
>>>>>              <Bundle-Vendor>Nipuni</Bundle-Vendor>
>>>>> 
>> <Bundle-SymbolicName>org.my.custom.http.socket.appender</Bundle-SymbolicName>
>>>>> 
>> <Bundle-Name>org.my.custom.http.socket.appender</Bundle-Name>
>>>>>              <Bundle-Version>1.0.0</Bundle-Version>
>>>>>              <Import-Package>
>>>>>                  org.apache.log4j.*;version="[2.5.0,3.0.0)"
>>>>>              </Import-Package>
>>>>>              <Export-Package>
>>>>>                  org.my.custom.http.socket.appender.*;version="1.0.0"
>>>>>              </Export-Package>
>>>>>              <DynamicImport-Package>*</DynamicImport-Package>
>>>>>          </instructions>
>>>>>      </configuration>
>>>>>  </plugin>
>>>>> 
>>>>> </plugins>
>>>>> 
>>>>> 
>>>>> Thanks,
>>>>> Nipuni
>>>>> 
>>>>> On Thu, Feb 4, 2016 at 4:31 AM, Remko Popma <remko.po...@gmail.com>
>> wrote:
>>>>> 
>>>>>> Thanks for confirming that.
>>>>>> 
>>>>>> You may avoid the classloader issues by combining the log4j jars and
>> your
>>>>>> custom appender in a single jar.
>>>>>> 
>>>>>> The only tricky part here is that you'd need to combine the serialized
>>>>>> plugin listing files (see
>>>>>> http://logging.apache.org/log4j/2.x/manual/plugins.html) from the
>>>>>> various log4j jars into a single serialized plugin listing file in
>> your
>>>>>> superjar.
>>>>>> 
>>>>>> See the source code for PluginProcessor for more details.
>>>>>> 
>> https://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.html
>>>>>> 
>>>>>> Sent from my iPhone
>>>>>> 
>>>>>>> On 2016/02/03, at 23:54, Nipuni Piyabasi Perera <
>> nipuni880...@gmail.com>
>>>>>> wrote:
>>>>>>> 
>>>>>>> Hi all,
>>>>>>> 
>>>>>>> As I have mentioned in my first mail, the issue is only in the OSGi
>>>>>>> environment it seems. I had mistakenly added the appender as a OSGi
>>>>>> bundle
>>>>>>> in the non-OSGi environment. Could resolve the issue after changing
>> the
>>>>>>> package to a jar.
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> Nipuni
>>>>>>> 
>>>>>>> On Wed, Feb 3, 2016 at 7:41 PM, Nipuni Piyabasi Perera <
>>>>>>> nipuni880...@gmail.com> wrote:
>>>>>>> 
>>>>>>>> Thanks for the prompt reply.
>>>>>>>> 
>>>>>>>> I have first tried my custom appender in OSGi environment which gave
>>>>>> the
>>>>>>>> errors above. But I am getting the same issue in non-OSGi
>> environment
>>>>>> too.
>>>>>>>> It seems an issue with custom appender.
>>>>>>>> AFAIK It is plugin annotation that make the appender visible to
>>>>>> log4j2. I
>>>>>>>> can't find any issue in my log4j2.xml and plugin configuration of
>> the
>>>>>>>> class. Is there any other places that I need to care about?
>>>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> Nipuni
>>>>>>>> 
>>>>>>>> On Wed, Feb 3, 2016 at 7:28 PM, Ralph Goers <
>>>>>> ralph.go...@dslextreme.com>
>>>>>>>> wrote:
>>>>>>>> 
>>>>>>>>> OSGi does interesting things with ClassLoaders. Log4j has to be
>> able
>>>>>> to
>>>>>>>>> access your plugin when it is configuring. If it isn’t in an
>>>>>> accessible
>>>>>>>>> ClassLoader it won’t see it.  There have been a few people who are
>>>>>> using
>>>>>>>>> Log4j in an OSGi environment that have helped out with patches from
>>>>>> time to
>>>>>>>>> time. Perhaps one of them can help out?
>>>>>>>>> 
>>>>>>>>> Ralph
>>>>>>>>> 
>>>>>>>>>>> On Feb 3, 2016, at 6:07 AM, Nipuni Piyabasi Perera <
>>>>>>>>>> nipuni880...@gmail.com> wrote:
>>>>>>>>>> 
>>>>>>>>>> Hi,
>>>>>>>>>> 
>>>>>>>>>> I have written a custom appender extending the log4j2
>>>>>> AbstractAppender.
>>>>>>>>> But
>>>>>>>>>> I am getting a runtime error[1]. I have added the plugin
>>>>>> annotation[2]
>>>>>>>>> as
>>>>>>>>>> per the manual and the custom appender class contains factory
>> method
>>>>>>>>>> createAppender() as well. I also have added the package name to
>>>>>>>>>> configuration element.
>>>>>>>>>> What am I missing here? Appreciate any input on this.
>>>>>>>>>> 
>>>>>>>>>> I have my log4j2.xml file as below:
>>>>>>>>>> 
>>>>>>>>>> <Configuration packages="org.my.custom.http.socket.appender">
>>>>>>>>>> <Appenders>
>>>>>>>>>>    ...
>>>>>>>>>>    <Socket name="socket" host="localhost" port="4714">
>>>>>>>>>>  <!--PatternLayout pattern="[%d] %5p {%c} - %m%ex%n"/-->
>>>>>>>>>> </Socket>
>>>>>>>>>>    <HTTPSocket name="HTTP_APPENDER" host="localhost" port="8888">
>>>>>>>>>> <-------------------------------------
>>>>>>>>>> New Appender
>>>>>>>>>> </HTTPSocket>
>>>>>>>>>> </Appenders>
>>>>>>>>>> <Loggers>
>>>>>>>>>>    <Root level="info" includeLocation="true">
>>>>>>>>>>        ...
>>>>>>>>>>        <AppenderRef ref="HTTP_APPENDER"/>
>>>>>>>>>>    </Root>
>>>>>>>>>>    <Logger name="my.custom.deployer" level="info"
>>>>>> additivity="true">
>>>>>>>>>>            <AppenderRef ref="socket"/>
>>>>>>>>>> </Logger>
>>>>>>>>>> </Loggers>
>>>>>>>>>> </Configuration>
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> [1] ERROR Appenders contains an invalid element or attribute
>>>>>>>>> "HTTPSocket"
>>>>>>>>>> [2] @Plugin(name = "HTTPSocket", category = "Core", elementType =
>>>>>>>>> "appender",
>>>>>>>>>> printObject = true)
>>>>>>>>>> 
>>>>>>>>>> Thanks,
>>>>>>>>>> Nipuni
>>>>>>>>>> 
>>>>>>>>>> --
>>>>>>>>>> Nipuni Perera
>>>>>>>>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>>>>>>>>> Email: nip...@wso2.com
>>>>>>>>>> Git hub profile: https://github.com/nipuni
>>>>>>>>>> Blog : http://nipunipererablog.blogspot.com/
>>>>>>>>>> Mobile: +94 (71) 5626680
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>>>>>>>>> For additional commands, e-mail:
>> log4j-user-h...@logging.apache.org
>>>>>>>> 
>>>>>>>> 
>>>>>>>> --
>>>>>>>> Nipuni Perera
>>>>>>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>>>>>>> Email: nip...@wso2.com
>>>>>>>> Git hub profile: https://github.com/nipuni
>>>>>>>> Blog : http://nipunipererablog.blogspot.com/
>>>>>>>> Mobile: +94 (71) 5626680
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> --
>>>>>>> Nipuni Perera
>>>>>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>>>>>> Email: nip...@wso2.com
>>>>>>> Git hub profile: https://github.com/nipuni
>>>>>>> Blog : http://nipunipererablog.blogspot.com/
>>>>>>> Mobile: +94 (71) 5626680
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Nipuni Perera
>>>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>>>> Email: nip...@wso2.com
>>>>> Git hub profile: https://github.com/nipuni
>>>>> Blog : http://nipunipererablog.blogspot.com/
>>>>> Mobile: +94 (71) 5626680
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Nipuni Perera
>>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>>> Email: nip...@wso2.com
>>>> Git hub profile: https://github.com/nipuni
>>>> Blog : http://nipunipererablog.blogspot.com/
>>>> Mobile: +94 (71) 5626680
>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>> 
>> 
> 
> 
> -- 
> Nipuni Perera
> Software Engineer; WSO2 Inc.; http://wso2.com
> Email: nip...@wso2.com
> Git hub profile: https://github.com/nipuni
> Blog : http://nipunipererablog.blogspot.com/
> Mobile: +94 (71) 5626680



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to