WebLogic 12c - SpringBoot - java.io.FileNotFoundException: Could not open ServletContext resource












0














I am trying to deploy a SpringBoot project onto Weblogic 12c. According to this spring article I edited my SpringBootApplication class to implement WebApplicationInitializer interface.



I removed below lines from the POM



   <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.dependency.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>


Since there is no need for repackaging to executable archive.



I added below:



   <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>


Since I want to package the app as WAR file and I don't have a web.xml(I use annotation-based configuration) so I don't want the packaging to fail.



Also, I added below to set the packaging to WAR:



<packaging>war</packaging>


So far so good. I do mvn clean install and my WAR package is ready with all the dependencies as JAR files inside the WAR archive of my web app.



When I try to deploy this war file I get this error:



java.io.FileNotFoundException: Could not open ServletContext resource [/myfile.properties]
Could not open ServletContext resource [/myfile.properties]



I check if the mentioned properties file was in the package and there it was inside one of the JARs in the WAR file.



This is the structure of the JAR file:



META-INF
com
myfile.properties


So the properties file is in the root of the JAR archive as expected.



In that JAR archive one of the classes are trying to load the properties file using @PropertySource annotation as below:



@Configuration
@PropertySource("myfile.properties")
public class MyConfigClassForThisApp{

}


In another class the values are read as below:



@Value("${some.key}")
private String keyValue;


I understand that WebLogic classpath is not the same as the Tomcat classpath. So, I think I need to configure the WebLogic classpath to see this properties file. How can I do that?



OR maybe I should change the way I refer to this properties file and instead of using @PropertySource annotation, I should do something like:



this.getClass().getClassLoader().getResourceAsStream()


and wrap the properties file in a Properties class then read the values?



Please note that I would like to avoid changing the code whenever I can.
What would be the best way to make the WebLogic server see my configuration class with as little code/config modification as possible? Also, my WAR has other JARs inside and many of them have properties files like this. Whatever solution I can come up with will be applied multiple times for other properties files inside other JARs.



Note: I am deploying the application on a test environment on AdminServer.



Note: I placed the properties files in %WEBLOGIC_HOME%/user_projects/domains/MYDOMAIN as suggested here, it didn't work.










share|improve this question
























  • Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
    – M. Deinum
    Nov 13 at 14:05
















0














I am trying to deploy a SpringBoot project onto Weblogic 12c. According to this spring article I edited my SpringBootApplication class to implement WebApplicationInitializer interface.



I removed below lines from the POM



   <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.dependency.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>


Since there is no need for repackaging to executable archive.



I added below:



   <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>


Since I want to package the app as WAR file and I don't have a web.xml(I use annotation-based configuration) so I don't want the packaging to fail.



Also, I added below to set the packaging to WAR:



<packaging>war</packaging>


So far so good. I do mvn clean install and my WAR package is ready with all the dependencies as JAR files inside the WAR archive of my web app.



When I try to deploy this war file I get this error:



java.io.FileNotFoundException: Could not open ServletContext resource [/myfile.properties]
Could not open ServletContext resource [/myfile.properties]



I check if the mentioned properties file was in the package and there it was inside one of the JARs in the WAR file.



This is the structure of the JAR file:



META-INF
com
myfile.properties


So the properties file is in the root of the JAR archive as expected.



In that JAR archive one of the classes are trying to load the properties file using @PropertySource annotation as below:



@Configuration
@PropertySource("myfile.properties")
public class MyConfigClassForThisApp{

}


In another class the values are read as below:



@Value("${some.key}")
private String keyValue;


I understand that WebLogic classpath is not the same as the Tomcat classpath. So, I think I need to configure the WebLogic classpath to see this properties file. How can I do that?



OR maybe I should change the way I refer to this properties file and instead of using @PropertySource annotation, I should do something like:



this.getClass().getClassLoader().getResourceAsStream()


and wrap the properties file in a Properties class then read the values?



Please note that I would like to avoid changing the code whenever I can.
What would be the best way to make the WebLogic server see my configuration class with as little code/config modification as possible? Also, my WAR has other JARs inside and many of them have properties files like this. Whatever solution I can come up with will be applied multiple times for other properties files inside other JARs.



Note: I am deploying the application on a test environment on AdminServer.



Note: I placed the properties files in %WEBLOGIC_HOME%/user_projects/domains/MYDOMAIN as suggested here, it didn't work.










share|improve this question
























  • Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
    – M. Deinum
    Nov 13 at 14:05














0












0








0







I am trying to deploy a SpringBoot project onto Weblogic 12c. According to this spring article I edited my SpringBootApplication class to implement WebApplicationInitializer interface.



I removed below lines from the POM



   <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.dependency.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>


