Rhino reports missing : after property id - java

I'm using Rhino 1.7 R4 with envjs 1.2 on Mac OSX with JDK 1.6.0_33
If I run:
java -jar rhino-1.7R4.jar -opt -1
And then:
load('env.rhino-1.2.js')
Then the script is loaded successfully.
When I load the same JS script from Java via RhinoTest.java:
import org.apache.commons.io.IOUtils;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.tools.shell.Main;
import org.mozilla.javascript.tools.shell.ShellContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class RhinoTest {
static final Logger LOGGER = LoggerFactory.getLogger(RhinoTest.class);
static private Scriptable SCRIPTABLE;
static private List<Script> scripts;
public static void main(String[] args) {
ShellContextFactory cxFactory = Main.shellContextFactory;
cxFactory.call(new ContextAction() {
#Override
public Object run(Context cx) {
final Initiator initiator = new Initiator(cx).init();
LOGGER.trace("Run script");
try {
return initiator.execute();
} finally {
}
}
class Initiator {
Initiator(Context context) {
this.cx = context;
}
Initiator init() {
if (SCRIPTABLE == null)
createScriptable();
initContext();
return this;
}
Object execute() {
return null;
}
void createScriptable() {
LOGGER.trace("init standard objects");
SCRIPTABLE = cx.initStandardObjects();
LOGGER.trace("set optimization level to -1");
cx.setOptimizationLevel(-1);// bypass the 64k limit // interpretive mode
attachJs("env.rhino-1.2.js");
LOGGER.trace("set optimization level to 9");
cx.setOptimizationLevel(9);
}
#SuppressWarnings("deprecation")
private void attachJs(String jsFileName) {
InputStream in = null;
InputStreamReader reader = null;
if (LOGGER.isDebugEnabled()) LOGGER.debug("loading " + jsFileName);
try {
in = RhinoTest.class.getResourceAsStream(jsFileName);
if (in == null)
throw new RuntimeException("cannot find js file : " + jsFileName);
reader = new InputStreamReader(in);
if (scripts == null)
scripts = new ArrayList<Script>();
scripts.add(cx.compileReader(SCRIPTABLE, reader, jsFileName, 1, null));
if (LOGGER.isDebugEnabled()) LOGGER.debug("loaded " + jsFileName);
} catch (IOException e) {
throw new RuntimeException("cannot load js file : " + jsFileName, e);
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(reader);
}
}
void initContext() {
LOGGER.trace("set optimization level to -1");
cx.setOptimizationLevel(-1);// bypass the 64k limit // interpretive mode
for (Script s : scripts) {
s.exec(cx, SCRIPTABLE);
}
}
private final Context cx;
}
});
}
}
I get:
Exception in thread "main" org.mozilla.javascript.EvaluatorException: missing : after property id (env.rhino-1.2.js#2121)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(Unknown Source)
at org.mozilla.javascript.DefaultErrorReporter.error(Unknown Source)
at org.mozilla.javascript.Parser.addError(Unknown Source)
at org.mozilla.javascript.Parser.reportError(Unknown Source)
at org.mozilla.javascript.Parser.mustMatchToken(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.argumentList(Unknown Source)
at org.mozilla.javascript.Parser.memberExprTail(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.statementHelper(Unknown Source)
at org.mozilla.javascript.Parser.statement(Unknown Source)
at org.mozilla.javascript.Parser.parseFunctionBody(Unknown Source)
at org.mozilla.javascript.Parser.function(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.statementHelper(Unknown Source)
at org.mozilla.javascript.Parser.statement(Unknown Source)
at org.mozilla.javascript.Parser.parse(Unknown Source)
at org.mozilla.javascript.Parser.parse(Unknown Source)
at org.mozilla.javascript.Context.compileImpl(Unknown Source)
at org.mozilla.javascript.Context.compileReader(Unknown Source)
at org.mozilla.javascript.Context.compileReader(Unknown Source)
at RhinoTest$1$Initiator.attachJs(RhinoTest.java:85)
at RhinoTest$1$Initiator.createScriptable(RhinoTest.java:63)
at RhinoTest$1$Initiator.init(RhinoTest.java:44)
at RhinoTest$1.run(RhinoTest.java:28)
at org.mozilla.javascript.Context.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.call(Unknown Source)
at RhinoTest.main(RhinoTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Please help

Wladimir,
You were right it was a version thing.
It turns out that the batik libs I imported included another version of rhino.
By excluding batik-js from my project for each batik dependency this issue went away.

Related

I am trying to get urls from Bing search API, but getting this kind of error

I am creating an article summarization project however I am a beginner in java and cannot fix the error. What I am trying to do is get the URL's from Bing search API for custom query which I can later summarize.
package Summarizer;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import org.core4j.Enumerable;
import org.odata4j.consumer.ODataConsumer;
import org.odata4j.consumer.ODataConsumers;
import org.odata4j.consumer.behaviors.OClientBehaviors;
import org.odata4j.core.OEntity;
import org.odata4j.core.OQueryRequest;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* #author Safer
*/
public class Crawler {
ArrayList<String> links = new ArrayList<String>();
String qry;
int count = 10;
public Crawler(String qry) {
this.qry = qry;
getURL();
printToFile();
}
public Crawler(String qry, int count) {
this.qry = qry;
this.count = count;
getURL();
printToFile();
}
public static void main(String[] args) {
Crawler crawller = new Crawler("paris attack");
crawller.getURL();
crawller.printToFile();
}
public void getURL() {
qry = "\'" + qry + "\'";
//System.setProperty("https.proxyHost", "172.31.1.4");
//System.setProperty("https.proxyPort", "8080");
ODataConsumer c = ODataConsumers.newBuilder("https://api.datamarket.azure.com/Bing/Search").setClientBehaviors(OClientBehaviors.basicAuth("accountKey", "I/JMZMShDneSQBg6o+21hcz5eEjR4ROyxnFwG1K4iRM")).build();
OQueryRequest<OEntity> oRequest = c.getEntities("Web").custom("Query", qry);
Enumerable<OEntity> entities = oRequest.execute();
Iterator i = entities.iterator();
while (i.hasNext() && count > 0) {
String[] fields = i.next().toString().split("OProperty");
String link = fields[fields.length - 1].split(",")[2];
links.add(link.substring(0, link.length() - 2));
System.out.println(link.substring(0, link.length() - 2));
count --;
}
}
public void printToFile() {
System.out.println(links.size());
try {
PrintWriter out = new PrintWriter("URL\\urlfile.txt");
for (int i = 0 ; i < links.size() ; i ++) {
out.println(links.get(i));
}
out.close();
}catch(Exception ex){}
}
}
i expect the output to generate the summary of the links from bing search api but couldn't fetch the url
and i am getting this kinda error
Exception in thread "AWT-EventQueue-0" com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection timed out: connect
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:128)
at com.sun.jersey.api.client.Client.handle(Client.java:457)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
at com.sun.jersey.api.client.WebResource$Builder.method(WebResource.java:539)
at org.odata4j.jersey.consumer.ODataJerseyClient.doRequest(ODataJerseyClient.java:143)
at org.odata4j.consumer.AbstractODataClient.getMetadata(AbstractODataClient.java:43)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.refreshDelegate(AbstractODataConsumer.java:212)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.getDelegate(AbstractODataConsumer.java:205)
at org.odata4j.internal.EdmDataServicesDecorator.findEdmEntitySet(EdmDataServicesDecorator.java:46)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.findEdmEntitySet(AbstractODataConsumer.java:221)
at org.odata4j.consumer.AbstractODataConsumer.getFeedCustomizationMapping(AbstractODataConsumer.java:235)
at org.odata4j.consumer.AbstractODataConsumer.getEntities(AbstractODataConsumer.java:73)
at org.odata4j.consumer.AbstractODataConsumer.getEntities(AbstractODataConsumer.java:69)
at Summarizer.Crawler.getURL(Crawler.java:51)
at Summarizer.Crawler.<init>(Crawler.java:37)
at Summarizer.Summary.<init>(Summary.java:30)
at GUI.Base.jButton3ActionPerformed(Base.java:344)
at GUI.Base.access$3(Base.java:331)
at GUI.Base$4.actionPerformed(Base.java:135)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue.access$600(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.base/java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.base/java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.base/java.net.PlainSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at java.base/sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at java.base/sun.net.NetworkClient.doConnect(Unknown Source)
at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at java.base/sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.base/java.net.HttpURLConnection.getResponseCode(Unknown Source)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:215)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
... 55 more

Sql error or missing database when adding sqlite database to jar

I am trying to package a jar file containing a sqlite database for my application to run on another computer. After packaging the the application i tried running it in another computer and it throws this error :
I want to either create an exe file or a jar file so that i can give other users the file to run on there computers.
I created my database externally using sql DBbrowser and i added it to the resources folder within my application.
SQL error or missing database (no such table: users)
These are the tables in my database:
This is my code :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
public class DBConnection {
private static Connection conn;
private static String url = "jdbc:sqlite:mydb.db";
private static String user = "root";//Username of database
private static String pass = "yes";//Password of database
public static Connection connect() throws SQLException {
try {
Class.forName("org.sqlite.JDBC").newInstance();
} catch (ClassNotFoundException cnfe) {
System.err.println("Error: " + cnfe.getMessage());
} catch (InstantiationException ie) {
System.err.println("Error: " + ie.getMessage());
} catch (IllegalAccessException iae) {
System.err.println("Error: " + iae.getMessage());
}
conn = DriverManager.getConnection(url);
System.out.println("CONNECTED!!");
return conn;
}
public static Connection getConnection() throws SQLException, ClassNotFoundException {
if (conn != null && !conn.isClosed())
return conn;
connect();
return conn;
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
This is where i access the table called users:
import java.sql.ResultSet;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import static pkg3treka.DBConnection.getConnection;
public class FXMLDocumentController implements Initializable {
#FXML
private Button button;
#FXML
private Label label;
#FXML
private TextField textField;
#FXML
private TextField textPassword;
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
public FXMLDocumentController() throws SQLException {
try {
connection = DBConnection.getConnection();
} catch (ClassNotFoundException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
}
#FXML
void handleButtonAction(ActionEvent event) {
boolean isAdmin = false;
String username = textField.getText();
String password = textPassword.getText();
if( username.length()>=6 && "admin/".equals(username.substring(0,6))){
isAdmin = true;
username = textField.getText().substring(6);
System.out.println("---->"+username);
}
String sql = "SELECT * FROM users WHERE U_username = ? and U_password = ?";
try{
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, username);
preparedStatement.setString(2, password);
resultSet = (ResultSet) preparedStatement.executeQuery();
if(!resultSet.next()){
DBConnection.infoBox("Enter Correct Email and Password", "Failed", null);
}else{
try {
Stage stage = (Stage) button.getScene().getWindow();
stage.close();
FXMLLoader fxmlLoader = new FXMLLoader();
if(isAdmin){
fxmlLoader.setLocation(getClass().getResource("ChooseRouteToOpen.fxml"));
}else{
fxmlLoader.setLocation(getClass().getResource("UserTimeSheetsView.fxml"));
}
Scene scene = new Scene(fxmlLoader.load());//next page size
stage.setScene(scene);
stage.show();
} catch (IOException e) {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.SEVERE, "Failed to create new Window.", e);
}
}
}catch(Exception e){
e.printStackTrace();
}
}
#Override
public void initialize(URL url, ResourceBundle rb) {
try {
// TODO
if(DBConnection.getConnection() == null){
label.setText("Status: DATABASE NOT CONNECTED!");
}
else {
label.setText("Status: DATABASE CONNECTED!");
}
} catch (SQLException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
;
}
}
This is the error log :
Jan 14, 2018 12:31:04 PM javafx.fxml.FXMLLoader$ValueElement
processValue
WARNING: Loading FXML document with JavaFX API of version 8.0.111 by JavaFX runtime of version 8.0.66
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: users)
at org.sqlite.core.DB.newSQLException(DB.java:909)
at org.sqlite.core.DB.newSQLException(DB.java:921)
at org.sqlite.core.DB.throwex(DB.java:886)
at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
at org.sqlite.core.NativeDB.prepare(NativeDB.java:127)
at org.sqlite.core.DB.prepare(DB.java:227)
at org.sqlite.core.CorePreparedStatement.<init>(CorePreparedStatement.java:41)
at org.sqlite.jdbc3.JDBC3PreparedStatement.<init>(JDBC3PreparedStatement.java:30)
at org.sqlite.jdbc4.JDBC4PreparedStatement.<init>(JDBC4PreparedStatement.java:19)
at org.sqlite.jdbc4.JDBC4Connection.prepareStatement(JDBC4Connection.java:48)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:263)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:235)
at pkg3treka.FXMLDocumentController.handleButtonAction(FXMLDocumentController.java:117)
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.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Button.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
at java.lang.Thread.run(Unknown Source)
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: users)
at org.sqlite.core.DB.newSQLException(DB.java:909)
at org.sqlite.core.DB.newSQLException(DB.java:921)
at org.sqlite.core.DB.throwex(DB.java:886)
at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
at org.sqlite.core.NativeDB.prepare(NativeDB.java:127)
at org.sqlite.core.DB.prepare(DB.java:227)
at org.sqlite.core.CorePreparedStatement.<init>(CorePreparedStatement.java:41)
at org.sqlite.jdbc3.JDBC3PreparedStatement.<init>(JDBC3PreparedStatement.java:30)
at org.sqlite.jdbc4.JDBC4PreparedStatement.<init>(JDBC4PreparedStatement.java:19)
at org.sqlite.jdbc4.JDBC4Connection.prepareStatement(JDBC4Connection.java:48)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:263)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:235)
at pkg3treka.FXMLDocumentController.handleButtonAction(FXMLDocumentController.java:117)
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.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Button.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
at java.lang.Thread.run(Unknown Source)
In your FXMLDocumentController.java file at line 117, you are running a query againt a SQL table named "users". This table is missing in your database.

