Eine Namensausnahme erfolgt beim Ausführen eines Frühlingsprojekts als ausführbare Datei (EXE)Java

Java-Forum
Guest
 Eine Namensausnahme erfolgt beim Ausführen eines Frühlingsprojekts als ausführbare Datei (EXE)

Post by Guest »

Ich entwickle eine Desktop -Anwendung, die Spring und OpenJFX kombiniert, aber ich habe ein Problem, bei dem die von JPackage erstellte ausführbare Datei nicht korrekt funktioniert. Beim Überprüfen der Protokolle stellte ich fest, dass ein Javax/Naming/NamingException-Fehler auftritt.

Code: Select all

.   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/

:: Spring Boot ::                (v3.4.2)

2025-02-13T21:53:15.250+09:00  INFO 9960 --- [JavaFX-Launcher] o.s.boot.SpringApplication               : Starting application using Java 22.0.1 with PID 9960 (started by tako21osan in C:\Users\tako21osan\Desktop\250205\myapp\myapp\myapp\MyApp)
2025-02-13T21:53:15.253+09:00  INFO 9960 --- [JavaFX-Launcher] o.s.boot.SpringApplication               : No active profile set, falling back to 1 default profile: "default"
2025-02-13T21:53:15.694+09:00  WARN 9960 --- [JavaFX-Launcher] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [test.myapp.MyApp]: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration due to javax/naming/NamingException not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
2025-02-13T21:53:15.703+09:00  INFO 9960 --- [JavaFX-Launcher] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-02-13T21:53:15.720+09:00 ERROR 9960 --- [JavaFX-Launcher] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [test.myapp.MyApp]: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration due to javax/naming/NamingException not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g.  if you put a @ComponentScan in the default package by mistake)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:613) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:836) ~[spring-context-6.2.2.jar:6.2.2]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:833) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:803) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:418) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:290) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149) ~[spring-boot-3.4.2.jar:3.4.2]
at test.myapp.MyApp.init(MyApp.java:22) ~[myapp-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:817) ~[javafx.graphics:na]
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196) ~[javafx.graphics:na]
at java.base/java.lang.Thread.run(Thread.java:1570) ~[na:na]
Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration due to javax/naming/NamingException not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:54) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:99) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:233) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:413) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:294) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:267) ~[spring-context-6.2.2.jar:6.2.2]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:603) ~[spring-context-6.2.2.jar:6.2.2]
...  19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/naming/NamingException
at org.springframework.boot.jdbc.DataSourceBuilder$HikariDataSourceProperties.(DataSourceBuilder.java:611) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.lookup(DataSourceBuilder.java:439) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.lookupPooled(DataSourceBuilder.java:405) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.forType(DataSourceBuilder.java:395) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.jdbc.DataSourceBuilder.findType(DataSourceBuilder.java:267) ~[spring-boot-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceAvailableCondition.getMatchOutcome(DataSourceAutoConfiguration.java:118) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberOutcomes.getConditionOutcome(AbstractNestedCondition.java:195) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberOutcomes.(AbstractNestedCondition.java:189) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.lambda$getMatchOutcomes$0(AbstractNestedCondition.java:169) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:986) ~[na:na]
at org.springframework.util.MultiValueMapAdapter.forEach(MultiValueMapAdapter.java:179) ~[spring-core-6.2.2.jar:6.2.2]
at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1708) ~[na:na]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMatchOutcomes(AbstractNestedCondition.java:169) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberMatchOutcomes.(AbstractNestedCondition.java:78) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition.getMatchOutcome(AbstractNestedCondition.java:63) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-3.4.2.jar:3.4.2]
... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
... 41 common frames omitted
< /code>
Die gleiche Ausnahme trat auch dann auf, wenn ich ein minimales Projekt erstellt habe, um die Ursache zu isolieren. Wenn Sie Informationen oder Lösungen zu ähnlichen Problemen mit NamensException haben, würde ich mich darüber freuen, wenn Sie es mich wissen lassen.  In Zukunft denke ich darüber nach, Tomcat vorzustellen und mit OpenJFX WebView zu kombinieren.jpackage --type app-image --win-console --input ".\target" --name MyApp --main-class "test.myapp.MyApp" --main-jar "myapp-1.0-SNAPSHOT.jar" --runtime-image ".\target\jre_set" --dest ".\"
< /code>
Application.yml
spring:
datasource:
url: 'jdbc:sqlite:file::memory:?cache=shared'
driver-class-name: org.sqlite.JDBC
jpa:
show-sql: true
properties:
hibernate:
dialect: 'org.hibernate.community.dialect.SQLiteDialect'

