this my project strucuture:
and i found the next exception:
aused by: org.springframework.webflow.engine.model.builder.FlowModelBuilderException: Couldtion at class path resource [WEB-INF/flow/consultaDeutes/consultaDeutes.xml]
at org.springframework.webflow.engine.model.builder.xml.XmlFlowModelBuilder.init(Xml at org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder.assembleF.java:86)
at org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder.getFlowMo:61)
at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.doInit(Flow ... 47 more
Caused by: java.io.FileNotFoundException: class path resource [src/main/webapp/WEB-INF/flow/consultaDeutes/consultaDeutes.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.ja at org.springframework.webflow.engine.model.builder.xml.DefaultDocumentLoader.loadDova:98)
at org.springframework.webflow.engine.model.builder.xml.XmlFlowModelBuilder.init(Xml ... 50 more
What is wrong here? i'm pretty desperate ty.
#Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
FlowDefinitionResource resource = resourceFactory.createResource("consultaDeutes.xml");
Assert.assertNotNull(resource);
return resource;
}
/*[src/main/webapp/WEB-INF/flow/consultaDeutes/consultaDeutes.xml]*/
#Test
public void testFlowShouldEnterStartState()
{
this.startFlow(context);
// assertCurrentStateEquals("a_cargar_info");
}
Related
I am trying to create my first Spring app. It is showing the following error:
log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext] 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)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at com.spring1.FirstSpring1.main(FirstSpring1.java:20)
Caused by: java.io.FileNotFoundException: class path resource [applicationContext] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 4 more
GetterSetter.java
package com.spring1;
private String name;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
public void displayInfo()
{
System.out.println("hello "+name);
}
FirstSpring1.java
package com.spring1;
public static void main(String[] args)
{
GetterSetter gt=new GetterSetter();
gt.setName("Google");
gt.displayInfo();
Resource resource = new ClassPathResource("applicationContext");
BeanFactory factory = new XmlBeanFactory(resource);
GetterSetter gt1 = (GetterSetter)factory.getBean("name1");
gt1.displayInfo();
}
The XML file is in the src folder.
Instead of:
Resource resource = new ClassPathResource("applicationContext");
Use:
Resource resource = new ClassPathResource("applicationContext.xml");
I'm trying to use mybatis-guice with mysql but I keep catching the next exception:
Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
Here is the code I try to run:
public class DaoImpl implements Dao {
#Inject
private MyMapper mapper;
public String getSomething() {
return mapper.getSomething();
}
}
public interface Dao {
String getSomething();
}
public interface MyMapper {
#Select("SELECT DATE_FORMAT(NOW(),'%d/%m/%Y %H:%i') as time")
String getSomething();
}
Injector injector = Guice.createInjector(
new MyBatisModule() {
#Override
protected void initialize() {
install(JdbcHelper.MySQL);
environmentId("development");
bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
addMapperClass(MyMapper.class);
bindProperties(binder(), getMybatisProperties());
bind(Dao.class).to(DaoImpl.class);
}
}
);
private Properties getMybatisProperties() {
Properties myBatisProperties = new Properties();
myBatisProperties.setProperty("JDBC.host", "127.0.0.1");
myBatisProperties.setProperty("JDBC.port", "3306");
myBatisProperties.setProperty("JDBC.schema", "my_schema");
myBatisProperties.setProperty("JDBC.driver", "com.mysql.jdbc.Driver"));
myBatisProperties.setProperty("JDBC.username", "root");
myBatisProperties.setProperty("JDBC.password", "");
myBatisProperties.setProperty("JDBC.autoCommit", "false");
return myBatisProperties;
}
And than I try to run:
injector.getInstance(Dao.class).getSomething()
I tried to remove myBatisProperties.setProperty("JDBC.driver", "com.mysql.jdbc.Driver")); but the result was the same.
Also, after several hours of debugging the code, install(JdbcHelper.MySQL); should add the driver by itself. Is this assumption correct?
The exception is thrown on mapper.getSomething();
Ideas???
You need a driver mysql-connector-java or verify the version of the driver and your put mysql-connector-java-bin.jar in the lib
For a project, I need to import the GSON library, despite of these steps found on different topics, I still have the error NoClassDefFoundError...
Step 1 : in the BuildPath, I add the library as an external JARs
Step 2 : in Order and Export, I check the library
So, if anyone has the solution, thank you in advance for your answers ! ;)
More Informations :
package ummisco.gama.webgl;
import com.google.gson.Gson;
public class SceneReceiver {
private final static SceneReceiver instance = new SceneReceiver();
private boolean canReceive = true;
public static SceneReceiver getInstance() {
return instance;
}
private SceneReceiver() {
}
public void receive(final SimpleScene scene) {
reception(false);
try {
Gson gson = new Gson();
String sceneSend = gson.toJson(scene);
System.out.println(sceneSend);
} catch (Exception e) {
System.out.println(e.getMessage());
}
reception(true);
}
private void reception(boolean canReceive) {
this.canReceive = canReceive;
}
public boolean canReceive() {
return canReceive;
}
}
Here the stacktrace :
Exception in thread "Thread-14" java.lang.NoClassDefFoundError: com/google/gson/Gson
at ummisco.gama.webgl.SceneReceiver.receive(SceneReceiver.java:28)
at ummisco.gama.opengl.scene.ModelScene.endDrawingLayers(ModelScene.java:232)
at ummisco.gama.opengl.scene.SceneBuffer.endUpdatingScene(SceneBuffer.java:74)
at ummisco.gama.opengl.JOGLRenderer.endDrawingLayers(JOGLRenderer.java:713)
at msi.gama.outputs.display.LayerManager.drawLayersOn(LayerManager.java:182)
at ummisco.gama.opengl.SWTOpenGLDisplaySurface.updateDisplay(SWTOpenGLDisplaySurface.java:168)
at ummisco.gama.ui.views.displays.LayeredDisplayView$11.run(LayeredDisplayView.java:673)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson cannot be found by ummisco.gama.opengl_1.7.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more
I'm using Drools 5.5.0-Final and, suddenly, I have this exception
I put all the libraries again in my project, but the result is the same
org.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:136)
at org.drools.compiler.PackageBuilderConfiguration.buildEvaluatorRegistry(PackageBuilderConfiguration.java:550)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:196)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:300)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:228)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:46)
at com.drools.optimizer.AppExpertSystem.readKnowledgeBase(AppExpertSystem.java:130)
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:115)
at com.drools.optimizer.AppExpertSystem.<init>(AppExpertSystem.java:46)
at eventlauncher.OptimizerLauncher.NuevoEscenario(OptimizerLauncher.java:57)
at eventlauncher.DemoPruebas.main(DemoPruebas.java:18)
Caused by: java.lang.ClassNotFoundException: Unable to load class: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:92)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:132)
... 12 more
Exception in thread "main" java.lang.RuntimeException: org.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:122)
at com.drools.optimizer.AppExpertSystem.<init>(AppExpertSystem.java:46)
at eventlauncher.OptimizerLauncher.NuevoEscenario(OptimizerLauncher.java:57)
at eventlauncher.DemoPruebas.main(DemoPruebas.java:18)
Caused by: org.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:136)
at org.drools.compiler.PackageBuilderConfiguration.buildEvaluatorRegistry(PackageBuilderConfiguration.java:550)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:196)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:300)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:228)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFaorg.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:136)
at org.drools.compiler.PackageBuilderConfiguration.buildEvaluatorRegistry(PackageBuilderConfiguration.java:550)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:196)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:300)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:228)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:46)
at com.drools.optimizer.AppExpertSystem.readKnowledgeBase(AppExpertSystem.java:130)
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:115)
at com.drools.optimizer.AppExpertSystem.<init>(AppExpertSystem.java:46)
at eventlauncher.OptimizerLauncher.NuevoEscenario(OptimizerLauncher.java:57)
at eventlauncher.DemoPruebas.main(DemoPruebas.java:18)
Caused by: java.lang.ClassNotFoundException: Unable to load class: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:92)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:132)
... 12 more
Exception in thread "main" java.lang.RuntimeException: org.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:122)
at com.drools.optimizer.AppExpertSystem.<init>(AppExpertSystem.java:46)
at eventlauncher.OptimizerLauncher.NuevoEscenario(OptimizerLauncher.java:57)
at eventlauncher.DemoPruebas.main(DemoPruebas.java:18)
Caused by: org.drools.RuntimeDroolsException: Class not found for evaluator definition: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:136)
at org.drools.compiler.PackageBuilderConfiguration.buildEvaluatorRegistry(PackageBuilderConfiguration.java:550)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:196)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:300)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:228)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:46)
at com.drools.optimizer.AppExpertSystem.readKnowledgeBase(AppExpertSystem.java:130)
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:115)
... 3 more
Caused by: java.lang.ClassNotFoundException: Unable to load class: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:92)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:132)
... 12 morectoryServiceImpl.java:34)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:46)
at com.drools.optimizer.AppExpertSystem.readKnowledgeBase(AppExpertSystem.java:130)
at com.drools.optimizer.AppExpertSystem.loadKnowledgeBase(AppExpertSystem.java:115)
... 3 more
Caused by: java.lang.ClassNotFoundException: Unable to load class: org.drools.base.evaluators.EqualityEvaluatorsDefinition
at org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:92)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.drools.base.evaluators.EvaluatorRegistry.addEvaluatorDefinition(EvaluatorRegistry.java:132)
... 12 more
My code is:
import com.answare.backendconnection.RESTConnection;
import com.answare.dataModel.ActionANS;
import com.answare.dataModel.CrisisContextANS;
import com.answare.db.QueriesDB;
import com.answare.settings.CTES;
import com.drools.utils.Event;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.*;
import org.drools.conf.EventProcessingOption;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import java.sql.SQLException;
/**
* This is the class that launch Expert System.
*/
public class AppExpertSystem {
StatefulKnowledgeSession ksession;
DSS_ANS optimizerDSS_ANS;
Event event;
RESTConnection restConnection;
public AppExpertSystem() {
loadKnowledgeBase();
optimizerDSS_ANS = new DSS_ANS(ksession);
event = new Event();
event.setNewEvent(true);
}
public AppExpertSystem(RESTConnection restConnection){
loadKnowledgeBase();
event = new Event();
event.setNewEvent(true);
this.restConnection = restConnection;
}
private void loadKnowledgeBase() {
// load up the knowledge base
KnowledgeBase kbase;
try {
kbase = readKnowledgeBase();
ksession = kbase.newStatefulKnowledgeSession();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(CTES.RULES),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM );
return kbase;
}
public String executeMessage(CrisisContextANS crisisContext) {
try {
storeInDatabaseCrisis(crisisContext,true);
ksession.setGlobal("optimizerDSS", optimizerDSS_ANS);
ksession.insert(crisisContext);
this.event.setType("CrisisContextANS");
ksession.insert(this.event);
int num = ksession.fireAllRules();
if (num != 0) {
this.event.setNewEvent(false);
return ("Run OK from Expert System");
}
return ("");
} catch (Throwable t) {
t.printStackTrace();
return ("Run NOT OK Expert System");
}
}
}
And the exception is in the method readKnowledgeBase(), in line
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
The only thing that I'm doing is to call to AppExpertSystem constructor :(
Any idea?
Thanks!
This class is gone from the 5.5.0.Final distribution. It was present in 5.3.0 and 5.4.0 (jar: drools-core.jar), presumably also earlier.
org.drools.base and ...evaluators wasn't part of the stable API in 5.3 and 5.4, so using it was risky.
If you post how your code is using that class, s.o. might come up with a way to work around this mishap.
Class org.drools.base.evaluators.EqualityEvaluatorsDefinition is typically configured into the builder by including a line
drools.evaluator.equality = org.drools.base.evaluators.EqualityEvaluatorsDefinition
in a file "drools.packagebuilder.conf" in the working directory, your home directory or on some jar's META-INF drools.default.packagebuilder.conf, or on a file pointed to by a system property "drools.packagebuilder.conf".
I have a code below. I can compile and run it normally in NetBeans. But with javac/java, I cannot run it normally. What do I miss?
The code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/* the original code is from link: http://edu.qudong.com/safe/base/Javascript/shilidaima/20080514/12527.html */
package gendemo;
/**
*
* #author tomxue
*/
class Gen2 {
private Object ob; //定义一个通用类型成员
public Gen2(Object ob) {
this.ob = ob;
}
public Object getOb() {
return ob;
}
public void setOb(Object ob) {
this.ob = ob;
}
public void showTyep() {
System.out.println("T的实际类型是: " + ob.getClass().getName());
}
}
public class GenDemo2 {
public static void main(String[] args) {
//定义类Gen2的一个Integer版本
Gen2 intOb = new Gen2(new Integer(88));
intOb.showTyep();
int i = (Integer) intOb.getOb();
System.out.println("value= " + i);
System.out.println("----------------------------------");
//定义类Gen2的一个String版本
Gen2 strOb = new Gen2("Hello Gen!");
strOb.showTyep();
String s = (String) strOb.getOb();
System.out.println("value= " + s);
}
}
By javac, after compiling, I got below result.
tomxue#ubuntu:~/test$ javac GenDemo2.java
tomxue#ubuntu:~/test$ ls
Gen2.class GenDemo2.class GenDemo2.java
And then, if I run it like this:
tomxue#ubuntu:~/test$ java Gen2
Exception in thread "main" java.lang.NoClassDefFoundError: Gen2
Caused by: java.lang.ClassNotFoundException: Gen2
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
tomxue#ubuntu:~/test$ java GenDemo2
Exception in thread "main" java.lang.NoClassDefFoundError: GenDemo2
Caused by: java.lang.ClassNotFoundException: GenDemo2
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
What is wrong with it?
The problem is that java expects the directory structure to match the package name ("gendemo"), so it can't find your classes. move your java file into a sub-directory named gendemo, then compile it from the top directory using javac gendemo/GenDemo2.java and run it using java -cp . gendemo.GenDemo2.
When you run java SomeClass JVM load SomeClass and trying to run SomeClass.main method.
So you should run:
java GenDemo2
or add:
public static void main(String[] args) to Gen2.java