I'm getting a java.util.zip.ZipException: invalid bit length repeat when attempting to retrieve a AuthnRequest with the opensaml library HTTPRedirectDeflateDecoder. I'm receiving the deflated and encoded SAMLObject thorough a GET request. This is the code I'm using to retrieve the object
import org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder;
protected String getAuthnRequest(
HttpServletRequest request,
HttpServletResponse response) throws Exception {
HTTPRedirectDeflateDecoder decoder = new HTTPRedirectDeflateDecoder();
decoder.setHttpServletRequest(request);
try {
decoder.initialize();
decoder.decode(); //error occurs here
} catch (ComponentInitializationException | MessageDecodingException e) {
throw new Exception("error in decoding authnrequest", e);
}
MessageContext<SAMLObject> messageContext = decoder.getMessageContext();
...
}
Full error:
org.opensaml.messaging.decoder.MessageDecodingException: Error unmarshalling message from input stream
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.unmarshallMessage(BaseHttpServletRequestXMLMessageDecoder.java:158)
at org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder.doDecode(HTTPRedirectDeflateDecoder.java:108)
at org.opensaml.messaging.decoder.AbstractMessageDecoder.decode(AbstractMessageDecoder.java:58)
at org.opensaml.messaging.decoder.servlet.AbstractHttpServletRequestMessageDecoder.decode(AbstractHttpServletRequestMessageDecoder.java:55)
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.decode(BaseHttpServletRequestXMLMessageDecoder.java:72)
at com.healthtrio.htcweb.common.controller.sso.BaseOutboundController.getAuthnRequestId(BaseOutboundController.java:426)
... 129 common frames omitted
Caused by: net.shibboleth.utilities.java.support.xml.XMLParserException: Unable to read data from input stream
at net.shibboleth.utilities.java.support.xml.BasicParserPool.parse(BasicParserPool.java:255)
at org.opensaml.core.xml.util.XMLObjectSupport.unmarshallFromInputStream(XMLObjectSupport.java:235)
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.unmarshallMessage(BaseHttpServletRequestXMLMessageDecoder.java:154)
... 134 common frames omitted
Caused by: java.util.zip.ZipException: invalid bit length repeat
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:165)
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:123)
at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.readAndBuffer(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
at net.shibboleth.utilities.java.support.xml.BasicParserPool$DocumentBuilderProxy.parse(BasicParserPool.java:785)
at net.shibboleth.utilities.java.support.xml.BasicParserPool.parse(BasicParserPool.java:247)
... 136 common frames omitted
Any help is appreciated,
Thanks
Found the error, This was a mistake from the data I was testing with. I used a deflated/encoded AuthnRequest. Since this is a GET request, I had to also URL decode the SAML Object.
Related
The SAX parser is throwing 403 exception for a valid URL, which loads without any issues in a browser. We are able to reproduce the problem with the sample code that follows. Pointers appreciated.
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.helpers.DefaultHandler;
public class StackOverflow {
public static void main(String[] args) {
SAXParserFactory factory2 = SAXParserFactory.newInstance();
try {
String uri;
uri = "https://www.sec.gov/Archives/edgar/data/1326801/000132680119000009/FilingSummary.xml"; // Does not work
// uri = "https://www.w3schools.com/xml/simple.xml"; // ** Works if this line is uncommented **
SAXParser saxParser = factory2.newSAXParser();
DefaultHandler eventHandler = new DefaultHandler();
saxParser.parse(uri, eventHandler);
// ...
// Business Logic
// ...
System.out.println("SUCCESS");
}
catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
The stacktrace is as follows:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.sec.gov/Archives/edgar/data/1326801/000132680119000009/FilingSummary.xml
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at StackOverflow.main(StackOverflow.java:15)
I have created custom entry processor for updating map entries by extending AbstractEntryProcessor.
When my app is running in a cluster on two instances, and the entry processor is executed I receive following exception:
com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to serialize 'com.hazelcast.spi.impl.operationservice.impl.operations.Backup'
at com.hazelcast.internal.serialization.impl.SerializationUtil.handleSerializeException(SerializationUtil.java:73)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:143)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:124)
at com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl.send(OperationServiceImpl.java:406)
at com.hazelcast.spi.impl.operationservice.impl.OperationBackupHandler.sendSingleBackup(OperationBackupHandler.java:187)
at com.hazelcast.spi.impl.operationservice.impl.OperationBackupHandler.makeBackups(OperationBackupHandler.java:159)
at com.hazelcast.spi.impl.operationservice.impl.OperationBackupHandler.backup(OperationBackupHandler.java:78)
at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.sendBackup(OperationRunnerImpl.java:270)
at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.handleResponse(OperationRunnerImpl.java:253)
at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:182)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:122)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:102)
Caused by: com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to serialize 'com.hazelcast.map.impl.operation.PartitionWideEntryWithPredicateBackupOperation'
at com.hazelcast.internal.serialization.impl.SerializationUtil.handleSerializeException(SerializationUtil.java:73)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.writeObject(AbstractSerializationService.java:201)
at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataOutput.writeObject(ByteArrayObjectDataOutput.java:371)
at com.hazelcast.spi.impl.operationservice.impl.operations.Backup.writeInternal(Backup.java:222)
at com.hazelcast.spi.Operation.writeData(Operation.java:472)
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.write(DataSerializableSerializer.java:161)
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.write(DataSerializableSerializer.java:52)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.write(StreamSerializerAdapter.java:41)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:140)
... 10 common frames omitted
Caused by: com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to serialize 'com.hazelcast.map.AbstractEntryProcessor$EntryBackupProcessorImpl'
at com.hazelcast.internal.serialization.impl.SerializationUtil.handleSerializeException(SerializationUtil.java:73)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.writeObject(AbstractSerializationService.java:201)
at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataOutput.writeObject(ByteArrayObjectDataOutput.java:371)
at com.hazelcast.map.impl.operation.PartitionWideEntryBackupOperation.writeInternal(PartitionWideEntryBackupOperation.java:98)
at com.hazelcast.map.impl.operation.PartitionWideEntryWithPredicateBackupOperation.writeInternal(PartitionWideEntryWithPredicateBackupOperation.java:51)
at com.hazelcast.spi.Operation.writeData(Operation.java:472)
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.write(DataSerializableSerializer.java:161)
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.write(DataSerializableSerializer.java:52)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.write(StreamSerializerAdapter.java:41)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.writeObject(AbstractSerializationService.java:199)
... 17 common frames omitted
Caused by: java.util.ConcurrentModificationException: null
at java.util.ArrayList.writeObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at java.util.ArrayList.writeObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.write(JavaDefaultSerializers.java:242)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.write(StreamSerializerAdapter.java:41)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.writeObject(AbstractSerializationService.java:199)
... 25 common frames omitted
My entry processor is look like this:
public class HRUpdateRacesWithEntriesProcessor extends AbstractEntryProcessor<HRMeeting.HRMeetingKey, HRMeeting> {
private List<HRRace> races;
private Date date;
public HRUpdateRacesWithEntriesProcessor(List<HRRace> races, Date date) {
this.races = races;
this.date = date;
}
#Override
public Object process(Map.Entry<HRMeeting.HRMeetingKey, HRMeeting> entry) {
HRMeeting meeting = entry.getValue();
races.stream()
.filter(race -> entry.getKey().equals(new HRMeeting.HRMeetingKey(race.getMeetingDate(), race.getCourseId())))
.forEach(newRace -> {
Optional<HRRace> matchedRace =
meeting.getRaces().stream().filter(origin -> origin.getKey().equals(newRace.getKey())).findFirst();
if (newRace.getEntries() != null && matchedRace.isPresent()) {
newRace.setUpdateDate(date);
newRace.getEntries().stream()
.filter(hrEntry -> matchedRace.get().getEntries().stream().map(el -> el.getKey())
.collect(Collectors.toList()).contains(hrEntry.getKey()))
.forEach(hrEntry -> hrEntry.setUpdateDate(date));
matchedRace.get().getEntries().retainAll(newRace.getEntries());
newRace.getEntries().addAll(matchedRace.get().getEntries());
}
meeting.getRaces()
.removeIf(hrRace -> matchedRace.isPresent() && matchedRace.get().getKey().equals(hrRace.getKey()));
meeting.getRaces().add(newRace);
});
entry.setValue(meeting);
return null;
}
}
For serialization my entites implements java Serializible. Is is can be reason of the issue?
I am using hazelcast-3.8-SNAPSHOT
Please, help me to solve it.
It might be a simple problem. I met the same error when tried to put an Object to IMap in Hazelcast. In my case, the object, which I try to put, wasn't implements Serializable.
So, I think you should check you did implements Serializable in "com.hazelcast.spi.impl.operationservice.impl.operations.Backup" like
public class Backup implements Serializable {
...
}
I think your problem is that somehow (it actually hard to follow the stream flow) capture content from your EntryProcessor implementation and because of that it is tried to be serialized using Serializable. Anyhow DataSerializable / IdentifiedDataSerializable is not java.util.Serializable to prevent unexpected serialization (like in your case) from happening :)
My guess is the date:
.forEach(hrEntry -> hrEntry.setUpdateDate(date));
I hope this helps, you might have to look for the actually captured value.
I've been trying to understand what the issue is exactly, but whatever I do doesn't seem to work.
I have a text file that lists names along with numbers, seperated by a colon.
An example of this is:
Betty Ross:52
Angie Scotts:29
Michael Rosen:72
The list is very long and comprises over 10,000 lines.
public class PeopleIds {
public static int UNDEFINED_ID = -1;
private static HashMap<String, Integer> people;
public static void initialize() {
people = new HashMap<String, Integer>();
System.out.println(new File("res/ids/people_ids.txt").exists());
try {
Files.lines(Paths.get("res/ids/people_ids.txt")).forEach(s -> {
people.put(s.replaceAll(":.*", "").trim(), Integer.parseInt(s.replaceAll(".*:", "")));
});
} catch (IOException e) {
System.out.println("Unable to read specified file.");
e.printStackTrace();
}
}
public static int getId(final String name) {
final Integer id = people.get(name);
return id != null ? id : UNDEFINED_ID;
}
}
I call the initialize method from a GUIController class:
public class GUIController implements Initializable {
#FXML
private TableView<PersonData> personTable;
#FXML
private TableColumn<PersonData, String> name;
#FXML
private TableColumn<PersonData, Integer> limit;
#FXML
private TextField searchInput;
#FXML
private ImageView personIcon;
private Image undefinedIcon;
private PersonIcon icon;
private ObservableList<PersonData> data;
#Override
public void initialize(URL location, ResourceBundle resources) {
PeopleIds.initialize();
undefinedIcon = new Image(getClass().getResourceAsStream("/ids/no.png"));
name.setCellValueFactory(new PropertyValueFactory<PersonData, String>("name"));
limit.setCellValueFactory(new PropertyValueFactory<PersonData, Integer>("limit"));
data = PriceData.getData();
personTable.setPeople(data);
searchInput.textProperty().addListener((ov, oldValue, newValue) -> {
final String input = searchInput.getText();
if (input.length() == 0) return;
searchInput.setText(input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase());
filterSearch();
});
}
}
When I call it from this class with PeopleIds.initialize(), an exception is thrown, telling me that there was an exception in the application start method.
Here is what was logged in its entirety:
Exception in Application start method
java.lang.reflect.InvocationTargetException
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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(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 sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/C:/Confidential/bin/base/PersonGUI.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at base.PersonGUI.start(PersonGUI.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
... 1 more
Caused by: java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1
at java.io.BufferedReader$1.hasNext(Unknown Source)
at java.util.Iterator.forEachRemaining(Unknown Source)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at base.PeopleIds.initialize(PeopleIds.java:17)
at base.GUIController.initialize(GUIController.java:36)
... 18 more
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
... 24 more
Exception running application base.PersonGUI
I'm not sure what is going on here? I've looked into it and people have said to move the fxml file (the one that is used to format the content and is linked with the GUIController to the same package as the Main class, however it already is.
I've been wrestling with this issue for days to no avail. Do any of you have past experiences with this issue? If so, how did you resolve it? Thanks a lot.
If there is an Exception while the file is being read, not when opening the file, an unchecked exception is thrown for the Files.lines stream operation (Stream.forEach doesn't have a throws clause).
This happens here
Files.lines(Paths.get("res/ids/people_ids.txt")).forEach(s -> {
people.put(s.replaceAll(":.*", "").trim(), Integer.parseInt(s.replaceAll(".*:", "")));
});
, which you can easily see in the stacktrace:
Caused by: java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1
(This is caused by the wrong Charset being used, see Files.readAllBytes vs Files.lines getting MalformedInputException )
You don't catch this kind of exception with your catch clause:
} catch (IOException e) {
You need to use
} catch (Exception e) {
to catch the unchecked exceptions too.
In Java, sometimes I get an exception parsing user input. Instead of printing a stack trace, I want it to "cleanly" redirect the output to a string. Example (uses LuaJ):
Exception:
Exception in thread "Thread-3" org.luaj.vm2.LuaError: [string "jhkfchyufjhdnxvk,gh'bnmcvk,fvjmfk,xdcfsdkckucfdxfds,ie(); "]:1: unfinished string
at org.luaj.vm2.compiler.LexState.lexerror(Unknown Source)
at org.luaj.vm2.compiler.LexState.read_string(Unknown Source)
at org.luaj.vm2.compiler.LexState.llex(Unknown Source)
at org.luaj.vm2.compiler.LexState.next(Unknown Source)
at org.luaj.vm2.compiler.LexState.str_checkname(Unknown Source)
at org.luaj.vm2.compiler.LexState.singlevar(Unknown Source)
at org.luaj.vm2.compiler.LexState.primaryexp(Unknown Source)
at org.luaj.vm2.compiler.LexState.suffixedexp(Unknown Source)
at org.luaj.vm2.compiler.LexState.assignment(Unknown Source)
at org.luaj.vm2.compiler.LexState.exprstat(Unknown Source)
at org.luaj.vm2.compiler.LexState.statement(Unknown Source)
at org.luaj.vm2.compiler.LexState.statlist(Unknown Source)
at org.luaj.vm2.compiler.LexState.mainfunc(Unknown Source)
at org.luaj.vm2.compiler.LuaC.luaY_parser(Unknown Source)
at org.luaj.vm2.compiler.LuaC.compile(Unknown Source)
at org.luaj.vm2.Globals.compilePrototype(Unknown Source)
at org.luaj.vm2.Globals.loadPrototype(Unknown Source)
at org.luaj.vm2.Globals.load(Unknown Source)
at org.luaj.vm2.Globals.load(Unknown Source)
at org.luaj.vm2.Globals.load(Unknown Source)
at net.snugglesstuff.LeoBot.LuaThread.run(LuaThread.java:25)
What the output should be:
[string "jhkfchyufjhdnxvk,gh'bnmcvk,fvjmfk,xdcfsdkckucfdxfds,ie(); "]:1: unfinished string
You can catch the exception and print exception.getMessage().
try {
... parsing code ...
}
catch (Exception exc) { // change this to catch the specific type of exceptions relevant to the parsing
System.out.println(exc.getMessage()); // or redirect the message to a file
}
I would like to create an in-memory database for testing purposes using Derby/JavaDB. I have read Java DB Developer's Guide: Using in-memory databases and tested with this code with derby.jar from JDK7 in the "build path":
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class DBTest {
public static void main(String[] args) {
final String sql = "DECLARE GLOBAL TEMPORARY TABLE memtable "+
"(id int, name varchar(10))";
final String connURL = "jdbc:derby:memory:memdatabase;create=true";
try(Connection conn = DriverManager.getConnection(connURL);
PreparedStatement ps = conn.prepareStatement(sql);) {
boolean success = ps.execute();
System.out.println("Memory database created: " + success);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
But when running the application, I get this error:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "<EOF>" at line 1, column 66.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at DBTest.main(DBTest.java:12)
Caused by: java.sql.SQLException: Syntax error: Encountered "<EOF>" at line 1, column 66.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 14 more
Caused by: ERROR 42X01: Syntax error: Encountered "<EOF>" at line 1, column 66.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
... 8 more
How can I create an in-memory database table with Derby/JavaDB?
I think you're missing NOT LOGGED at the end:
declare global temporary table SESSION.t1(c11 int) not logged;