Can't find bundle for base name data1 - properties

I recently working with Struts1,and I am so confused about this error.
I have done with [add class folder] in Java build path, so actually the 'config' folder might be classpath right?
why does ResourceBundle can't read 'data1.properties'?
enter image description here

Related

What is the path of mapping file on Crashlytics server once crashlytics plugin automatically upload mapping file to crashlytics server?

I have added following code inside proguard-rules.pro for producing redable crash report once proguard enabled in my project.
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.
I haven't add mappingsFileUploadEnabled in build.gradle. So that means as per crashlytics documentation, plugin will automatically upload mapping file.
When i build the project my mapping file generated under build->outputs->mapping
Anyone please tell me crashlytics plugin on which location uploading this mapping file automatically ? Can i view this file on crashlytics portal once plugin uploaded to mapping file ?
At the moment is not possible to see the uploaded mapping files in the Crashlytics dashboard.
After building the app, you would need to cause a test crash and see if the code has been deobfuscated. If it is, then that means the mapping file got uploaded correctly.
If it doesn't, you could try running the gradle task that upload the mapping file and see if there are errors. for this you can use this command:
./gradlew app:uploadCrashlyticSymbolFileDebug --console=plain --debug | grep "com.google.firebase.crashlytics"

Can't access resources in kotlin from src/main/resources

I have a gradle kotlin project , where I want to load a file from my resources directory.
My kotlin classes are in src/main/kotlin/packagenames and my resources are in src/main/resources
After gradle build including kotlin plugin (kotlin("jvm") version "1.7.20") my classes are copied to build/classes/kotlin/main/packagenames and my resources to build/resources/main
Now I try to read this files from my kotlin code
object {}.javaClass.getResourceAsStream("/resources/filename")
or
object {}.javaClass.classloader.getResourceAsStream("/resources/filename")
but the files are not found.
When I try to see which directory it looks into
println(this.javaClass.getResource("/"))
results in build/classes/kotlin and with javaClass.classLoader it returns null accessing '/'
This means normally I would have to go up two directories and then access resources directory, but this doesn't work as build/classes/kotlin seems to be the root.
Any Idea why this happens.
Remove /resources/ from the input string and instead try
object {}.javaClass.getResourceAsStream("/filename")
This should work as expected.

"no main manifest attribute" error in intellij when executing jar

I'm working on a kotlin project that I want to execute as a jar. This is all done in IntelliJ Idea and I went about making the jar using the artifacts.
The process I followed was (as illustrated by an Idea guide):
Add artifact (as jar) from project structure
Build jar
Run jar
After this, I get a
'no main manifest attribute, in ____.jar'
What I have tried after reading several stack overflow questions:
Checking that the manifest file is in the correct folder and has the correct path in the artifact
Adding code to the build.gradle file for the jar->manifest portion
Trying the method of moving the manifest stuff into a resources folder
Checking that the jar exists
Moving the manifest stuff into a different folder (java,kotlin,out folders)
Making sure that the manifest file is in the correct format
All of the above has not worked.
Something that is confusing to me is that, even when I alter the manifest file to be in "incorrect" format, it still gives the same error. The path stated in the artifact's details is correct yet there is no difference even when I purposely input incorrect items in the manifest file. Not sure if that is the"real" problem but I'm also not sure how to fix that as well
None of the solutions worked for me.
I solved it in this way:
When setting up the artifact, change:
Meta-inf: (...)\src\main\ (you must remove "java")
Also, there was a problem with resources, solved this way:
When setting up the artifact:
Output Layout > Add copy of > Directory content > resources.
That's all!
For anyone that may have encountered this problem in intellij and did not find a solution in any other posts, what helped me was
Navigating to Project Structure
Going to the Artifacts tab
Explicitly adding a new META-INF/ directory in my jar
Adding the created MANIFEST.MF file to the META-INF/ in the jar FROM THE ARTIFACTS TAB
Rearranging the order for the META-INF/ to be at the top
Building and running
The end result looked like this
while creating the exeutable jar file explicitly create a mainfest.txt file
that should be in order of the directory structure and mainfest.txt file should contain only one line (Main-Class:name of the class containg main method)then run the jar tool

resource not found when using IntelliJ

I have a resource abc/xyz.json under src/test/resources. I'm using IntelliJ IDE.
While running a Test for my project, I get the following exception.
Exception
com.google.common.io.Resources.getResource("abc/xyz.json")
fails with java.lang.IllegalArgumentException: resource abc/xyz.json not found.
The Test runs fine with gradle clean build and eclipse
Try marking your src/test/resources folder as Test Resource Root. Attach is the image on how to do it.
Let me know if you need any other information.
Make your resource folder a Test Resource folder, if this does not fix the issue then, close your project, delete target folder and open the project. Hope this helps.
Had the same issue not that long ago, since Intellij outputs the class files into out/production/{project_name}, that path will not start in the src directory but will start in the out/production/{project_name} directory.
It will however see files that are in the project root directory, I'd recommend moving your resource directory into the main project directory then accessing the file with "resources\${FILE_NAME}".
Sometimes I have the same problem, though the folder is marked as resource root. So what I do: I just Unmark it and then mark it as resource root again. Sometimes I need to do it several times and it works. But anyway I think it is Intellij IDEA bug.

How to mark package as a resource folder?

I have a dir structure for Intellij 12:
...
...test
- java
- com.mycompany.myproject
- package1 (contains code, etc,.)
- resourcePackage (want to contain .json files but can't mark as a resource)
- myOtherJunk.json
- o o o
- resources
- aResource.json
The thing is if I right click on my package name (com.mycompany.myproject) I can only add packages and not directories (like that of an existing resource folder).
However, I don't want to use that existing resource folder for the .json files that I'm going to read into per my test class.
So, I need something to support:
// this already works for the resources directory per the .json file but doesn't for the
// myOtherJunk.json per the resourcePackage.
InputStream is = MyClassTest.class.getResourceAsStream("aResource.json");
This can be solved in several ways. An example of a good approach would be the following folder structure:
src
main
java
resources
test
java
resources
When this is done, you put all you java classes under src/main/java/com.mycompany package and any resources under /src/main/resources/com/mycompany folder.
To link them together, go to the project properties, and find the Path tab. Mark the src/main/java and src/main/resources as source folders. (see the screen-shot attached)
If you link them together, you'll be able to use getResourceAsStream() method.
If you wonder why you should use the following folder structure - this is standard maven way of keeping things clean and tidy.
Directories Creation
Intellij creates directories when you ask her to create package. It is not an error.
If you create package "com", it will create the dir "com", and if you create a source file there, it will think that the file is in the package "com".
If you create package "com.next.pack", it will create three nested dirs "com", then "next", then "pack", and if you create a source file there, it will think that the file is in the package "com.next.pack".
Directories Structures
Only the path under the source root is taken as a package. Any directory(ies) can be set as a source root(s).
Resources roots
Make practically any structure of directories. Somewhere in it there is the root dir of resources. Right-click it and Mark Directory As ... Resources Root.
Notice, the same method can be used for the directories structures for tests, test classes, and test resources. Look here.
Please use #ContextConfiguration annotation to load the resource files. Please see below example.
#ContextConfiguration( { "/app-config.xml", "/test-data-access-config.xml",application-test.yml })