Java」タグアーカイブ

Jenkinsのshh-agentがつながらない

一気にすべてをアップデートしたので何が原因かわからないけどshh-agentがつながらなくなっている。

DockerのJenkinsからその中のssh-agentを使うというめんどくさそうな構成

これから細かく調べるが

FATAL: [ssh-agent] Could not find specified credentials
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] FATAL: Could not find a suitable ssh-agent provider

(スタックトレースは長くなるので下のほうに張り付け)

本来だと以下みたいになる

[ssh-agent] Using credentials (credentials名) 
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
$ docker exec 80f7594988d50d5a190f788b4ffab62d8902fb594ebfffe3c282f6ace8ee88ba ssh-agent

死んでいるのはこの辺の処理

SSHAgentの拡張ポイント使っているプラグインがないか、あるけどfactory.isSupported(launcher, listener)のとこでダメっぽい。

こいつかな?ssh-agentがキルできないと(≒すでに生きていないと)いけない判定がある

よくみたら0か1ならよかった。

あまりにもわからないからプラグインにログ入れてみたらstatus が126といっている。

ログの埋め方はこちら

[ssh-agent] Looking for ssh-agent implementation...
[Loaded]   Exec ssh-agent (binary ssh-agent on a remote machine)
status: 126

こちらをみると実効権限がないと。

[Loaded]   Exec ssh-agent (binary ssh-agent on a remote machine)
OCI runtime exec failed: exec failed: unable to start container process: exec: "ssh-agent": executable file not found in $PATH: unknown
status: 126

さらにログ埋めたらうえ

そしてさらにさまよったら、ssh-agent入れなきゃいけないのはjenkinsファイルに書いてあるimageなことにやっと気づいた。ブログ書きながらやったけどただのポカミスだ。。。

pipeline {
	agent {
		docker {
			image 'kyoshitake/maven'

長くなった元々のスタックトレース

Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 594109d1-aaf2-4c19-97c1-539affc618f2 java.lang.RuntimeException: [ssh-agent] Could not find a suitable ssh-agent provider. at com.cloudbees.jenkins.plugins.sshagent.SSHAgentStepExecution.initRemoteAgent(SSHAgentStepExecution.java:176) at com.cloudbees.jenkins.plugins.sshagent.SSHAgentStepExecution.start(SSHAgentStepExecution.java:64) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:323) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:180) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:163) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:178) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:182) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:152) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17) at org.jenkinsci.plugins.workflow.cps.LoggingInvoker.methodCall(LoggingInvoker.java:105) at WorkflowScript.run(WorkflowScript:18) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:666) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:395) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:393) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:665) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:288) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:544) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:543) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:276) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:275) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:481) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withCredentialsBlock(ModelInterpreter.groovy:480) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:274) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:586) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:585) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:272) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:356) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:355) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:261) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:618) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:617) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:259) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:254) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:90) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:116) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:85) at jdk.internal.reflect.GeneratedMethodAccessor167.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:152) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:146) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:146) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:423) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:331) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:295) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:97) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Finished: FAILURE

spring-boot-starter-parentのバージョンアップ時メモ

小さいシステムバージョンアップしようとしたら色々コンパイルエラー(他)が出たので作業しながらメモ残す。新バージョンのライブラリ(Junitとか)は極力新しい奴のデフォルトに合わせる予定だが、つらくなったら妥協する。

作業内容

  • 2.1.6.RELEASEから3.2.3
  • JDKは11から17(21のバイナリで17動作指定)

Junitのエラー

Junit4系から5系に変わりった。

以下2つがコンパイルエラー。

  • import org.junit.Test
  • import org.junit.runner

org.junit.jupiter.api.Test に代わってrunnerはいらない

import static org.junit.Assert.assertHOGE

import static org.junit.jupiter.api.Assertions.assertHOGEに

import javax.servlet.http.HttpServletRequest;

import jakarta.servlet.http.HttpServletRequest;にパッケージ名が変わっている

import org.hibernate.validator

jakarta.validation.constraints.HOGEへ

以下はいれてコンパイルエラーは消えるがすでに org.hibernate.validatorはDuplicateだった。

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>

import javax.persistence.HOGE

jakarta.persistence.HOGEへ

とりあえずコンパイルエラーは消えた。このあと実行時のやつらを

実行時のjar重複

Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts

こちらによるとほかの依存している奴と重複すると警告がでる。

依存関係から除外

		<dependency>
			<groupId>jp.co.epea</groupId>
			<artifactId>jpholiday</artifactId>
			<version>0.0.1</version>
			<exclusions>
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

LogLevelの型?

Failed to bind properties under 'logging.level.org.hibernate.sql' to org.springframework.boot.logging.LogLevel:

    Property: logging.level.org.hibernate.sql
    Value: "DUBUG"
    Origin: class path resource [application.properties] - 12:33
    Reason: failed to convert java.lang.String to org.springframework.boot.logging.LogLevel (caused by java.lang.IllegalArgumentException: No enum constant org.springframework.boot.logging.LogLevel.DUBUG)

Action:

Update your application's configuration. The following values are valid:

    DEBUG
    ERROR
    FATAL
    INFO
    OFF
    TRACE
    WARN

application.propertiesのログレベル指定をorg.springframework.boot.logging.LogLevel=DUBUGにしたらとりあえず動くけどそんなプロパティないと警告出ている。また、デバックログは出てないっぽい。そもそもなにも働いていないからエラーにもならないだけだな。

Description	Resource	Path	Location	Type
'org.springframework.boot.logging.LogLevel' is an unknown property.	application.properties	/momoyama-web/src/main/resources	line 12	Language Servers

あらためて確認すると

  • logging.level.sql=DEBUG
  • logging.level.org.hibernate.SQL=DEBUG
  • logging.level.org.hibernate.orm.jdbc.bind=TRACE

これらは使えるっぽい(上ふたつは多分同じものさす)

改めて設定したら使えた。クラスパスの反映とかがうまくいってないかったのかな?ちょっと様子見。

それはそうとSTSでapplication.properties触ろうとするとかなりの確率でフリーズする。

HHH90000025

HHH90000025: PostgreSQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
spring.jpa.database=POSTGRESQL
spring.datasource.driverClassName=org.postgresql.Driver

がいらなくなったらしい

HHH000489

HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)

調べ中

これはそういうものとここに書いてある。とりあえず受け入れる。

spring.datasource.hoge

spring.sql.init.hogeに変更

Excel形式の列名に変換

列のインデックスをExcelの列名(AからZでAAに続くやつ)に変換する処理。時々使うのでメモかねて。

colIndexの0がA。

    private static final Character[] COL_STRING = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
            'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

    public static String toExcelCol(int colIndex) {

        StringBuilder sb = new StringBuilder();
        while (true) {
            int div = colIndex / 26;
            int mod = colIndex % 26;
            sb.insert(0, COL_STRING[mod]);
            if (div == 0)
                break;
            colIndex = div - 1;
        }

        return sb.toString();
    }

colIndexマイナスのチェックなかったりとかとかは適宜修正で。