0

I'd a custom log4j custom appender, it works in my testing environment like:
C:\Log4jTest>java -cp . Log4jTest

But when configuring it into Karaf, when starting it always throws error: org.apache.felix.configadmin-1.2.8|[org.osgi.service.log.LogService, org.knopflerfish.service.log.LogService, org.ops4j.pax.logging.PaxLoggingService, org.osgi.service.cm.ManagedService, id=8, bundle=4]: Unexpected problem updating Configuration PID=org.ops4j.pax.logging, factoryPID=null, bundleLocation=mvn:org.ops4j.pax.logging/pax-logging-service/1.6.9 java.lang.NoClassDefFoundError: javax/crypto/SecretKey at com.microsoft.azure.storage.Credentials.(Credentials.java:63) at com.microsoft.azure.storage.StorageCredentialsAccountAndKey.(StorageCredentialsAccountAndKey.java:42) ......
My mvn POM.XML is very simple:

[<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.hcit.logger</groupId>
  <artifactId>cloud-logger-service</artifactId>
  <version>1.0.0</version>
  <packaging>bundle</packaging>
  <dependencies>
    <dependency>
      <groupId>org.ops4j.pax.logging</groupId>
      <artifactId>pax-logging-service</artifactId>
      <version>1.6.9</version>
    </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-storage</artifactId>
            <version>1.1.0</version>
        </dependency>
  </dependencies>
  <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>
            <Export-Package>com.hcit.logger</Export-Package>
            <Import-Package>!*</Import-Package>
            <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
            <_failok>true</_failok>
            <Fragment-Host>org.ops4j.pax.logging.pax-logging-service</Fragment-Host>
            <Implementation-Version>${project.version}</Implementation-Version>
            <Bundle-Version>${project.version}</Bundle-Version>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
]

And snippet of my org.ops4j.pax.logging.cfg:
....
log4j.appender.hafauditCloudLoggerAppender=com.hcit.logger.CloudLoggerAppender
log4j.appender.hafauditCloudLoggerAppender.Threshold=DEBUG
log4j.appender.hafauditCloudLoggerAppender.TableName=LoggerTable
log4j.category.com.gehcit.haf.audit.consumer = DEBUG,hafauditCloudLoggerAppender ......

I checked that my jre.properties did have the javax.crypto:
......
javax.crypto, \
javax.crypto.interfaces, \
javax.crypto.spec, \
......

I'm new to Karaf, and wonder how to resolve it? my JDK is jdk1.7.0_72 and thanks.

1 Answers1

0

Finally I found the tricks, if changing the config.properties by adding those components like this:
org.osgi.framework.bootdelegation=org.apache.karaf.jaas.boot,sun.,com.sun.,javax.transaction,javax.transaction.,javax.sql.,oracle.,com.microsoft.sqlserver., javax.crypto, javax.crypto., javax.xml., com.fasterxml.*

It works. of course in POM.xml should add the dependency of fasterxml:

   [<dependency>
       <groupId>de.matrixweb.smaller</groupId>
       <artifactId>ant</artifactId>
       <version>0.8.4</version>
    </dependency>]