basic: eccezione: java.lang.ExceptionInInitializerError java.lang.RuntimeException: java.lang.ExceptionInInitializerError

I am trying to write an applet that run in html page .
If I run the applet in eclipse with debug as JApplet it runs fine, but if i put it in an html it has an error.
Java console say :
basic: eccezione: java.lang.ExceptionInInitializerError
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at org.restlet.resource.ClientResource.(ClientResource.java:405)
at com.gabrielepiscitelli.JAppletGui.RestClient.Client.listAllThreads(Client.java:39)
at com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.(GUIApplet.java:191)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.util.logging.config.file" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at org.restlet.engine.Engine.configureLog(Engine.java:194)
at org.restlet.engine.Engine.register(Engine.java:380)
at org.restlet.engine.Engine.register(Engine.java:368)
at org.restlet.engine.Engine.getInstance(Engine.java:252)
at org.restlet.data.Method.(Method.java:334)
at org.restlet.data.Method.(Method.java:393)
at org.restlet.data.Method.(Method.java:358)
at org.restlet.data.Method.(Method.java:57)
... 28 more
the code at Client.java:39 is the line cr = new ClientResource(lURI); in this part of java file:
/**
*
*/
package com.gabrielepiscitelli.JAppletGui.RestClient;
import java.io.IOException;
import org.restlet.data.Status;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiPost;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiThread;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiUser;
import com.gabrielepiscitelli.SystemForum.Utils.ExceptionForum;
import com.google.gson.Gson;
/**
* #author Gabriele
*
*/
public class Client {
/**
*
* #return
* #throws ExceptionForum
*/
public static DataGuiThread[] listAllThreads() throws ExceptionForum{
DataGuiThread[] lRestDataGuiThreads = null;
ClientResource cr = null;
Gson gson = new Gson();
Status status = null;
String json = null;
String lURI = "http://localhost:8182/ListThreadsAll";
cr = new ClientResource(lURI);
try {
json = cr.get().getText();
status = cr.getStatus();
if (status.getCode() != 200) {
// System.out.println(status);
// System.exit(status.getCode());
Status lStatusJson = gson.fromJson(json, Status.class);
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
lStatusJson.getDescription() + lStatusJson.getReasonPhrase());
} else {
lRestDataGuiThreads = gson.fromJson(json, DataGuiThread[].class);
}
} catch (ResourceException e) {
// e.printStackTrace();
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
e.getMessage());
} catch (IOException e) {
// e.printStackTrace();
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
e.getMessage());
}
return lRestDataGuiThreads;
}
Html file is simply :
<html><body>
<p>
<applet code="com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.class" archive="GUIApplet.jar,miglayout15-swing.jar,org.restlet.jar,gson-2.2.4.jar"
width="800" height="640"></applet>
</p>
Is there someone that can explain me the problem? thanks in advances!
Caused by: java.security.AccessControlException: access denied
("java.util.PropertyPermission" "java.util.logging.config.file" "read")
This applet needs to be trusted. Digitally sign the applet code.