logging:
level:
org.hibernate.SQL: DEBUG
#org.hibernate.type.descriptor.sql.BasicBinder: TRACE
#org.springframework.boot.autoconfigure: DEBUG
< /code>
MyApp.class
@SpringBootApplication
public class MyApp extends Application {

private ConfigurableApplicationContext appContext;
private Parent root;

@Override
public void init() throws Exception{
appContext = new SpringApplicationBuilder(MyApp.class)
.run(getParameters().getRaw().toArray(new String[0]));

FXMLLoader loader = new FXMLLoader(MyApp.class.getResource("hello-view.fxml"));
root = loader.load();
}

@Override
public void start(Stage stage) {
stage.setTitle("MyAppView");

Scene scene = new Scene(root, 480, 320);
stage.setScene(scene);
stage.show();
}

@Override
public void stop(){
appContext.close();
Platform.exit();
}

public static void main(String...  args){
Application.launch(MyApp.class, args);
}

}
< /code>
MyAppDatabaseConfig.class
@Configuration(proxyBeanMethods = false)
public class MyAppDataBaseConfig {

final DataSourceProperties DATA_SOURCE_PROPERTY;

@Autowired
public MyAppDataBaseConfig(DataSourceProperties dataSource){
this.DATA_SOURCE_PROPERTY = dataSource;
}

@Bean
@Primary
public DataSource backDataSource() {
SQLiteDataSource sqlDs = new SQLiteDataSource();
sqlDs.setUrl(DATA_SOURCE_PROPERTY.getUrl());
return sqlDs;
}
}
< /code>
pom.xml
 & l t ; p r o j e c t   x m l n s = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0 & q u o t ; < b r   / >                   x m l n s : x s i = & q u o t ; h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e & q u o t ; < b r   / >                   x s i : s c h e m a L o c a t i o n = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0   h t t p s : / / m a v e n . a p a c h e . o r g / x s d / m a v e n - 4 . 0 . 0 . x s d & q u o t ; & g t ; < b r   / >         & l t ; m o d e l V e r s i o n & g t ; 4 . 0 . 0 & l t ; / m o d e l V e r s i o n & g t ; < b r   / > < b r   / >         & l t ; g r o u p I d & g t ; t e s t & l t ; / g r o u p I d & g t ; < b r   / >         & l t ; a r t i f a c t I d & g t ; m y a p p & l t ; / a r t i f a c t I d & g t ; < b r   / >         & l t ; v e r s i o n & g t ; 1 . 0 - S N APSHOT
myapp


UTF-8
21
21.0.1
2.0.16



org.springframework.boot
spring-boot-starter-parent
3.4.2




org.springframework.boot
spring-boot-starter



org.projectlombok
lombok
true



org.springframework.boot
spring-boot-starter-data-jpa



org.hibernate.orm
hibernate-community-dialects
6.6.1.Final



org.xerial
sqlite-jdbc
3.46.1.0



org.openjfx
javafx-controls
${jfx.version}


org.openjfx
javafx-fxml
${jfx.version}



org.slf4j
slf4j-api
${slf4j.version}



org.slf4j
slf4j-reload4j
${slf4j.version}
test







org.apache.maven.plugins
maven-compiler-plugin
3.11.0

UTF-8
21
21




org.apache.maven.plugins
maven-dependency-plugin


copy-dependencies
package

copy-dependencies


org.openjfx
${project.build.directory}/lib
false
false
true








Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post