Cayenne null pointer error when trying to commit changes - java

I'm running the following code that errors when I try to commit my changes using Cayenne as my ORM. The code is pasted below and errors out on the context.commitChanges();line. The output messages are pasted below the code. Any help on figuring this out would be appreciated.
import org.apache.cayenne.access.DataContext;
import java.util.*;
import com.jared.*;
public class Main {
public static void main(String[] args) {
DataContext context = DataContext.createDataContext();
Stocks theStock=(Stocks) context.createAndRegisterNewObject(Stocks.class);
theStock.setAsk(3.4);
theStock.setAvgdailyvolume(323849);
theStock .setBid(5.29);
theStock.setChange(-1.22);
theStock.setDayhigh(9.21);
theStock.setDaylow(2.11);
theStock.setLasttradeprice(5.11);
theStock.setLasttradesize(3827);
theStock.setOpen(6.21);
theStock.setPriorclose(4.21);
theStock.setShortratio(1.1);
theStock.setSymbol("^SP%");
theStock.setVolume(28193);
theStock.setLasttradedate(new Date());
context.commitChanges();
System.out.println("Done with the database");
}
}
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate startedLoading
INFO: started configuration loading.
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate shouldLoadDataDomain
INFO: loaded domain: stocks
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate loadDataMap
INFO: loaded .
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate shouldLoadDataNode
INFO: loading .
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate shouldLoadDataNode
INFO: using factory: org.apache.cayenne.conf.DriverDataSourceFactory
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.DriverDataSourceFactory load
INFO: loading driver information from 'stocksNode.driver.xml'.
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.DriverDataSourceFactory$DriverHandler init
INFO: loading driver org.hsqldb.jdbcDriver
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.DriverDataSourceFactory$LoginHandler init
INFO: loading user name and password.
Nov 20, 2008 11:20:37 PM org.apache.cayenne.access.QueryLogger logPoolCreated
INFO: Created connection pool: jdbc:hsqldb:file:/hsqldb/data/stocks
Driver class: org.hsqldb.jdbcDriver
Min. connections in the pool: 1
Max. connections in the pool: 1
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate shouldLoadDataNode
INFO: loaded datasource.
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate initAdapter
INFO: no adapter set, using automatic adapter.
Nov 20, 2008 11:20:37 PM org.apache.cayenne.conf.RuntimeLoadDelegate finishedLoading
INFO: finished configuration loading in 203 ms.
Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: [v.3.0M4 May 18 2008 16:32:02] Commit Exception
at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1192)
at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1066)
at Main.main(Main.java:24)
Caused by: java.lang.NullPointerException
at org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainInsertBucket.java:101)
at org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(DataDomainInsertBucket.java:76)
at org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyncBucket.java:80)
at org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlushAction.java:183)
at org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:135)
at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:821)
at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:788)
at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:847)
at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:785)
at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1164)
... 2 more

user name, password?
ClientConnection connection = new
HessianConnection("http://localhost:8080/cayenne-service",
"cayenne-user", "secret",
null);

Related

how overcome this error "com.mongodb.diagnostics.logging.JULLogger log"

