I want to install org.postgresql/postgresql/9.4-1201-jdbc41 in Karaf but I get errors. How can I resolve these errors? Strangely on Windows my Karaf doesn't have errors with this Postgres jdbc but on Ubuntu it has these errors. Any clues appreciated.
Install Kar feature social_importer.kar/1.0-SNAPSHOT
java.lang.Exception: Could not start bundle
mvn:org.postgresql/postgresql/9.4-1201-jdbc41 in feature(s)
T: Unresolved constraint in bundle org.postgresql.jdbc41
[127]: Unable to resolve 127.0: missing requirement [127.0]
osgi.wiring.package; (osgi.wiring.package=javax.transaction.xa)
Caused by: org.osgi.framework.BundleException:
Unresolved constraint in bundle org.postgresql.jdbc41 [127]: Unable
to resolve 127.0: missing requirement [127.0] osgi.wiring.package;
(osgi.wiring.package=javax.transaction.xa)
This might be related Apache Felix not able to access Postgres JDBC
karaf#root()> install -s wrap:mvn:postgresql/postgresql/9.4-1201-jdbc41
Bundle IDs:
Error executing command: Error installing bundles:
Unable to install bundle wrap:mvn:postgresql/postgresql/9.4-1201-jdbc41
karaf#root()> install -s mvn:postgresql/postgresql/9.4-1201-jdbc41
Bundle IDs:
Error executing command: Error installing bundles:
Unable to install bundle mvn:postgresql/postgresql/9.4-1201-jdbc41
karaf#root()>
I looked in the Karaf logs with log level of INFO.
Caused by: java.lang.NoClassDefFoundError: org/osgi/service/jdbc/DataSourceFactory
at org.postgresql.osgi.PGBundleActivator.start(PGBundleActivator.java:32)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2154)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.osgi.service.jdbc.DataSourceFactory not found by org.postgresql.jdbc41 [5328]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)[org.apache.felix.framework-4.4.1.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_25]
Provisioning Postgresql JDBC Driver to Karaf 4.0.1
__ __ ____
/ //_/____ __________ _/ __/
/ ,< / __ `/ ___/ __ `/ /_
/ /| |/ /_/ / / / /_/ / __/
/_/ |_|\__,_/_/ \__,_/_/
Apache Karaf (4.0.1)
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
karaf#root()> feature:repo-add mvn:org.ops4j.pax.jdbc/pax-jdbc-features/0.7.0/xml/features
karaf#root()>feature:install pax-jdbc-spec
karaf#root()>feature:install transaction
karaf#root()>bundle:install -s mvn:org.postgresql/postgresql/9.4-1200-jdbc41
karaf#root()> service:list org.osgi.service.jdbc.DataSourceFactory
[org.osgi.service.jdbc.DataSourceFactory]
-----------------------------------------
osgi.jdbc.driver.class = org.postgresql.Driver
osgi.jdbc.driver.name = PostgreSQL JDBC Driver
osgi.jdbc.driver.version = PostgreSQL 9.4 JDBC4.1 (build 1200)
service.bundleid = 52
service.id = 113
service.scope = singleton
Provided by :
PostgreSQL JDBC Driver JDBC41 (52)
Definining a Postgres Pool Datasource to Karaf 4.0.1
Theory at: https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config
karaf#root()>feature:install pax-jdbc-config
karaf#root()>feature:install pax-jdbc-pool-dbcp2
Create file under KARAF_HOME/etc/org.ops4j.datasource-companymanager.cfg
where companymanager is the datasource name.
osgi.jdbc.driver.name=PostgreSQL JDBC Driver-pool-xa
serverName=localhost
databaseName=companymanager
portNumber=5432
user=postgres
password=admin
dataSourceName=companymanager
Voilá you are done, your datasource is exposed to OSGI registry ready to be used at your will:
karaf#root()> service:list javax.sql.DataSource
[javax.sql.DataSource]
----------------------
databaseName = companymanager
dataSourceName = companymanager
felix.fileinstall.filename = file:/C:/apache-karaf-4.0.1/etc/org.ops4j.datasource-companymanager.cfg
osgi.jdbc.driver.name = PostgreSQL JDBC Driver-pool-xa
osgi.jndi.service.name = companymanager
password = admin
portNumber = 5432
serverName = localhost
service.bundleid = 64
service.factoryPid = org.ops4j.datasource
service.id = 119
service.pid = org.ops4j.datasource.3cad9abf-49be-4868-8940-1623481b1363
service.scope = singleton
user = postgres
Provided by :
OPS4J Pax JDBC Config (64)
The next step will be perhaps set up JPA if you are interested, you can keep reading and get the full example code from:
https://github.com/antoniomaria/karaf4-eclipselink-jpa
Just tested with Karaf 4.0.0.M2:
OSGi compendium exports org.osgi.service.jdbc
__ __ ____
/ //_/____ __________ _/ __/
/ ,< / __ `/ ___/ __ `/ /_
/ /| |/ /_/ / / / /_/ / __/
/_/ |_|\__,_/_/ \__,_/_/
Apache Karaf (4.0.0.M2)
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
karaf#root()> feature:install transaction
karaf#root()> install -s mvn:org.osgi/org.osgi.compendium/5.0.0
Bundle ID: 51
karaf#root()> install -s wrap:mvn:org.postgresql/postgresql/9.4-1201- jdbc41
Bundle ID: 52
karaf#root()> list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
----------------------------------------------------------------------
51 | Active | 80 | 5.0.0.201305092017 | osgi.cmpn
52 | Active | 80 | 9.4.0.build-1201 | PostgreSQL JDBC Driver JDBC41
karaf#root()>
The Apache Karaf DataSources (JDBC) is an optional enterprise feature. In order to install the postgresql, please use the following statements.
karaf#root()> feature:install jdbc
karaf#root()> install -s mvn:org.postgresql/postgresql/9.4-1203-jdbc42
the above solution was tested on Karaf 4.0.1
Related
I have a Quarkus application and I'd like to display the application version as the Git commit SHA1, how do I do that?
The buildnumber-maven-plugin provides information about the current Git commit for the application as a maven property.
Make sure your pom.xml has it included and the src/main/resources/application.properties file is filtered by Maven, like the following:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Add the following to your src/main/resources/application.properties:
quarkus.application.version=${buildNumber}
The buildNumber property will be resolved and replaced during the maven build. The quarkus.application.version is a build-time property resolved during the Quarkus build (performed by the quarkus-maven-plugin).
If all steps were performed correctly, you should see an output as the following when running the application:
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-07-22 11:35:44,283 INFO [org.fly.cor.int.lic.VersionPrinter] (main) Flyway Community Edition 7.11.2 by Redgate
2021-07-22 11:35:44,284 INFO [org.fly.cor.int.dat.bas.BaseDatabaseType] (main) Database: jdbc:postgresql://localhost:5432/postgres (PostgreSQL 12.7)
2021-07-22 11:35:44,321 INFO [org.fly.cor.int.com.DbMigrate] (main) Current version of schema "public": 3
2021-07-22 11:35:44,322 INFO [org.fly.cor.int.com.DbMigrate] (main) Schema "public" is up to date. No migration necessary.
2021-07-22 11:35:45,080 INFO [io.quarkus] (main) quarkus-registry afd82c886d3d6fa60d1f29df642bf6565135ccef on JVM (powered by Quarkus 2.1.0.Final) started in 2.327s. Listening on: http://0.0.0.0:8080
HINT: you can resize the commit SHA by adding the maven.buildNumber.shortRevisionLength Maven property to your pom.xml:
<maven.buildNumber.shortRevisionLength>7</maven.buildNumber.shortRevisionLength>
My goal is to run CAS to replace ADFS. I thought starting with the docker image is a good place to begin.
I've tried running two different versions of apereo/cas and both have the same error.
Here's what I tried.
command
docker run -p 8080:8080 -p 8443:8443 apereo/cas:v5.3.2
output
__ ____ _ ____ __
/ / / ___| / \ / ___| \ \
| | | | / _ \ \___ \ | |
| | | |___ / ___ \ ___) | | |
| | \____| /_/ \_\ |____/ | |
\_\ /_/
CAS Version: 5.3.2
CAS Commit Id: 145d8c3dd5e27333dd05f5cc10987df4656fba5e
CAS Build Date/Time: 2018-07-30T21:09:46Z
Spring Boot Version: 1.5.14.RELEASE
Spring Version: 4.3.18.RELEASE
Java Home: /opt/zulu8.30.0.1-jdk8.0.172-linux_x64/jre
Java Vendor: Azul Systems, Inc.
Java Version: 1.8.0_172
JVM Free Memory: 24 MB
JVM Maximum Memory: 539 MB
JVM Total Memory: 52 MB
JCE Installed: Yes
Node Version: N/A
NPM Version: N/A
OS Architecture: amd64
OS Name: Linux
OS Version: 4.9.87-linuxkit-aufs
OS Date/Time: 2018-08-30T13:18:59.269
OS Temp Directory: /tmp
------------------------------------------------------------
Apache Tomcat Version: Apache Tomcat/8.5.32
------------------------------------------------------------
2018-08-30 13:18:59,416 INFO [org.apereo.cas.configuration.DefaultCasConfigurationPropertiesSourceLocator] - <Configuration directory [/etc/cas/config] is not a directory or cannot be found at the specific path>
2018-08-30 13:18:59,470 INFO [org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration] - <Located property source: CompositePropertySource [name='casCompositePropertySource', propertySources=[PropertiesPropertySource {name='embeddedYamlOverriddenProperties'}]]>
2018-08-30 13:18:59,500 INFO [org.apereo.cas.web.CasWebApplication] - <The following profiles are active: standalone>
2018-08-30 13:18:59,674 INFO [org.apereo.cas.web.CasWebApplicationContext] - <Refreshing CasWebApplicationContext()>
2018-08-30 13:19:09,553 WARN [org.apereo.cas.config.CasCoreTicketsConfiguration] - <Runtime memory is used as the persistence storage for retrieving and managing tickets. Tickets that are issued during runtime will be LOST when the web server is restarted. This MAY impact SSO functionality.>
2018-08-30 13:19:09,557 INFO [org.apereo.cas.util.CoreTicketUtils] - <Ticket registry encryption/signing is turned off. This MAY NOT be safe in a clustered production environment. Consider using other choices to handle encryption, signing and verification of ticket registry tickets, and verify the chosen ticket registry does support this behavior.>
2018-08-30 13:19:36,081 INFO [org.apereo.cas.config.CasConfigurationSupportUtilitiesConfiguration] - <CAS is configured to NOT watch configuration directory [/etc/cas/config]. Changes require manual reloads/restarts.>
2018-08-30 13:19:37,111 WARN [org.apereo.cas.config.support.authentication.AcceptUsersAuthenticationEventExecutionPlanConfiguration] - <>
2018-08-30 13:19:37,128 WARN [org.apereo.cas.config.support.authentication.AcceptUsersAuthenticationEventExecutionPlanConfiguration] - <
____ _____ ___ ____ _
/ ___| |_ _| / _ \ | _ \ | |
\___ \ | | | | | | | |_) | | |
___) | | | | |_| | | __/ |_|
|____/ |_| \___/ |_| (_)
CAS is configured to accept a static list of credentials for authentication. While this is generally useful for demo purposes, it is STRONGLY recommended that you DISABLE this authentication method (by setting 'cas.authn.accept.users' to a blank value) and switch to a mode that is more suitable for production.>
2018-08-30 13:19:37,129 WARN [org.apereo.cas.config.support.authentication.AcceptUsersAuthenticationEventExecutionPlanConfiguration] - <>
2018-08-30 13:19:50,183 INFO [org.apereo.cas.support.events.listener.CasConfigurationEventListener] - <Refreshing CAS configuration. Stand by...>
2018-08-30 13:19:51,182 WARN [org.apereo.cas.config.CasCoreServicesConfiguration] - <Runtime memory is used as the persistence storage for retrieving and persisting service definitions. Changes that are made to service definitions during runtime WILL be LOST when the web server is restarted. Ideally for production, you need to choose a storage option (JDBC, etc) to store and track service definitions.>
2018-08-30 13:19:51,278 INFO [org.apereo.cas.services.AbstractServicesManager] - <Loaded [0] service(s) from [InMemoryServiceRegistry].>
2018-08-30 13:19:51,931 WARN [org.apereo.cas.util.cipher.BaseStringCipherExecutor] - <Secret key for encryption is not defined for [Ticket-granting Cookie]; CAS will attempt to auto-generate the encryption key>
2018-08-30 13:19:51,956 WARN [org.apereo.cas.util.cipher.BaseStringCipherExecutor] - <Generated encryption key [eTqXF8ggwLZtTQEZCskBylE0S4px3iBbGcverLvO2Fs] of size [256] for [Ticket-granting Cookie]. The generated key MUST be added to CAS settings under setting [cas.tgc.crypto.encryption.key].>
2018-08-30 13:19:51,961 WARN [org.apereo.cas.util.cipher.BaseStringCipherExecutor] - <Secret key for signing is not defined for [Ticket-granting Cookie]. CAS will attempt to auto-generate the signing key>
2018-08-30 13:19:51,973 WARN [org.apereo.cas.util.cipher.BaseStringCipherExecutor] - <Generated signing key [ZJNEO4PuSX3og9E923KKcp6bVVHb7bajkqkP1B4_35ytg4rW5CPqRvFYuxzmBTHAvsaTnBRvKqe53F_4ulg5Rw] of size [512] for [Ticket-granting Cookie]. The generated key MUST be added to CAS settings under setting [cas.tgc.crypto.signing.key].>
2018-08-30 13:19:53,293 WARN [org.apereo.cas.util.cipher.BaseBinaryCipherExecutor] - <Secret key for signing is not defined under [cas.webflow.crypto.signing.key]. CAS will attempt to auto-generate the signing key>
2018-08-30 13:19:53,295 WARN [org.apereo.cas.util.cipher.BaseBinaryCipherExecutor] - <Generated signing key [txKypaRUGM0NyMfI9reKAPzMCEuTDO4xWh9J-G16rmp5l-ZWpqBR7bge1wPvAx0FdYw2j__4aI_6Q9qANFe5ng] of size [512]. The generated key MUST be added to CAS settings under setting [cas.webflow.crypto.signing.key].>
2018-08-30 13:19:53,297 WARN [org.apereo.cas.util.cipher.BaseBinaryCipherExecutor] - <Secret key for encryption is not defined under [cas.webflow.crypto.encryption.key]. CAS will attempt to auto-generate the encryption key>
2018-08-30 13:19:53,300 WARN [org.apereo.cas.util.cipher.BaseBinaryCipherExecutor] - <Generated encryption key [xUiptRY2-RuCvAFV39UJlg] of size [16]. The generated key MUST be added to CAS settings under setting [cas.webflow.crypto.encryption.key].>
2018-08-30 13:19:53,867 ERROR [org.apache.catalina.core.StandardService] - <Failed to start connector [Connector[HTTP/1.1-8443]]>
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8443]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:265) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:208) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
at org.apereo.cas.web.CasWebApplication.main(CasWebApplication.java:71) ~[cas-server-webapp-init-5.3.2.jar!/:5.3.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_172]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_172]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_172]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_172]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[cas.war:?]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[cas.war:?]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[cas.war:?]
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) ~[cas.war:?]
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
... 20 more
Caused by: java.lang.IllegalArgumentException: No aliases for private keys found in key store
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:116) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:87) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
... 20 more
Caused by: java.io.IOException: No aliases for private keys found in key store
at org.apache.tomcat.util.net.jsse.JSSEUtil.getKeyManagers(JSSEUtil.java:233) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:114) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:87) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) ~[tomcat-coyote-8.5.32.jar!/:8.5.32]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-catalina-8.5.32.jar!/:8.5.32]
... 20 more
I also tried a different version with no luck.
docker run -p 8080:8080 -p 8443:8443 apereo/cas:v5.2.2
This appears to be a problem with missing keys that I (think) need to be generated but I'm not sure if/where I need to mount a volume or what to do next.
FILE: /etc/cas/config/
keytool -genkeypair -alias cas -keyalg RSA \
-keypass changeit -storepass changeit \
-keystore $AP_HOME/etc/cas/thekeystore \
-dname "CN=localhost.xxx.com.tw,OU=xxx,OU=xxx,C=TW" \
-ext SAN="dns:localhost,ip:127.0.0.1,dns:`hostname`"
copy this file into container docker:
docker cp /etc/cas/thekeystore *container_name*:/etc/cas
I'd like to map the etc outside container, but maintains in container.
~/etc/cas/theKeystore
~/etc/cas/config/application.properties
~/etc/cas/config/cas.properties
~/etc/cas/config/log4j2.xml
~/cas-overlay: clone from github.
Try this
docker --name ...
-p 8443:8443 -p ...
-v ~/etc/cas:/etc/cas
-v ~/cas-overlay:/cas-overlay
...
I also maintain my project out of container.
such as modifing ~/etc/cas/config/application.properties, ...
and/or rebuilding cas.war, in ~/cas-overlay/mvnm package.
then restart this container dokcer.
I am new to Spring Cloud Task. I am trying to setup the Hello World Sample application. It runs and everything seems fine as per the example here.
However i see below output. I see some slf4j warnings. However my understanding is spring boot should provide default setup. Any reason why i see different log file?
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
Hello World!
My application.properties already have this.
logging.level.org.springframework.cloud.task=DEBUG
spring.application.name=demo
EDIT
When I have added spring batch starter to my pom the logs started displaying fine and the slf4j warning are gone. I guess slf4j configuration is missing if we only have spring cloud task. Is there any specific reason it is configured like that specific for spring cloud task ?
Based on the SLF4J documentation (https://www.slf4j.org/codes.html#StaticLoggerBinder), that error is due to the fact that you haven't added a logging impl. You can address this by adding the Spring Boot Starter for logging or add your own logging dependencies.
I'm trying to deploy the tmp1 branch of the Spring example application (A Spring Boot 1.3.4 application using JSP and having WAR packaging) to Pivotal Cloud Foundry, using STS Boot Dashboard. I have created a manifest.yml file, looking as below:
---
applications:
- name: np-spring-tutorial
buildpack: https://github.com/cloudfoundry/java-buildpack.git
path: target/spring-tutorial-0.0.1-SNAPSHOT.war
env:
application_url: http://np-spring-tutorial.cfapps.io
timeout: 180
The application gets deployed and seems to be running well; I'm able to view the pages. However, when starting it gives :SLF4J: Class path contains multiple SLF4J bindings" error. Here is the log:
[9 May, 2016 11:18:31 AM - Boot Dashboard] - Creating application: np-spring-tutorial
[9 May, 2016 11:18:38 AM - Boot Dashboard] - Verifying that the application was created successfully: np-spring-tutorial
Updated app with guid 7a95bd52-1c14-461b-a6df-59aeb7ba285a ({"environment_json"=>"PRIVATE DATA HIDDEN"})
[9 May, 2016 11:19:08 AM - Boot Dashboard] - Generating archive for application: np-spring-tutorial
[9 May, 2016 11:19:08 AM - Boot Dashboard] - Uploading archive to Cloud Foundry for application: np-spring-tutorial
[9 May, 2016 11:19:57 AM - Boot Dashboard] - Archive uploaded to Cloud Foundry for application: np-spring-tutorial
[9 May, 2016 11:20:02 AM - Boot Dashboard] - Starting application: np-spring-tutorial
[9 May, 2016 11:20:09 AM - Boot Dashboard] - Checking if the application is running. Please wait...
Updated app with guid 7a95bd52-1c14-461b-a6df-59aeb7ba285a ({"state"=>"STARTED"})
Creating container
Successfully created container
Downloading app package...
Downloaded app package (45.5M)
Staging...
-----> Java Buildpack Version: 78c3d0a | https://github.com/cloudfoundry/java-buildpack.git#78c3d0a
-----> Downloading Open Jdk JRE 1.8.0_91-unlimited-crypto from https://download.run.pivotal.io/openjdk/trusty/x86_64/openjdk-1.8.0_91-unlimited-crypto.tar.gz (1.9s)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.1s)
-----> Downloading Open JDK Like Memory Calculator 2.0.2_RELEASE from https://download.run.pivotal.io/memory-calculator/trusty/x86_64/memory-calculator-2.0.2_RELEASE.tar.gz (0.0s)
Memory Settings: -Xss1M -Xmx768M -XX:MaxMetaspaceSize=104857K -Xms768M -XX:MetaspaceSize=104857K
-----> Downloading Container Customizer 1.0.0_RELEASE from https://download.run.pivotal.io/container-customizer/container-customizer-1.0.0_RELEASE.jar (0.0s)
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (45.4M)
Uploaded droplet (91.1M)
Creating container
Successfully created container
Starting health monitoring of container
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
java.lang.AbstractMethodError: ch.qos.logback.classic.pattern.EnsureExceptionHandling.process(Lch/qos/logback/core/Context;Lch/qos/logback/core/pattern/Converter;)V
at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:85)
at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28)
at ch.qos.logback.classic.BasicConfigurator.configure(BasicConfigurator.java:50)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:164)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:140)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:119)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:328)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:280)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:191)
at com.naturalprogrammer.spring.tutorial.NpSpringTutorialApplication.main(NpSpringTutorialApplication.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
at java.lang.Thread.run(Thread.java:745)
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
... 1 more
Caused by: java.lang.AbstractMethodError: ch.qos.logback.classic.pattern.EnsureExceptionHandling.process(Lch/qos/logback/core/Context;Lch/qos/logback/core/pattern/Converter;)V
at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:85)
at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28)
at org.springframework.boot.logging.logback.LogbackConfigurator.start(LogbackConfigurator.java:112)
at org.springframework.boot.logging.logback.DefaultLogbackConfiguration.consoleAppender(DefaultLogbackConfiguration.java:121)
at org.springframework.boot.logging.logback.DefaultLogbackConfiguration.apply(DefaultLogbackConfiguration.java:78)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadDefaults(LogbackLoggingSystem.java:124)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:74)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:49)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:262)
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:233)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.naturalprogrammer.spring.tutorial.NpSpringTutorialApplication.main(NpSpringTutorialApplication.java:14)
... 6 more
Exit status 0
Exit status 0
App instance exited with guid 7a95bd52-1c14-461b-a6df-59aeb7ba285a payload: {"instance"=>"3c98e26d-7714-45b8-6152-df1ae08c2025", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Codependent step exited\n* cancelled\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1462773044776529510, "version"=>"8cf24bda-13e6-49a6-8b52-906440c1b780"}
Creating container
Successfully created container
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.4.RELEASE)
2016-05-09 05:50:52.875 INFO 29 --- [ main] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext
2016-05-09 05:50:52.963 INFO 29 --- [ main] nfigurationApplicationContextInitializer : Adding cloud service auto-reconfiguration to ApplicationContext
2016-05-09 05:50:52.978 INFO 29 --- [ main] c.n.s.t.NpSpringTutorialApplication : Starting NpSpringTutorialApplication on ip3ju5q5j6m with PID 29 (/home/vcap/app/WEB-INF/classes started by vcap in /home/vcap/app)
...
2016-05-09 05:51:07.749 INFO 29 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-05-09 05:51:08.376 INFO 29 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
Container became healthy
2016-05-09 05:51:08.720 INFO 29 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-05-09 05:51:10.014 INFO 29 --- [ main] c.n.s.t.NpSpringTutorialApplication : Started NpSpringTutorialApplication in 18.612 seconds (JVM running for 19.599)
[9 May, 2016 11:21:22 AM - Boot Dashboard] - Application appears to have started - np-spring-tutorial
Any idea how to fix this? (This question has originated from this one)
Update
As recommended by Gemini, checking the WAR, I indeed see two logback-classic-x.x.x.jars:
However, looking at the maven dependency tree, I see only the 1.1.7 version of logback, as below:
So, what could be going wrong? Maybe the spring-boot-maven-plugin is doing something?
There should be only one implementation of slf4j in your classpath. Please check your project dependencies and remove one of them.
From what you've posted, there are two jars jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.3.jar and jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.7.jar in your application, which should be mistake.
You can just keep one of them and remove the one you don't want to use, for example, keep the newer and remove the older. It should be fine.
If you are using maven to management your dependencies, you can check the full dependencies and make sure there is only one of them exist(exclude the one you do not want to use). If they are added manually, you can manually remove it and repackage your application. It'll work.
I Use the following 2 commands to install the hawtio feature in apache karaf
features:addurl mvn:io.hawt/hawtio-karaf/1.4.17/xml/features
features:install hawtio
When I run "features:install hawtio" I get the following error
"Error executing command: Could not start bundle mvn:io.hawt/hawtio-osgi-jmx/1.4.17 in feature(s) hawtio-core-1.4.17: Activator start error in bundle io.hawt.hawtio-osgi-jmx [286]"
Could you help me fix this.
Works fine for me
davsclaus:/opt/apache-karaf-2.3.7/$ bin/karaf
__ __ ____
/ //_/____ __________ _/ __/
/ ,< / __ `/ ___/ __ `/ /_
/ /| |/ /_/ / / / /_/ / __/
/_/ |_|\__,_/_/ \__,_/_/
Apache Karaf (2.3.7)
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'osgi:shutdown' or 'logout' to shutdown Karaf.
karaf#root> features:addurl mvn:io.hawt/hawtio-karaf/1.4.17/xml/features
karaf#root> features:install hawtio
karaf#root> web:list
ID State Web-State Level Web-ContextPath Name
[ 86] [Active ] [Deployed ] [ 80] [/hawtio ] hawtio :: hawtio-web (1.4.17)
[ 88] [Active ] [Deployed ] [ 80] [/hawtio-karaf-terminal ] hawtio :: Karaf terminal plugin (1.4.17)
karaf#root>
And btw there is shortcut to add hawtio, by
features:chooseurl hawtio 1.4.17
So you need to check the logs what is failing for you, you can use log:display or check the data/logs directory of Apache Karaf.
I was using the wrong Java version, I was using 1.6.x the compatible version for hawtio 1.4.17 is Java 1.7.x