No. But I want to expose it to all other osgi bundles in the containers. So
I also added <Export-Package>*</Export-Package> in the pom.xml. But still
getting the error Could not instantiate class
[net.logstash.log4j.JSONEventLayoutV1].


On Mon, Feb 29, 2016 at 4:21 PM, Achim Nierbeck [via Karaf] <
[email protected]> wrote:

> Do you have a bundle in your container, which actually also exports that
> package/class?
>
> regards, Achim
>
> 2016-02-29 11:47 GMT+01:00 D <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4045618&i=0>>:
>
>> Hi,
>>
>> I set <Import-Package>*;resolution:=optional</Import-Package> but still
>> getting the exception Could not instantiate class
>> [net.logstash.log4j.JSONEventLayoutV1].
>>
>> My entire pom.xml looks like below:-
>>
>> <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
>> http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd";>
>>   <modelVersion>4.0.0</modelVersion>
>>   <groupId>net.logstash.log4j</groupId>
>>   <artifactId>jsonevent-layout</artifactId>
>>   <packaging>jar</packaging>
>>   <version>1.8-SNAPSHOT</version>
>>   <name>jsonevent-layout</name>
>>   <description>Log4j pattern layout that conforms to the logstash
>> json_event format</description>
>>   <url>http://logstash.net</url>
>>   <licenses>
>>     <license>
>>       <name>The Apache Software License, Version 2.0</name>
>>       <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
>>       <distribution>repo</distribution>
>>     </license>
>>   </licenses>
>>   <developers>
>>     <developer>
>>       <id>lusis</id>
>>       <name>John E. Vincent</name>
>>       <email>lusis.org+[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=1></email>
>>     </developer>
>>     <developer>
>>       <id>pyr</id>
>>       <name>Pierre-Yves Ritschard</name>
>>       <email>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=2></email>
>>     </developer>
>>   </developers>
>>   <properties>
>>       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>
>> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>>   </properties>
>>   <parent>
>>     <groupId>org.sonatype.oss</groupId>
>>     <artifactId>oss-parent</artifactId>
>>     <version>7</version>
>>   </parent>
>>   <scm>
>>     <connection>scm:git:[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=3>:g[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=4>:
>> logstash/log4j-jsonevent-layout.git</connection>
>>     <developerConnection>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=5>:
>> logstash/log4j-jsonevent-layout.git</developerConnection>
>>     <url>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=6>
>> :logstash/log4j-jsonevent-layout.git</url>
>>
>>   </scm>
>>   <build>
>>     <pluginManagement>
>>       <plugins>
>>         <plugin>
>>           <artifactId>maven-assembly-plugin</artifactId>
>>           <version>2.2.2</version>
>>           <executions>
>>             <execution>
>>               <id>uberjar</id>
>>               <phase>package</phase>
>>               <goals>
>>                 <goal>single</goal>
>>               </goals>
>>             </execution>
>>           </executions>
>>           <configuration>
>>             <descriptorRefs>
>>               <descriptorRef>jar-with-dependencies</descriptorRef>
>>             </descriptorRefs>
>>           </configuration>
>>         </plugin>
>>         <plugin>
>>           <groupId>org.apache.maven.plugins</groupId>
>>           <artifactId>maven-compiler-plugin</artifactId>
>>           <version>2.3.2</version>
>>           <configuration>
>>             <source>1.5</source>
>>             <target>1.5</target>
>>           </configuration>
>>         </plugin>
>>         <plugin>
>>           <groupId>org.apache.maven.plugins</groupId>
>>           <artifactId>maven-source-plugin</artifactId>
>>           <executions>
>>             <execution>
>>               <id>attach-sources</id>
>>               <goals>
>>                 <goal>jar</goal>
>>               </goals>
>>             </execution>
>>           </executions>
>>         </plugin>
>>       <plugin>
>>         <groupId>org.apache.maven.plugins</groupId>
>>         <artifactId>maven-javadoc-plugin</artifactId>
>>         <executions>
>>           <execution>
>>             <id>attach-javadocs</id>
>>             <goals>
>>               <goal>jar</goal>
>>             </goals>
>>           </execution>
>>         </executions>
>>       </plugin>
>>     </plugins>
>>   </pluginManagement>
>>   </build>
>>   <dependencies>
>>     <dependency>
>>       <groupId>net.minidev</groupId>
>>       <artifactId>json-smart</artifactId>
>>       <version>1.1.1</version>
>>     </dependency>
>>     <dependency>
>>       <groupId>log4j</groupId>
>>       <artifactId>log4j</artifactId>
>>       <version>1.2.16</version>
>>       <scope>provided</scope>
>>     </dependency>
>>     <dependency>
>>       <groupId>commons-lang</groupId>
>>       <artifactId>commons-lang</artifactId>
>>       <version>2.6</version>
>>     </dependency>
>>     <dependency>
>>       <groupId>junit</groupId>
>>       <artifactId>junit</artifactId>
>>       <version>4.8.1</version>
>>       <scope>test</scope>
>>     </dependency>
>>   </dependencies>
>>   <profiles>
>>       <profile>
>>           <id>bundle</id>
>>           <build>
>>               <plugins>
>>                   <plugin>
>>                       <groupId>org.apache.felix</groupId>
>>                       <artifactId>maven-bundle-plugin</artifactId>
>>                       <version>2.3.7</version>
>>                       <extensions>true</extensions>
>>                       <configuration>
>>                           <instructions>
>>
>> <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
>>
>>
>> <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
>>
>> <Import-Package>*;resolution:=optional</Import-Package>
>>
>>
>> <Fragment-Host>org.ops4j.pax.logging.pax-logging-service;bundle-version="[1.6,1.7)"</Fragment-Host>
>>
>> <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
>>
>> <Implementation-Version>${project.version}</Implementation-Version>
>>                           </instructions>
>>                       </configuration>
>>                   </plugin>
>>               </plugins>
>>           </build>
>>       </profile>
>>     <profile>
>>       <id>release-sign-artifacts</id>
>>       <activation>
>>         <property>
>>           <name>performRelease</name>
>>           <value>true</value>
>>         </property>
>>       </activation>
>>       <build>
>>         <plugins>
>>           <plugin>
>>             <groupId>org.apache.maven.plugins</groupId>
>>             <artifactId>maven-gpg-plugin</artifactId>
>>             <executions>
>>               <execution>
>>                 <id>sign-artifacts</id>
>>                 <phase>verify</phase>
>>                 <goals>
>>                   <goal>sign</goal>
>>                 </goals>
>>               </execution>
>>             </executions>
>>           </plugin>
>>           <plugin>
>>               <groupId>org.apache.felix</groupId>
>>               <artifactId>maven-bundle-plugin</artifactId>
>>               <version>2.3.7</version>
>>               <extensions>true</extensions>
>>               <configuration>
>>                   <instructions>
>>
>> <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
>>
>>
>> <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
>>
>> <Import-Package>*;resolution:=optional</Import-Package>
>>
>>
>> <Fragment-Host>org.ops4j.pax.logging.pax-logging-service;bundle-version="[1.6,1.7)"</Fragment-Host>
>>
>> <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
>>
>> <Implementation-Version>${project.version}</Implementation-Version>
>>                   </instructions>
>>               </configuration>
>>           </plugin>
>>         </plugins>
>>       </build>
>>     </profile>
>>   </profiles>
>> <distributionManagement>
>>   <snapshotRepository>
>>     <id>ossrh</id>
>>     <url>https://oss.sonatype.org/content/repositories/snapshots</url>
>>   </snapshotRepository>
>>   <repository>
>>     <id>ossrh</id>
>>     <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/
>> </url>
>>   </repository>
>> </distributionManagement>
>> </project>
>>
>>
>>
>> On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4045618&i=7>>
>> wrote:
>>
>> > Hi,
>> >
>> > you have an import-package with !* so you import nothing.
>> > My guess, that is wrong as it should actually import something as it
>> can't
>> > call the desired class.
>> > You should make sure your own bundle/fragment does import the correct
>> > packages.
>> >
>> > regards, Achim
>> >
>> >
>> > 2016-02-29 11:18 GMT+01:00 Debraj Manna <[hidden email]
>> > <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
>> >
>> >> Thanks Achim for replying.
>> >>
>> >> I tried to have a fragment bundle of  JSONEvenLayout
>> >> <https://github.com/logstash/log4j-jsonevent-layout> . But whenever I
>> am
>>
>> >> trying to start Karaf I am getting the below exception. I have listed
>> down
>> >> all the steps that I have been doing. Can you let me know what I am
>> doing
>> >> wrong?
>> >>
>> >> ]log4j:ERROR Could not instantiate class [net.logstash.log4j.
>> >> JSONEventLayoutV1].
>> >> java.lang.ClassNotFoundException: net.logstash.log4j.JSONEventLayoutV1
>> >> not found by org.ops4j.pax.logging.pax-logging-service [5]
>> >>     at
>> >>
>> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
>> >>
>> >>     at
>> >>
>> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
>> >>
>> >>     at
>> >>
>> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
>> >>
>> >>     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> >>     at java.lang.Class.forName0(Native Method)
>> >>     at java.lang.Class.forName(Class.java:264)
>> >>     at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
>> >>     at
>> >>
>> org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:129)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
>> >>
>> >>     at
>> >>
>> org.apache.log4j.PaxLoggingConfigurator.doConfigure(PaxLoggingConfigurator.java:72)
>> >>
>> >>     at
>> >>
>> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:214)
>> >>
>> >>     at
>> >>
>> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:362)
>> >>
>> >>     at
>> >>
>> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
>> >>
>> >>     at
>> >>
>> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
>> >>
>> >>     at
>> >>
>> org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
>> >>
>> >>     at
>> >>
>> org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1747)
>> >>
>> >>     at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
>> >>     at java.lang.Thread.run(Thread.java:745)
>> >> log4j:ERROR No layout set for the appender named [out].
>> >>
>> >>
>> >>
>> >> The steps that I have followed.
>> >>
>> >> 1. Modified the pom.xml file of jsonevent-layout as shown below:-
>> >>
>> >> <plugin>
>> >> <groupId>org.apache.felix</groupId>
>> >> <artifactId>maven-bundle-plugin</artifactId>
>> >> <version>2.3.7</version>
>> >> <extensions>true</extensions>
>> >> <configuration>
>> >>     <instructions>
>> >>
>> >> <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
>> >>
>> >>
>> <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
>> >>         <Import-Package>!*</Import-Package>
>> >>
>> >>
>> <Fragment-Host>org.ops4j.pax.logging.pax-logging-service;bundle-version="[1.6,1.7)"</Fragment-Host>
>> >>
>> >>
>> <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
>> >>
>> >> <Implementation-Version>${project.version}</Implementation-Version>
>> >>     </instructions>
>> >> </configuration>
>> >> </plugin>
>> >>
>> >> 2. Build json format using mvn clean install -Pbundle
>> >>
>> >> 3. Copy bundle created to system directory
>> >>
>> >>     mkdir -p
>> ${karaf.home}/system/net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/
>> >>
>> >>     cp target/jsonevent-layout-1.8-SNAPSHOT.jar
>> >> ${karaf.home}/system/net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/
>> >>
>> >> 4. Add this line to etc/startup.properties before Pax Logging
>> >>
>>  
>> net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/jsonevent-layout-1.8-SNAPSHOT.jar=3
>> >>
>> >>     mvn\:org.ops4j.pax.url/pax-url-aether/2.4.1 = 5
>> >>     mvn\:org.ops4j.pax.url/pax-url-wrap/2.4.1/jar/uber = 5
>> >>     mvn\:org.ops4j.pax.logging/pax-logging-api/1.8.4 = 8
>> >>     mvn\:org.ops4j.pax.logging/pax-logging-service/1.8.4 = 8
>> >>     Updated org.ops4j.pax.logging.cfg as follows:-
>> >>     log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> >>     log4j.appender.stdout.layout=net.logstash.log4j.JSONEventLayoutV1
>> >>     log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} |
>> %-5.5p |
>> >> %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} -
>> >> %X{bundle.version} | %m%n
>> >>
>> >>
>> >>  Thanks,
>> >> Debraj
>> >>
>> >> On Mon, Feb 29, 2016 at 1:17 PM, Achim Nierbeck <[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> wrote:
>> >>
>> >>> Depends on if you have an appender that can do so.
>> >>> If you have such an appender, make sure to attach it to pax-logging.
>> >>> One known to work solution is to have a fragment bundle which attaches
>> >>> to the pax-logging service bundle (if it's a log4j 1.x bundle)
>> >>>
>> >>> regards, Achim
>> >>>
>> >>>
>> >>> 2016-02-29 6:46 GMT+01:00 D <[hidden email]
>> >>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
>> >>>
>> >>>> Is there a way we can make karaf log in JSON format?
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> View this message in context:
>> >>>>
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607.html
>> >>>> Sent from the Karaf - User mailing list archive at Nabble.com.
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>>
>> >>> Apache Member
>> >>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>> >>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
>> Committer
>> >>> & Project Lead
>> >>> blog <http://notizblog.nierbeck.de/>
>> >>> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>> >>>
>> >>> Software Architect / Project Manager / Scrum Master
>> >>>
>> >>>
>> >>
>> >
>> >
>> > --
>> >
>> > Apache Member
>> > Apache Karaf <http://karaf.apache.org/> Committer & PMC
>> > OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
>> Committer &
>> > Project Lead
>> > blog <http://notizblog.nierbeck.de/>
>> > Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>> >
>> > Software Architect / Project Manager / Scrum Master
>> >
>> >
>> >
>> > ------------------------------
>> > If you reply to this email, your message will be added to the discussion
>> > below:
>> >
>> >
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
>> > To unsubscribe from Karaf logging in JSON format, click here
>> > < > .
>> > NAML
>> > <
>> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >
>> >
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>
>
>
> --
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>
> Software Architect / Project Manager / Scrum Master
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045618.html
> To unsubscribe from Karaf logging in JSON format, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045619.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to