我正在尝试将HardSoftScore保留为整数列,如 https://www.javacodegeeks.com/2015/09/integrating-jpa-hibernate-with-optaplanner.html 中所述。但是,在包含以下语句时,我收到以下错误
import org.optaplanner.persistence.jpa.impl.score.buildin.hardsoft.HardSoftScoreHibernateType;
以添加 TypeDef 注释。
构建时出错
Only a type can be imported. org.optaplanner.persistence.jpa.impl.score.buildin.hardsoft.HardSoftScoreHibernateType resolves to a package
我正在使用kie-wb 7.0.0.Beta6来创建optaplanner项目。
在pom.xml
中添加optaplanner-persistence-jpa
依赖项,以使用该 JPA 对 OptaPlanner 的支持。
Xstream 是通过 optaplanner-core 的瞬态依赖关系 - 您不必手动添加它。
通常不需要抛弃。
mvn help:effective-pom
检查您的有效pom - 您可能继承自某些降级XStream版本等的父pom。还要mvn dependency:tree -Dverbose
弄清楚谁在确定 xstream 版本。
下面是我的pom.xml。我只将 kie-maven-plugin 插件版本从 7.0.0-SNAPSHOT(由系统生成)更改为 7.0.0.Beta6,并添加了 optaplanner-persistence-jpa 依赖项。
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.optaplanner.examples</groupId>
<artifactId>cloud-balancing</artifactId>
<version>1.0</version>
<packaging>kjar</packaging>
<name>cloud-balancing</name>
<repositories>
<repository>
<id>guvnor-m2-repo</id>
<name>Guvnor M2 Repo</name>
<url>http://localhost:8080/jbpm-console/maven2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>7.0.0.Beta6</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.optaplanner/optaplanner-persistence-jpa -->
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-persistence-jpa</artifactId>
<version>7.0.0.Beta6</version>
</dependency>
</dependencies>
</project>
MVN帮助:有效-POM
[INFO] --- maven-help-plugin:2.2:effective-pom (default-cli) @ cloud-balancing ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.pom (5 KB at 10.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/2.4.3/maven-plugin-tools-2.4.3.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/2.4.3/maven-plugin-tools-2.4.3.pom (10 KB at 19.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.pom
Downloaded: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.pom (9 KB at 17.9 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream-parent/1.4.3/xstream-parent-1.4.3.pom
Downloaded: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream-parent/1.4.3/xstream-parent-1.4.3.pom (19 KB at 30.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar
Downloaded: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.jar (471 KB at 343.4 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar (51 KB at 27.5 KB/sec)
[INFO]
Effective POMs, after inheritance, interpolation, and profiles are applied:
除了日志显示 xstream-1.4.3.jar 外,没有下载有效 POM 中对 Xstream 的引用。
mvn dependency:tree -dverbose 表明 com.thoughtworks.xstream:xstream:jar:1.4.9 是 org.optaplanner:optaplanner-core 的依赖关系
重新启动服务器后,收到很多警告,如下所示
2017-03-13 23:45:28,539 INFO [org.drools.compiler.kie.builder.impl.KieRepositoryImpl] (EJB default - 2) KieModule was added: ZipKieModule[releaseId=org.optaplanner.examples:cloud-balancing:1.0,file=C:UsersUser.m2repositoryorgoptaplannerexamplescloud-balancing1.0cloud-balancing-1.0.jar]
2017-03-13 23:45:30,399 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.optaplanner.core.api.score.holder.AbstractScoreHolder$DoubleConstraintUndoListener due to org.optaplanner.core.api.score.holder.AbstractScoreHolder and org.optaplanner.core.api.score.holder.AbstractScoreHolder$DoubleConstraintUndoListener disagree on InnerClasses attribute
2017-03-13 23:45:30,400 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.optaplanner.core.api.score.holder.AbstractScoreHolder$MultiLevelActivationUnMatchListener due to org.optaplanner.core.api.score.holder.AbstractScoreHolder and org.optaplanner.core.api.score.holder.AbstractScoreHolder$MultiLevelActivationUnMatchListener disagree on InnerClasses attribute
2017-03-13 23:45:30,400 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.optaplanner.core.api.score.holder.AbstractScoreHolder$LongConstraintUndoListener due to org.optaplanner.core.api.score.holder.AbstractScoreHolder and org.optaplanner.core.api.score.holder.AbstractScoreHolder$LongConstraintUndoListener disagree on InnerClasses attribute
2017-03-13 23:45:30,401 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.optaplanner.core.api.score.holder.AbstractScoreHolder$IntConstraintUndoListener due to org.optaplanner.core.api.score.holder.AbstractScoreHolder and org.optaplanner.core.api.score.holder.AbstractScoreHolder$IntConstraintUndoListener disagree on InnerClasses attribute
2017-03-13 23:45:30,401 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.optaplanner.core.api.score.holder.AbstractScoreHolder$BigDecimalConstraintUndoListener due to org.optaplanner.core.api.score.holder.AbstractScoreHolder and org.optaplanner.core.api.score.holder.AbstractScoreHolder$BigDecimalConstraintUndoListener disagree on InnerClasses attribute
2017-03-13 23:45:30,515 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type ch.qos.logback.classic.boolex.EvaluatorTemplate due to groovy/lang/GroovyObject
2017-03-13 23:45:30,532 WARN [org.jboss.modules] (EJB default - 2) Failed to define class org.dom4j.xpp.ProxyXmlStartTag in Module "deployment.kie-server.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/dom4j/xpp/ProxyXmlStartTag (Module "deployment.kie-server.war:main" from Service Module Loader): org/gjt/xpp/XmlStartTag
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.drools.core.common.ProjectClassLoader.internalLoadClass(ProjectClassLoader.java:158)
at org.drools.core.common.ProjectClassLoader.loadClass(ProjectClassLoader.java:141)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.kie.server.services.drools.DroolsKieServerExtension.createContainer(DroolsKieServerExtension.java:108)
at org.kie.server.services.impl.KieServerImpl.createContainer(KieServerImpl.java:280)
at org.kie.server.services.impl.ContainerManager.installContainersSync(ContainerManager.java:43)
at org.kie.server.services.impl.ContainerManager.installContainers(ContainerManager.java:33)
at org.kie.server.jms.ContainerManagerEJB.installContainers(ContainerManagerEJB.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.tx.EjbBMTInterceptor.handleInvocation(EjbBMTInterceptor.java:103)
at org.jboss.as.ejb3.tx.BMTInterceptor.processInvocation(BMTInterceptor.java:58)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73)
at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.singleton.SingletonComponentInstanceAssociationInterceptor.processInvocation(SingletonComponentInstanceAssociationInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptor.processInvocation(ContainerManagedConcurrencyInterceptor.java:110)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:66)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636)
at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:195)
at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.LogDiagnosticContextRecoveryInterceptor.processInvocation(LogDiagnosticContextRecoveryInterceptor.java:82)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.AsyncFutureInterceptorFactory$1$2.runInvocation(AsyncFutureInterceptorFactory.java:101)
at org.jboss.as.ejb3.component.interceptors.AsyncInvocationTask.run(AsyncInvocationTask.java:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
2017-03-13 23:45:30,534 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.dom4j.xpp.ProxyXmlStartTag due to Failed to link org/dom4j/xpp/ProxyXmlStartTag (Module "deployment.kie-server.war:main" from Service Module Loader): org/gjt/xpp/XmlStartTag
2017-03-13 23:45:31,012 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unexpected error while create instance of type org.drools.core.reteoo.RuleTerminalNode$RTNCleanupAdapter due to org.drools.core.reteoo.RuleTerminalNode and org.drools.core.reteoo.RuleTerminalNode$RTNCleanupAdapter disagree on InnerClasses attribute
2017-03-13 23:45:31,057 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unable to create instance of type org.apache.xmlcommons.Version due to org.apache.xmlcommons.Version
2017-03-13 23:45:31,153 WARN [org.kie.server.services.drools.DroolsKieServerExtension] (EJB default - 2) Unable to create instance of type javax.xml.stream.FactoryFinder$ConfigurationError due to javax.xml.stream.FactoryFinder$ConfigurationError
2017-03-13 23:45:31,350 WARN [org.jboss.modules] (EJB default - 2) Failed to define class com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter$ReverseEngineeredCallbackFilter in Module "deployment.kie-server.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter$ReverseEngineeredCallbackFilter (Module "deployment.kie-server.war:main" from Service Module Loader): net/sf/cglib/proxy/CallbackFilter