I am working with java program connected with MongoDB when I run the program it will show an error but code is working.
MongoDB has a database called MongoDB and inside that, there is a collection called seatbooking with two columns(name,seatnumber).
This is my code:
MongoClient mongoClient = new MongoClient("localhost", 27017);
System.out.println("connection is established");
MongoDatabase mongoDatabase = mongoClient.getDatabase("MongoDB");
MongoCollection mongoCollection = mongoDatabase.getCollection("seatbooking");
Document document = new Document("name","shenal");
document.append("seatnumber",20);
mongoCollection.insertOne(document);
when I run this code my output is:
> Mar 09, 2020 12:41:36 PM
> com.mongodb.diagnostics.logging.JULLogger log INFO: Cluster created
> with settings {hosts=[localhost:27017], mode=SINGLE,
> requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms',
> maxWaitQueueSize=500}
> **connection is established** Mar 09, 2020 12:41:36 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Cluster
> description not yet available. Waiting for 30000 ms before timing out
> Mar 09, 2020 12:41:36 PM com.mongodb.diagnostics.logging.JULLogger log
> INFO: Opened connection [connectionId{localValue:1, serverValue:309}]
> to localhost:27017 Mar 09, 2020 12:41:36 PM
> com.mongodb.diagnostics.logging.JULLogger log INFO: Monitor thread
> successfully connected to server with description
> ServerDescription{address=localhost:27017, type=STANDALONE,
> state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2,
> 2]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216,
> logicalSessionTimeoutMinutes=30, roundTripTimeNanos=5168100} Mar 09,
> 2020 12:41:36 PM com.mongodb.diagnostics.logging.JULLogger log INFO:
> Opened connection [connectionId{localValue:2, serverValue:310}] to
> localhost:27017
The logging output doesn't show any result for the insertOne operation.
If you are using MongoDB Java Driver version prior to 4.0, there is no acknowledgement object returned. But, the version 4's insertOne method returns a InsertOneResult object. This is a new feature in 4.0 (in prior version's the method returned a void).
You can use the following code to check the insert's outcome as follows (with version 4.0):
try {
InsertOneResult insertResult = collection.insertOne(document);
System.out.println("Document inserted with ID: " + insertResult.getInsertedId());
}
catch(MongoWriteException e) {
// write failure happened, handle it here...
}

How to suppress htmlunit (Java library) warning/error messages?

I'm using htmlunit [http://htmlunit.sourceforge.net/] and it spews out a bunch of warnings/error:
Mar 24, 2017 6:37:30 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:31 PM com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS
INFO: Bad input type: "datetime", creating a text input
Mar 24, 2017 6:37:31 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'application/x-javascript'.
Mar 24, 2017 6:37:32 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'application/x-javascript'.
Mar 24, 2017 6:37:34 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:34 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: :x).] sourceName=[https://www.example.com/bundles/jquery?v=u8J3xxyrazUhSJl-OWRJ6I82HpC6Fs7PQ0-l8XzoZXY1] line=[1] lineSource=[null] lineOffset=[0]
Mar 24, 2017 6:37:35 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:35 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:35 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:36 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Mar 24, 2017 6:37:43 PM com.gargoylesoftware.htmlunit.javascript.host.dom.Document createElement
INFO: createElement: Provided string 'iframe name="rufous-frame-29_-1">https://platform.twitter.com/widgets.js] line=[9] lineSource=[null] lineOffset=[0]
I've looked at other resources and tried to turn it off by:
Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
Logger.getLogger("org.apache.http").setLevel(Level.OFF);
and:
final WebClient webClient = new WebClient(BrowserVersion.EDGE);
but it does not work.
What else can be done to suppress these warning/error messages?
If you are not going set the loggers to OFF in 'logging.properties' file then you need pin the loggers with a hard reference before you set the level to OFF.
Here is a corrected example based off your code:
private static final Logger[] PINNED_LOGGERS;
static {
System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "fatal");
PINNED_LOGGERS = new Logger[]{
Logger.getLogger("com.gargoylesoftware.htmlunit"),
Logger.getLogger("org.apache.http")
};
for (Logger l : PINNED_LOGGERS) {
l.setLevel(Level.OFF);
}
}
I put the following at the start of the application and the errors/warnings stopped:
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
Logger.getLogger("org.apache.http").setLevel(Level.OFF);

Getting Error while creating EventHubClient in Microsoft Azure