Speech Recognition jar throwing error on its execution Grammar class not found

I have created a jar of my project on Speech Recognition in JAVA through Sphinx. My code is executing perfectly but when I am creating its jar through "runnable jar file->copy required libraries into sub folder", and executing it through cmd with command " java -jar {jar name}.jar" it opens but after selecting the speak button or invoking sphinx method it gives error edu.cmu.sphinx.jsapi.JSGFGrammar class not found.
I am not getting any way how to resolve this.
my speech to text code is:
package com.ongraph;
import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;
public class SpeechToTextOperation {
ConfigurationManager cm;
SpeechRecognizer speechRecognizer;
Result result;
Recognizer recognizer;
Microphone microphone;
private final static String STOP = "stop";
private final static String XML_FILE = "helloworld.config.xml";
public void voiceGet() throws InterruptedException {
String resultString = null;
int count_Check = 0;
if (cm == null) {
cm = new ConfigurationManager(getClass().getClassLoader().getResource(XML_FILE));
}
if (recognizer == null) {
recognizer = (Recognizer) cm.lookup("recognizer");
microphone = (Microphone) cm.lookup("microphone");
microphone.clear();
}
recognizer.allocate();
if (!(microphone.startRecording())) {
System.out.println("Cannot start microphone.");
recognizer.deallocate();
System.exit(1);
}
instructions();
//SpeechRecognizer.please_Speak.setVisible(true);
while (true) {
System.out
.println("Start speaking. Speak 'Stop' to Stop Recording.");
if(count_Check == 0)
{
SpeechRecognizer.textArea.append("\n Start speaking...\n");
count_Check++;
}
Result result = recognizer.recognize();
resultString = result.getBestFinalResultNoFiller();
if (resultString != null && !"".equals(resultString)
&& !resultString.contains(STOP)) {
SpeechRecognizer.textArea.append(resultString + "\n");
} else {
SpeechRecognizer.textArea
.append("'Application Stopped. Press 'Speak' again to restart'");
recognizer.deallocate();
microphone.stopRecording();
break;
}
}
}
public void voiceStop() {
microphone.clear();
cm = null;
}
public void instructions() {
// TODO Auto-generated method stub
SpeechRecognizer.please_Speak.setVisible(true);
}
}
errors in cmd are:
class not found !java.lang.ClassNotFoundException: edu.cmu.sphinx.jsapi.JSGFGrammar
Exception in thread "AWT-EventQueue-0" Property Exception component:'flatLinguist' property:'grammar' - mandatory property is not set!
edu.cmu.sphinx.util.props.InternalConfigurationException
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:291)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:246)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:460)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:279)
at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:179)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:460)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:279)
at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:65)
at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:460)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:279)
at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:90)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:460)
at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:161)
at com.ongraph.SpeechToTextOperation.voiceGet(SpeechToTextOperation.java:24)
at com.ongraph.SpeechRecognizer$1.actionPerformed(SpeechRecognizer.java:50)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Overall it's better to use latest version 5prealpha and the API described at http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
As for your exception, it says that class is not found. You need to pack that class into jar in order to run your code. There could be also a difference in package name. Recently edu.cmu.sphinx.jsapi package was renamed to edu.cmu.sphinx.jsgf. You might have issues to update that.