Since there is no need for repackaging to executable archive.



I added below:



   <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>


Since I want to package the app as WAR file and I don't have a web.xml(I use annotation-based configuration) so I don't want the packaging to fail.



Also, I added below to set the packaging to WAR:



<packaging>war</packaging>


So far so good. I do mvn clean install and my WAR package is ready with all the dependencies as JAR files inside the WAR archive of my web app.



When I try to deploy this war file I get this error:



java.io.FileNotFoundException: Could not open ServletContext resource [/myfile.properties]
Could not open ServletContext resource [/myfile.properties]



I check if the mentioned properties file was in the package and there it was inside one of the JARs in the WAR file.



This is the structure of the JAR file:



META-INF
com
myfile.properties


So the properties file is in the root of the JAR archive as expected.



In that JAR archive one of the classes are trying to load the properties file using @PropertySource annotation as below:



@Configuration
@PropertySource("myfile.properties")
public class MyConfigClassForThisApp{

}


In another class the values are read as below:



@Value("${some.key}")
private String keyValue;


I understand that WebLogic classpath is not the same as the Tomcat classpath. So, I think I need to configure the WebLogic classpath to see this properties file. How can I do that?



OR maybe I should change the way I refer to this properties file and instead of using @PropertySource annotation, I should do something like:



this.getClass().getClassLoader().getResourceAsStream()


and wrap the properties file in a Properties class then read the values?



Please note that I would like to avoid changing the code whenever I can.
What would be the best way to make the WebLogic server see my configuration class with as little code/config modification as possible? Also, my WAR has other JARs inside and many of them have properties files like this. Whatever solution I can come up with will be applied multiple times for other properties files inside other JARs.



Note: I am deploying the application on a test environment on AdminServer.



Note: I placed the properties files in %WEBLOGIC_HOME%/user_projects/domains/MYDOMAIN as suggested here, it didn't work.










share|improve this question















I am trying to deploy a SpringBoot project onto Weblogic 12c. According to this spring article I edited my SpringBootApplication class to implement WebApplicationInitializer interface.



I removed below lines from the POM



   <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.dependency.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>


Since there is no need for repackaging to executable archive.



I added below:



   <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>


Since I want to package the app as WAR file and I don't have a web.xml(I use annotation-based configuration) so I don't want the packaging to fail.



Also, I added below to set the packaging to WAR:



<packaging>war</packaging>


So far so good. I do mvn clean install and my WAR package is ready with all the dependencies as JAR files inside the WAR archive of my web app.



When I try to deploy this war file I get this error:



java.io.FileNotFoundException: Could not open ServletContext resource [/myfile.properties]
Could not open ServletContext resource [/myfile.properties]



I check if the mentioned properties file was in the package and there it was inside one of the JARs in the WAR file.



This is the structure of the JAR file:



META-INF
com
myfile.properties


So the properties file is in the root of the JAR archive as expected.



In that JAR archive one of the classes are trying to load the properties file using @PropertySource annotation as below:



@Configuration
@PropertySource("myfile.properties")
public class MyConfigClassForThisApp{

}


In another class the values are read as below:



@Value("${some.key}")
private String keyValue;


I understand that WebLogic classpath is not the same as the Tomcat classpath. So, I think I need to configure the WebLogic classpath to see this properties file. How can I do that?



OR maybe I should change the way I refer to this properties file and instead of using @PropertySource annotation, I should do something like:



this.getClass().getClassLoader().getResourceAsStream()


and wrap the properties file in a Properties class then read the values?



Please note that I would like to avoid changing the code whenever I can.
What would be the best way to make the WebLogic server see my configuration class with as little code/config modification as possible? Also, my WAR has other JARs inside and many of them have properties files like this. Whatever solution I can come up with will be applied multiple times for other properties files inside other JARs.



Note: I am deploying the application on a test environment on AdminServer.



Note: I placed the properties files in %WEBLOGIC_HOME%/user_projects/domains/MYDOMAIN as suggested here, it didn't work.







spring spring-boot weblogic weblogic12c






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 at 11:50

























asked Nov 13 at 8:52









SoftwareTheory

5472722




5472722












  • Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
    – M. Deinum
    Nov 13 at 14:05


















  • Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
    – M. Deinum
    Nov 13 at 14:05
















Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
– M. Deinum
Nov 13 at 14:05




Don't remove the spring-boot-pugin. It isn't just about making the archive executable it is also about adding things in the proper place when creating a war. To load your properties just prefix with classpath:.
– M. Deinum
Nov 13 at 14:05

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277106%2fweblogic-12c-springboot-java-io-filenotfoundexception-could-not-open-servle%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277106%2fweblogic-12c-springboot-java-io-filenotfoundexception-could-not-open-servle%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?