I am using the latest 0.8.2 jar for java eventhub library and I have used the following code to send the data to azure eventhub :
ConnectionStringBuilder connStr = new ConnectionStringBuilder(connectionstring);
byte[] payloadBytes = valueChangeMessage.data.get().toString().getBytes("UTF-8");
EventData sendEvent = new EventData(payloadBytes);
EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString());
ehClient.sendSync(sendEvent);
But I am getting the following error:
Sep 15, 2016 3:31:25 PM org.apache.qpid.proton.engine.impl.ssl.SslEngineFacadeFactory getClass
WARNING: unable to load org.bouncycastle.openssl.PEMReader
Sep 15, 2016 3:31:25 PM org.apache.qpid.proton.engine.impl.ssl.SslEngineFacadeFactory <clinit>
WARNING: unable to load bouncycastle provider
Sep 15, 2016 3:31:26 PM com.microsoft.azure.servicebus.MessagingFactory$RunReactor run
WARNING: UnHandled exception while processing events in reactor:
java.lang.IllegalArgumentException
org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:112)
org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:309)
org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:277)
com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:332)
java.lang.Thread.run(Thread.java:745)Cause: null
java.nio.Buffer.position(Buffer.java:244)
org.apache.qpid.proton.engine.impl.ssl.SimpleSslTransportWrapper.pop(SimpleSslTransportWrapper.java:411)
org.apache.qpid.proton.engine.impl.ssl.SslImpl$UnsecureClientAwareTransportWrapper.pop(SslImpl.java:185)
org.apache.qpid.proton.engine.impl.TransportImpl.pop(TransportImpl.java:1476)
org.apache.qpid.proton.reactor.impl.SelectorImpl.select(SelectorImpl.java:145)
org.apache.qpid.proton.reactor.impl.IOHandler.handleQuiesced(IOHandler.java:57)
org.apache.qpid.proton.reactor.impl.IOHandler.onUnhandled(IOHandler.java:381)
org.apache.qpid.proton.engine.BaseHandler.onReactorQuiesced(BaseHandler.java:87)
org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:206)
org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:309)
org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:277)
com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:332)
java.lang.Thread.run(Thread.java:745)
Sep 15, 2016 3:31:26 PM com.cognizant.iotworkbench.Channel.CatChannel sendPOST
SEVERE: null
com.microsoft.azure.servicebus.ServiceBusException: java.lang.IllegalArgumentException, TrackingId: a9055d98-2dff-4cc0-af1f-38a9718b3cf5, at: 2016-09-15T15:31:26.462+05:30[Asia/Calcutta]
at com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:357)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:244)
at org.apache.qpid.proton.engine.impl.ssl.SimpleSslTransportWrapper.pop(SimpleSslTransportWrapper.java:411)
at org.apache.qpid.proton.engine.impl.ssl.SslImpl$UnsecureClientAwareTransportWrapper.pop(SslImpl.java:185)
at org.apache.qpid.proton.engine.impl.TransportImpl.pop(TransportImpl.java:1476)
at org.apache.qpid.proton.reactor.impl.SelectorImpl.select(SelectorImpl.java:145)
at org.apache.qpid.proton.reactor.impl.IOHandler.handleQuiesced(IOHandler.java:57)
at org.apache.qpid.proton.reactor.impl.IOHandler.onUnhandled(IOHandler.java:381)
at org.apache.qpid.proton.engine.BaseHandler.onReactorQuiesced(BaseHandler.java:87)
at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:206)
at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:309)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:277)
at com.microsoft.azure.servicebus.MessagingFactory$RunReactor.run(MessagingFactory.java:332)
... 1 more
Can anyone help me with finding the possible issue for this?

Connection immediately is aborted when trying to connect to remote cluster-node

