IgniteException : Spring XML configuration path is invalid - java

Getting the following exception in intelliJ.
Caused by: class org.apache.ignite.IgniteException:
Spring XML configuration path is invalid: example-ignite.xml.
Note that this path should be either absolute or a relative local file system path, relative to META-INF in classpath or valid URL to IGNITE_HOME.
How can i fix it?
Thanks

If your configuration bean's definition has abstract=true parameter, try removing it if it does.
I think, the problem is that example-ignite.xml file has only abstract IgniteConfiguration. This is the case in the default configuration file in examples.

I had this problem. my issue was due existing error in config.xml file. for test, i ignore config.xml from environment variable (-v) and run ignite without it and after i saw that it worked, i figured out that issue is cause that.
i worked with ignite in docker in linux.

I had this problem and fixed with fake solution, , i used config file by internet path and not local file system path. i set config.xml on one domain path (https://example.net/config.xml) and then i set this path for spring xml configuration path.

Related

RabbitMQ JAVA Spring Configurations - spring.rabbitmq.ssl.key-store

I am trying to connect my Spring application to a RabbitMQ server.
I have in my src/main/resources folder an application.properties file containing the following properties:
spring.rabbitmq.port=port
spring.rabbitmq.username=user
spring.rabbitmq.password=pass
spring.rabbitmq.host=hostname
spring.rabbitmq.ssl.verify-hostname=true
spring.rabbitmq.virtual-host=virtualHost
spring.rabbitmq.ssl.enabled=true
spring.rabbitmq.ssl.algorithm=TLSv1.2
spring.rabbitmq.ssl.key-store=client-file
spring.rabbitmq.ssl.key-store-password=client
The "client-file" is also in the same directory - src/main/resources. However, when I build the application - I recieve the following error:
Factory method 'rabbitConnectionFactory' threw exception;
nested exception is org.springframework.amqp.AmqpIOException: java.io.FileNotFoundException:
class path resource [client-file] cannot be opened because it does not exist
My file is not being recognized... I might need to have some full path, but am not sure what it should look like. Any help would be greatly appreciated!
Try like this:
...
spring.rabbitmq.ssl.key-store=classpath:/client-file
spring.rabbitmq.ssl.key-store-password=client
I did put mine in the resource folder '..\src\main\resources'.
use file:file_path if you are placing the file on a directory location(or a mounted drive) outside your app.

#PropertySource cannot be opened because it does not exist

I have the problem with configuration file that is located in other directory than my jar file.
I use #PropertySource for loading properties.
#PropertySource(ignoreResourceNotFound = true, value = "${ext.properties.dir:classpath:}/properties.properties")
I try to run jar using following command:
java -jar import-0.0.1-SNAPSHOT.jar -Dext.properties.dir=file:/C:\Users\Admin\Desktop\
The following error pring in logs: Properties location
Properties location
[${ext.properties.dir:classpath:}/properties.properties] not resolvable:
class path resource [properties.properties] cannot be opened because it
does not exist
How can I fix this error?
I saw that you are using spring boot application, according to the spring documentation you can try to use this environment property:
--spring.config.location=file:/path/location/file-name.properties
The final instruction would be:
java -jar import-0.0.1-SNAPSHOT.jar --spring.config.location=file:C:\Users\Admin\Desktop\import.properties
Spring Boot looks for application.properties on classpath. You don't need an explicit #PropertySource annotation. And #PropertySource doesn't have the capability to resolve SPEL in the path, which should be evident from the error message you're getting.
Use src/main/resources/application.properties. When you want to use the external file, use spring.config.location like #juan-calvopina-m suggested in his answer.

Can i set relative path to java.security.auth.login.config?

In my Spring Boot app i need to call to:
System.setProperty("java.security.auth.login.config", authConf);
where authConf seems to be expected as an absolute path to the file.
the problem is, my Spring Boot app is packaged and executed as a jar and i want to package the file inside the jar.
The answer provided in this question might work only when a WAR is deployed in a server. It doesn't seem to work when we run JARs with embedded container.
is there way i could set a relative path to java.security.auth.login.config to refer to my conf file packaged within my jar ?
I know that the answer is about 6 years too late, but I recently faced the same issue and found and answer. Maybe my answer will at least help the next dev who will face this issue. I was able to solve it is by first creating a javax.security.auth.login.Configuration of type JavaLoginConfig and then use the Configuration.setConfiguration(configuration method) of the same Configuration class. Using this method I was able to bundle our jaas.conf inside the jar and use a relative path to it.
To give a concrete example:
Get the URL of the security configuration file you want to use
URL configLocation=YourClass.getClassLoader().getResource("resources/jaas.conf);"
Create the JavaLoginConfig configuration
Configuration secConfig=Configuration.getInstance("JavaLoginConf", new URIParameter(configLocation.toURI());
Set the configuration to the one you created in step 2
Configuration.setConfiguration(secConfig);

Adding spring XML files to classpath (Windows cmd-line)

I am trying to run a jar file via cmd line that uses Spring and a spring xml configuration file.
The cmd line call is similar to:
java -cp lib/MyJar.jar my.package.MyClass
The error I get is:
Caused by: java.io.FileNotFoundException: class path resource
[myPath/mySpringCfg.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
My manifest classpath is similar to:
Class-Path: 3rdPartyJar1.jar 3rdPartyJar2.jar ./myPath/
The call that loads the file equates to:
context = new ClassPathXmlApplicationContext("myPath/mySpringCfg.xml");
Is there a way to correctly pull in XML files in the classpath so that Spring will work as expected? It seems like the classpath docs only talk about archive files and folders.
Thanks!
UPDATE
It seems to run fine when I switch over to FileSystemXmlApplicationContext. I guess the ClassPathXmlApplicationContext cannot be used from command-line
Your reference to the XML is myPath/mySpringCfg.xml - this means that myPath has to be in the classpath.
Change your manifest to be:
Class-Path: 3rdPartyJar1.jar 3rdPartyJar2.jar ./
This way myPath will be a part of the classpath and not just its contents.
Note:
The application configuration XML is a part of your application's code, don't mistake it for a configuration.
If you want configuration - put it outside in a properties file and use place-holders in your XML configuration file.
Update:
I think the root cause of your problem is in the code (I didn't test it though) - try this instead:
context = new ClassPathXmlApplicationContext("/myPath/mySpringCfg.xml");
The difference is in the '/' before 'myPath'
I am not aware of the architecture of your project, but why not place your xml configuration file into your project jar?

Eclipse not able to find Spring configuration file

I am wetting my hands in Spring and using Eclipse along with Spring. I have written a very simple Spring application with eclipse to inject a property in a bean. However, when I am running my application, Spring is throwing exception and it seems that the Spring is not able to find the Spring configuration file. Below is the stacktrace --
INFO: Loading XML bean definitions from class path resource [Beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
I have tried the following -- Give the full path in the ClassPathXmlApplicationContext method like --
ApplicationContext context = new ClassPathXmlApplicationContext("C:/Users/devshankhasharm/workspace/FinalPowerShell/src/src/main/Beans.xml");
I have also updated the ClassPath variable in windows to add the path for my spring configuration file. But nothing worked. Any idea would be highly appreciated.
Try this
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:Beans.xml");
And of course your Beans.xml must be in classpath.
Update or maybe
ApplicationContext context = new ClassPathXmlApplicationContext("file:src/main/Beans.xml");
Beans.xml should be in classpath. You cannot give full physical path of xml file for ClassPathXmlApplicationContext . Please check if Beans.xml is there in build path of eclipse.
As you are using a full filepath for your Beans.xml example, use
ApplicationContext context = new GenericXmlApplicationContext("C:/Users/devshankhasharm/workspace/FinalPowerShell/src/src/main/Beans.xml");
BUT it is not recommended to do this. Use the ClassPathXmlApplicationContext for this instead.
Then move Beans.xml into the classpath. The simplest way to do this is to move it to the root of your java source if not using Maven or src/main/resources if using Maven
If it's not much of a bother then try using Spring Tool Suite. It's a Spring friendly IDE based on Eclipse, so that you don't have to depend on spring/maven plugin configurations. All you have to do is go and create a Spring Project instead of Java project and rest all the settings will be handled for you.
If you are using Spring Tool Suite (STS), it may be the case that when you create a Maven project the src/main/resources directory was configured with "Excluded: .". In other words, STS sets your src/main/resources directory to have all its contents excluded from output by default.
How to fix it:
Project properties (Alt+Enter) -> Java Build Path -> Source
On src/main/resources, you may see "Excluded: ."
Select this item and click on Edit...
Remove the . exclusion pattern
Click OK. Voila!

Categories

Resources