I am working on DROOLS 6.0.1 application. I have my rule files (*.drl) packaged inside a separate project which is included as a jar file as a maven dependency. When I deploy my project, KIEModule is not able to find the rules files (which are packaged inside the jar above). I am not getting an error though but rules are not getting fired.
If I manually place the rules files under classpath say WEB-INF/rules/*.drl they are detected and rules are executed.
I was under impression that KIEmodules are auto discovered from anywhere in classpath.
Any pointers are appreciated. This is general question hence I have not included the comprehensive code files.
Everything start working once I place the *.drl files in the classpath (take them outside of jar).
Thanks
Step 1 : Found the solution, the package with DLR must be declared inside your : "kmodule.xml"
Step2: you have to create enter image description here
Step3:enter image description here
Related
I creating a program to work with databases and I am getting the following error when compiling in IntelliJ IDEA. Does anyone why this is happening and how I could solve it?
The error that you get occurs not on complilation, but when you try to run your application. It happens because Java was not able to find Table.class file inside db subdirectory of the project output directory (classpath).
It can happen for multiple reasons:
wrong main class selected in the run/debug configuration
Table.java is excluded from compilation (by accident or intentionally because it contained errors and you wanted to skip it while working on other code)
class not compiled because Build step is excluded from from Before launch steps in the Run/Debug configuration
project is misconfigured and there is no Source root defined for the directory containing db subdirectory
Table.java has incorrect package statement or is located/moved to a different package
project path contains a colon : on Mac/Linux or semicolon ; on Windows, it's used to separate the classpath and will render the classpath invalid. See this thread for details. Note that Finder on Mac may display colons in the path as slashes.
the jar may not execute if one of the dependent jars is digitally signed since the new artifact will include the partial signature of the dependency. See this answer for more details.
In project structure make sure you have the right Java version for compile.
there is a known bug that sometimes a Java project created from the Command Line template doesn't work because .idea/modules.xml file references invalid module file named untitled104.iml. Fix the module name manually or create a project from scratch and don't use a template.
on Windows "Beta: Use Unicode UTF-8 for worldwide language support" Region Setting is enabled. See IDEA-247837 for more details and workarounds.
When IntelliJ IDEA is configured to store module dependencies in Eclipse format source root configuration is lost due to a known bug. Configure the module to use IntelliJ IDEA format dependencies as a workaround.
In a properly configured project and with the correct run/debug configuration everything works just fine:
the jar may not execute if one of the dependent jars is digitally signed since the new artifact will include the partial signature of the dependency. See this answer for more details.
I must again emphasis the point CrazyCoder has here.
The (Oracle) JVM used to throw a SecurityException when you tried to run a Jar-File containing broken signatures. This made sense from a "What's wrong"-Point of view.
That is no longer the case. They are indeed throwing ClassNotFoundExceptions now - even if the class is right there in the file (no matter if it is in the default package/toplevel or way down in a nested package structure).
Here's what worked for me:
I deleted .ide folder, .iml file. And all other auto generated files by intelliJ then restarted my ide and I was asked if I want to make my project run with maven that's it.
Obviously I said yes :)
This is a known bug in the IntelliJ idea.
To fix this I just deleted the .iml and the .idea and restart the IDE.
It works for most of the cases
Edit: The files will be in the project directories.
In my case the default console app template works only if the project folder path does not contain underscore (_) in it. Underscore brings the error
Error: Could not find or load main class com.company.Main
Caused by: java.lang.ClassNotFoundException: com.company.Main
IntelliJ IDEA 2021.3.1 (Ultimate Edition)
Build #IU-213.6461.79, built on December 28, 2021
If you've tried everything else that others have suggested (deleting .idea folder, rebuild, etc) there's another place to check, especially if you've built an artifact jar. When you first build an artifact jar, IntelliJ adds a folder: META-INF to src directory. in it is a single file: MANIFEST.MF which has info pointing to the Main-Class for Java to find. If you've refactored your project package, unfortunately IntelliJ does not update this file with the new changes. My MANIFEST.MF has the following correct content:
Manifest-Version: 1.0
Main-Class: org.umoja4life.fatashibackend.MainKt
Where "org.umoja4life.fatashibackend" is the package name, and "MainKt" is IntelliJ's constructed name for a (pseudo) "Main Class" because fun main() has been defined in file "main.kt" in the package directory.
Newbies: btw, This will be confusing for you because there should be no actual "class Main {}" definition despite the error message stating there should be.
Before I discovered this file and after trying everyone else's suggestions, I found it quickest to just have IntelliJ start a project (with correct package name!), initialize it with a trivial main.kt having:
fun main() { println("hello world!") }
run and test that; then, I added back in all my other files, rebuilt, ran, and tested it. Apparently IntelliJ has some secret state information stored somewhere which doesn't get correctly updated if your refactor your package name for an already running project and jar.
I am trying to integrate my application with stardog. The application accesses already other RDF repositories in Java via sesame remoteRepository interface.
Stardog writes in http://docs.stardog.com/#_using_sesame that this can be achieved via a use of StardogRepository() - but without saying what libs to include.
After a little search inside the stardog 4.1.3 installation I found and included in eclipse's WEB-INF/lib:
stardog-api-4.1.3.jar
stardog-sesame-core-4.1.3.jar
After that, the eclipse Java compiler shows no errors in the code but one error in the project path, saying:
The project was not built since its build path is incomplete. Cannot
find the class file for
org.openrdf.repository.base.AbstractRepository. Fix the build path
then try building this project
After project cleaning this problem remains.
This class org.openrdf.repository.base.AbstractRepository is defined in the lib eclipse-rdf4j-2.0.1.jar, which is also present in the WEB-INF/lib folder (with or without this latter eclipse-rdf4j-2.0.1.jar the problem is unchanged).
What lib shell I include in order to have these 2 lines of code in http://docs.stardog.com/# compiled?
Thanks a lot in advance for any hint.
The solution is: include openrdf-sesame-4.1.2-onejar.jar and the stardog code will compile.
I'm using Zelix KlassMaster version 8.0.2 to obfuscate a JAR file. The JAR itself works fine but when I try to obfuscate it, Zelix says that a class has not been found:
Error while opening classes. : 'javax.annotation.Nullable' not found. Cannot proceed to next step. Please adjust your Zelix KlassMaster classpath or class file selections.
If I find the said JAR file e.g. here and add it to the classpath, another class is not found. This keeps going on and on even though these classes/libraries are never needed or used by my application (which uses some 3rd party libraries obviously).
How do I fix this? I just want to obfuscate my JAR file without selecting additional nonsense external JAR files because no necessary classes are actually missing.
All you have to do is to add all of your projects libraries to the class path as well as the default Java libraries. What you describe happens when you open the project's libraries instead of adding them at the classpath.
Im want to link an android jar library to my Xamarin project, i do everything covered by the online doc on Xamarin website.
But when i compile the binding project i got a warning that say : No Package Found.
If i replace the desired Jar by another, let say picasso.jar for example, i don't have this error and the binding projet compile without problems.
I can't link the jar library because of an NDA engagement.
But it's possible that the problems is that i get the .jar from a repository supposed to be build by maven/gradle and not a final .jar compiled?
What can i do to track the real error behind this "no package found"
A DLL is correctly generated at the end of the process, but added it to the main project don't give me any classes from the original jar.
As I thought this is the fault to the jar from maven repository. Inside the jar we got java files and not compiled files.
So i take an compiled jar (aar files) and everything work now.
I am trying to add an external library to my Java project. The library files are in .jar format, and every time someone tries to run the project in a different environment, they have to modify the build path so that their environment can find the .jar files.
Is there any way to make it so that the .jar files are automatically found by the build path? Maybe by specifying where in the project the .jar files are located?
Edit: Here is an example -
In my linux environment, the .jar files are located in:
/home/MyUsername\SomeDirectory\workspace\java_project_name\data
In my windows environment, the .jar files are located in:
C:\MyUsername\SomeDirectory\workspace\java_project_name\data
In the example above, the project root directory is "java_project_name", and the .jar files are always in the java_project_name\data folder. Even though this is the case, different environments can't seem to detect that it is always in the same path in relation to the project's root directory.
I have looked in many places on how to do this, and some people told me it isn't possible. This doesn't sound reasonable to me, which is why I am posting this question here.
Thanks in advance for your help!
you can add a ClassPath: entry in your manifest file of the main jar, and use relative paths. As long as the jars are found relative to the main jar it will work.
This issue was one of my main motivators to start using maven.
#YoK nicely quotes here the relevant reasons to this question https://stackoverflow.com/a/3589930/1493954
Here is one the relevant quotes from Benefits of using Maven
Henning
quick project setup, no complicated build.xml files, just a POM and go
all developers in a project use the same jar dependencies due to
centralized POM.
getting a number of reports and metrics for a project
"for free"
reduce the size of source distributions, because jars can
be pulled from a central location
This is a common problem for developement environments.
I myself use the following solution in netbeans [Hope so that it works in your IDE too]:
Create an Ant variable [for e.g. JAR_LOCATION].
Each and every JAR that you refer, must have it's location relative to JAR_LOCATION.
Now, in every development environment that you're gonna use, you can set up the same ANT variable and it'll automatically pick up the JAR.
You can see the example in the given snapshot of netbeans..