I am trying to connect to an Elasticsearch cluster form a Java application by using the TransportClient.
I have successfully tested connected to a cluster running locally.
Now we have set up a remote cluster in the EC2-Cloud. Accessing it via REST intefaces work, also Kibana works.
I can run my application on the Elasticsearch Node directly successfully.
However when I try to connect remotely from another host, the log indicates that the connection succeeds, but then immediately fails with "An established connection was aborted by the software in your host machine".
I have verified that both server and client run the same version of Elasticsearch. Also the firewall configuration should allow communication on port 9300 as this is also needed for the cluster-nodes to communicate between each other.
Okt 21, 2015 6:50:24 PM com.example.elasticsearch.visit.nativescript.ElasticsearchTest main
INFO: Setting adress to myhost.com:9300
Okt 21, 2015 6:50:24 PM org.elasticsearch.client.transport.TransportClientNodesService addTransportAddresses
FINE: [Master Man] adding address [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]]
Okt 21, 2015 6:50:24 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
FINEST: [Master Man] connecting to listed node (light) [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]]
Okt 21, 2015 6:50:24 PM org.elasticsearch.transport.netty.NettyTransport connectToNode
FINE: [Master Man] connected to node [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]]
Okt 21, 2015 6:50:24 PM org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker addWithoutBreaking
FINEST: [Master Man] [REQUEST] Adjusted breaker by [16440] bytes, now [16440]
Okt 21, 2015 6:50:24 PM org.elasticsearch.transport.TransportService$Adapter traceRequestSent
FINEST: [Master Man] [0][cluster:monitor/nodes/info] sent to [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]] (timeout: [5s])
Okt 21, 2015 6:50:24 PM org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker addWithoutBreaking
FINEST: [Master Man] [REQUEST] Adjusted breaker by [-16440] bytes, now [0]
Okt 21, 2015 6:50:24 PM org.elasticsearch.transport.netty.NettyTransport exceptionCaught
FINEST: [Master Man] close connection exception caught on transport layer [[id: 0xd938d867, /x.x.x.x:60058 => myhost.com/1.1.1.1:9300]], disconnecting from relevant node
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:64)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
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)
Okt 21, 2015 6:50:24 PM org.elasticsearch.transport.netty.NettyTransport disconnectFromNode
FINE: [Master Man] disconnecting from [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]], channel closed event
Okt 21, 2015 6:50:24 PM org.elasticsearch.transport.netty.NettyTransport disconnectFromNode
FINEST: [Master Man] disconnected from [[#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]]], channel closed event
Okt 21, 2015 6:50:24 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
INFO: [Master Man] failed to get node info for [#transport#-1][LNZ123675N02][inet[myhost.com/1.1.1.1:9300]], disconnecting...
org.elasticsearch.transport.NodeDisconnectedException: [][inet[myhost.com/1.1.1.1:9300]][cluster:monitor/nodes/info] disconnected
Okt 21, 2015 6:50:24 PM com.example.elasticsearch.visit.nativescript.ElasticsearchTest main
INFO: Having: []
Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:305)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:200)
at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
at org.elasticsearch.client.support.AbstractClient.bulk(AbstractClient.java:167)
at org.elasticsearch.client.transport.TransportClient.bulk(TransportClient.java:370)
at org.elasticsearch.action.bulk.BulkRequestBuilder.doExecute(BulkRequestBuilder.java:166)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at com.example.elasticsearch.visit.nativescript.ElasticsearchTest.main(ElasticsearchTest.java:68)
My simple test looks like this:
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "cluster-name")
.build();
logger.info("Creating client");
try (final TransportClient client = new TransportClient(settings)) {
logger.info("Setting adress to " + host + ":" + port);
client.addTransportAddress(new InetSocketTransportAddress(host, port));
logger.info("Having: " + client.connectedNodes());
BulkRequestBuilder bulkRequest = client.prepareBulk();
String json= "{ id: \"12345678\", value: \"value\" }";
bulkRequest.add(client.prepareIndex(INDEX, TYPE, "12345678").
setSource(json));
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
logger.info("Could not write bulk: " + bulkResponse.buildFailureMessage());
} else {
logger.info("Wrote");
}
}
I also tried to verify some common things like cluster-name not set and others.
Also when I use a completely different port, I get a timeout as expected, not this error-message. So the port is definitely behaving different.
Where would I start to look? Can this still be a firewall issue where connections are dropped only after a short while instead of being rejected immediately?
With more testing I actually found out that a company-firewall was interfering in a strange way. When I run the same client-code on a machine outside the company-netowrk, it works fine.