ServerException is being thrown while binding RMI service

I'm trying to build simple echo server as RMI application (step by step as it's described in Sun tutorial).
All source code is shown below, it's very simple:
package test;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface EchoServer extends Remote {
public String sendString (String str) throws RemoteException;
}
package test;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public class EchoServerImpl extends UnicastRemoteObject implements EchoServer {
public EchoServerImpl () throws RemoteException {
super ();
}
public String sendString (String str) throws RemoteException {
return str.toUpperCase();
}
}
package test;
import java.rmi.Naming;
public class RMIServer {
public RMIServer () {
try {
EchoServer eServer = new EchoServerImpl ();
Naming.rebind ("rmi://localhost:1099/EchoService", eServer); // <--exception
} catch (Exception e) {
e.printStackTrace ();
}
}
public static void main(String[] args) {
new RMIServer ();
}
}
I compile code with rmic and I see file EchoServerImpl_Stub.class. After that I run 'rmiregistry' and then I start RMIServer. And at that moment I see ServerException:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at test.RMIServer.(RMIServer.java:10)
at test.RMIServer.main(RMIServer.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
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 java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(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)
... 12 more
I think it's a common problem and it's probably connected with wrong deploying. How to fix it?
I think it's your rmiregistry classpath. The test.EchoServer interface needs to be accessible to the rmiregistry itself. Set your CLASSPATH environment variable before you run up the rmiregistry e.g.
C:\>set CLASSPATH="MyBinFolder"
C:\>rmiregistry
Also, rmic is a hangover from before Java 5. It isn't necessary to run it anymore. Just run your server and client as normal and the proxies will be created dynamically.
Regards,
MK

Categories

Resources