Im already running morphia over mongDb in eclipse win7 64bit.
reading about the log4mongo here:
http://log4mongo.org/display/PUB/Log4mongo+for+Java
following the steps but get this:
log4j:ERROR Could not instantiate class [com.google.code.log4mongo.MongoDbAppender].
java.lang.ClassNotFoundException: com.google.code.log4mongo.MongoDbAppender
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:752)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at LogTest.main(LogTest.java:6)
log4j:ERROR Could not instantiate appender named "MongoDB".
log4j:WARN No appenders could be found for logger (LogTest).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I have the log4j.properties in my eclipse bin folder(maybe wrong but get no response elsewhere).
This files are importet:
log4mongo-java-0.7.0.jar
log4j-1.2.16.jar
mongo-2.6.5.jar
This is the log4j.properties:
log4j.rootLogger=error, MongoDB
log4j.appender.MongoDB=com.google.code.log4mongo.MongoDbAppender
log4j.appender.MongoDB.databaseName=appname
log4j.appender.MongoDB.collectionName=log
Im also startet a mongo shell that's waiting for connections
here's the starter:
import org.apache.log4j.Logger;
public class LogTest {
public static void main(String[] args) {
Logger logger = Logger.getLogger(LogTest.class);
logger.error("Don't panic");
}
}
this is working as expected
log4j.rootLogger=error, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Try change appender name.
"com.google.code.log4mongo.MongoDbAppender" -> "org.log4mongo.MongoDbAppender".
log4mongo-java-0.7.0.jar used this package.
Related
I am trying to run the Machine Learning and Anylogic Simulation example workflow provided here. - https://www.anylogic.com/features/artificial-intelligence/h2o-ai/
I can run the second workflow, but the first workflow (Hospital Planning) keeps giving errors. I have tried it running on different systems as well.
Any help will be highly appreciated.
Below is the error code :
Loading Mojo: pipeline.mojo
Loading Mojo: pipeline.mojo
Error during model creation:
Unable to make protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to
unnamed module #44f69442
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to
unnamed module #44f69442
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
at javassist.util.proxy.SecurityActions.setAccessible(SourceFile:159)
at javassist.util.proxy.DefineClassHelper$JavaOther.defineClass(SourceFile:213)
at javassist.util.proxy.DefineClassHelper$Java11.defineClass(SourceFile:52)
at javassist.util.proxy.DefineClassHelper.toClass(SourceFile:260)
at javassist.ClassPool.toClass(SourceFile:1232)
at javassist.ClassPool.toClass(SourceFile:1090)
at javassist.ClassPool.toClass(SourceFile:1048)
at javassist.CtClass.toClass(SourceFile:1290)
at ai.h2o.mojos.runtime.c.G.d(SourceFile:118)
at ai.h2o.mojos.runtime.c.G.a(SourceFile:60)
at ai.h2o.mojos.runtime.c.n.a(SourceFile:64)
at ai.h2o.mojos.runtime.readers.b.b.a(SourceFile:135)
at ai.h2o.mojos.runtime.MojoPipelineFactoryImpl.loadFrom(SourceFile:144)
at ai.h2o.mojos.runtime.MojoPipelineFactoryImpl.loadFrom(SourceFile:101)
at ai.h2o.mojos.runtime.MojoPipeline.loadFrom(SourceFile:41)
at hospital_capacity_planning_ml.Main.loadModel(Main.java:690)
at hospital_capacity_planning_ml.Main.setupPlainVariables_Main_xjal(Main.java:1498)
at hospital_capacity_planning_ml.Main.doCreate(Main.java:1421)
at com.anylogic.engine.Agent.createAsEmbedded(Unknown Source)
at com.anylogic.engine.Agent.create(Unknown Source)
at com.anylogic.engine.Engine.start(Unknown Source)
at com.anylogic.engine.ExperimentSimulation.a(Unknown Source)
at com.anylogic.engine.ExperimentSimulation.run(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost.f(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost.executeCommand(Unknown Source)
at com.anylogic.engine.internal.webserver.e.onCommand(Unknown Source)
at com.anylogic.executor.basic.rest.BasicAnimationSessionController.
lambda$null$9(BasicAnimationSessionController.java:112)
at com.anylogic.engine.internal.webserver.i.acceptToAnimationSvgSession(Unknown Source)
at com.anylogic.executor.basic.rest.BasicAnimationSessionController.
lambda$startController$10(BasicAni mationSessionController.java:112)
at spark.ResponseTransformerRouteImpl$1.handle(ResponseTransformerRouteImpl.java:47)
at spark.http.matching.Routes.execute(Routes.java:61)
at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:130)
at com.anylogic.engine.internal.webserver.config.ALServerFactory$1.lambda$0(Unknown Source)
at org.eclipse.jetty.servlets.QoSFilter.doFilter(QoSFilter.java:201)
at com.anylogic.engine.internal.webserver.config.ALServerFactory$1.doHandle(Unknown Source)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:530)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
atorg.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java
:382)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
at java.base/java.lang.Thread.run(Thread.java:834)
Error during drawing animation frame:
java.lang.NullPointerException
at com.anylogic.engine.gui.SVGFrameProducer.n(Unknown Source)
at com.anylogic.engine.gui.SVGFrameProducer.n(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost$1.l(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost$1.n(Unknown Source)
at com.anylogic.engine.gui.SVGFrameCollector.l(Unknown Source)
at com.anylogic.engine.gui.SVGFrameCollector.c(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:834)
The problem is that AnyLogic 8.7 switched to newer Java (from 9 to 11).
Add the following line to Java machine arguments in the experiment properties to make the model work in the recent updates 8.7.x:
--add-opens java.base/java.lang=ALL-UNNAMED
JBoss Server Version : 7.3
Java Version : 1.8
IDE : eclipse
Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:64)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at test.Client.main(Client.java:17)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
Below mentioned jars are added in build-path even after getting exception. java.lang.ClassNotFoundException: org.jboss.logging.Logger .
jbossall-client.jar
jboss-common-client.jar
jboss-logging-3.3.2.Final.jar
jboss-remote-naming-1.0.7.final.jar
Code
Main.java
public static void main(String[] args) {
try {
InputStream input;
input = new FileInputStream("/lookup.properties");
Properties prop = new Properties();
prop.load(input);
InitialContext initialContext = new InitialContext(getJBossClientProperties());
Object obj = initialContext.lookup(prop.getProperty("lookup"));
System.out.println("Got EJB : "+obj);
} catch (Exception e) {
System.out.println("Error : "+e);
}
}
private static Properties getJBossClientProperties() throws Exception {
InputStream input = new FileInputStream("/config.properties");
Properties prop = new Properties();
prop.load(input);
return prop;
}
lookup.properties
lookup=jndi_lookup
config.properties
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true
I tried above in glassfish works fine , i know its jboss...
I found another relevant post here
java.lang.ClassNotFoundException: org.jboss.logging.Logger
grep for;
When I added the jbossall-client.jar from tje jboss installtion path(../jboss-5.1.0.GA\client) and not from the lib folder, it worked.
that could be your answer.....
Here is my code I am trying to run:
import scala.swing._
object MyApp extends SimpleSwingApplication{
def top = new MainFrame{
contents = new Label("GUI stuff")
}
}
I am running the code through command line. In my directory, I have the code above (app2.scala), a scala swing jar file (scala-swing_2.13-2.1.1.jar).
I am compiling the scala file like:
scalac -cp "scala-swing_2.13-2.1.1.jar" app2.scala
then trying to run it through
scala MyApp
But I get an error:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/swing/MainFrame
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at scala.reflect.internal.util.ScalaClassLoader.run(ScalaClassLoader.scala:101)
at scala.reflect.internal.util.ScalaClassLoader.run$(ScalaClassLoader.scala:97)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:130)
at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:29)
at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:43)
at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:34)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:91)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.ClassNotFoundException: scala.swing.MainFrame
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more
How can I fix this?
I checked that my scala version is the same as the version for swing. I am running 2.13.2
I tried to load the package from the Guvnor using the following piece of code :-
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("GenderFact.xml"),ResourceType.CHANGE_SET);
System.out.println("fair trial");
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());
return kbase;
and the contents of the GenderFact.xml are :-
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">
<add>
<resource
source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/MyLastTrial/LATEST/"
type="PKG" basicAuthentication="disabled" username="admin" password="admin" />
</add>
When I tried to execute this from Eclipse , I get the following error :-
java.lang.RuntimeException: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:705)
at org.drools.compiler.PackageBuilder.addPackageFromChangeSet(PackageBuilder.java:772)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:43)
at com.sample.DroolsTest.main(DroolsTest.java:26)
Caused by: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.HashMap.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:59)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.rule.Package.readExternal(Package.java:208)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205)
at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189)
at org.drools.compiler.PackageBuilder.addPackageFromInputStream(PackageBuilder.java:781)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
... 6 more
Preconditions :-
I use Guvnor 5.3 with jboss AS 7.0.
Both the client and the server are sharing the same jre7.
Drools runtime 5.3 in Eclipse Indigo (Service Release 2)
Requesting for a workaround ...
Drools related jars used in java project are NOT of same version as used in GUvnor 5.3.
Use jars from Guvnor 5.3 into your java project.
It will solve problem. :)
I'm new to persevere, I did the helloWorld tutorial, very impressive btw but I'm now trying to connect to a real postgres database and find myself struggling having the driver recognized when I have the feeling it should be dead simple.
I dropped all the jdbc driver for postgres I had to the persevere/lib folder:
postgresql-8.3-603.jdbc2ee.jar
postgresql-8.3-603.jdbc2.jar
postgresql-8.3-603.jdbc3.jar
postgresql-8.3-603.jdbc4.jar
And yet when I start persevere with the command "persvr" with no argument from my project folder I get the following error message:
java.lang.ClassNotFoundException: org.postgresql.Driver
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 org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:379)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:341)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.persvr.datasource.DatabaseDataSource.initParameters(Unknown Source)
at org.persvr.datasource.DatabaseTableDataSource.initParameters(Unknown Source)
at org.persvr.data.DataSourceManager.initSource(Unknown Source)
at org.persvr.data.DataSourceManager.<clinit>(Unknown Source)
at org.persvr.data.Identification.idForString(Unknown Source)
at org.persvr.Persevere.load(Unknown Source)
at org.persvr.job.SampleData.execute(Unknown Source)
at org.persvr.job.Upgrade.execute(Unknown Source)
at org.persvr.remote.PersevereFilter.init(Unknown Source)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:620)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1234)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:460)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.persvr.util.JettyStart.main(Unknown Source)
I'm actually trying to expand the helloWorld project as an exercize, so I've added a postgres.json file in my helloWorld/WEB-INF/config folder. Here is the content of that file:
{"id":"postgres.json",
"sources":[
{"name":"addressTable",
"sourceClass":"org.persvr.datasource.DatabaseTableDataSource",
"connection":"jdbc:postgresql://hostname:5432/pnp?user=user1&pass=mypassword",
"driver":"org.postgresql.Driver",
"camelCaseColumnNames": false,
"table":"addr",
"idColumn":"addr_id",
"dataColumns":["addr_stat_cd","addr1","addr2","city","state","zip","zip_ext","cntry_cd","last_upd_uid","last_upd_dttm","create_uid","create_dt
tm"],
"schema":{
"data":{"$ref":"../addressTable/"}
}
}]
}
Could anyone tell me why persevere can't find that postgres driver please?
Thanks,
Lancelot.
Figured it out. The postgres driver jar should actually go into the folder: persevere/WEB-INF/lib instead of the persevere/lib.