J-Monkey subclass

I'm new in java and J-monkey and I'm trying to make a java game so for the Menu I have made a enum so I can Switch between any of my State but I want to keep the main file shorter so it can be easily to read so I'm making subclass the problem is that when run the game it give me an error that say "Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] NullPointerException" I think this problem has to be something whit the pipeline Here is the code of my main file:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
import com.jme3.scene.Geometry;
import com.jme3.input.*;
import com.jme3.input.controls.*;
public class Main extends SimpleApplication {
//GameStates
enum GameState{Logo, Menu, Playing, Option};
GameState gameState = GameState.Logo;
//Class Variables
Logo logo;
public Main() {
logo = new Logo();
}
public static void main(String[] args) {
Main app = new Main();
app.start();
}
public static void logo(String[] args) {
Logo app = new Logo();
app.start();
}
#Override
public void simpleInitApp() {
//Load
flyCam.setMoveSpeed(20);
if(gameState == GameState.Logo){
logo.simpleInitApp();
}
}
#Override
public void simpleUpdate(float tpf) {
}
#Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
//Load
if(gameState == GameState.Logo)
{
}
}
}
And here is my Logo subclass:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
public class Logo extends SimpleApplication {
#Override
public void simpleInitApp() {
Spatial Logo_Model = assetManager.loadModel("Models/Teapot/Logo.obj");
rootNode.attachChild(Logo_Model);
}
public void simpleRender(RenderManager rm) {
//Load
}
}
I have move down the stack trace that I think is giving my problem so you don't have to read all the Exception just scroll down
Full Exception stack trace:
Nov 09, 2013 11:29:32 AM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Nov 09, 2013 11:29:49 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta
Nov 09, 2013 11:29:49 AM com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: C:\Users\Zero\Documents\Basic_Test_menu
Nov 09, 2013 11:29:49 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run
INFO: Using LWJGL 2.8.4
Nov 09, 2013 11:29:49 AM com.jme3.system.lwjgl.LwjglDisplay createContext
INFO: Selected display mode: 800 x 600 x 0 #0Hz
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: igdumd64
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: null
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Intel
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 3.1.0 - Build 9.17.10.2932
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: Intel(R) HD Graphics
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 1.40 - Intel Build 9.17.10.2932
Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglTimer
INFO: Timer resolution: 1,000 ticks per second
Nov 09, 2013 11:29:50 AM com.jme3.renderer.lwjgl.LwjglRenderer initialize
INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, VertexTextureFetch, TextureArray, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray, Multisample, PackedDepthStencilBuffer]
Nov 09, 2013 11:29:50 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Nov 09, 2013 11:29:50 AM com.jme3.asset.DesktopAssetManager
INFO: DesktopAssetManager created.
Nov 09, 2013 11:29:50 AM com.jme3.renderer.Camera
INFO: Camera created (W: 800, H: 600)
Nov 09, 2013 11:29:50 AM com.jme3.renderer.Camera
INFO: Camera created (W: 800, H: 600)
Nov 09, 2013 11:29:50 AM com.jme3.input.lwjgl.LwjglMouseInput initialize
INFO: Mouse created.
Nov 09, 2013 11:29:50 AM com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
Nov 09, 2013 11:29:51 AM com.jme3.material.MaterialDef
INFO: Loaded material definition: Unshaded
Nov 09, 2013 11:29:51 AM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Nov 09, 2013 11:29:51
AM com.jme3.app.Application handleError SEVERE: Uncaught exception
thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Logo.simpleInitApp(Logo.java:17)
at mygame.Main.simpleInitApp(Main.java:46)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)
Nov 09, 2013 11:29:51 AM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
Nov 09, 2013 11:29:51 AM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
Nov 09, 2013 11:29:51 AM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
Nov 09, 2013 11:29:51 AM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
The problem is assetManager is null at that point in time. Either you assign it too late or you forget to assign it at all.

Categories

Resources