I am working to parse STEP files ISO-10303-21; using Part21Parser in java
Following is file structure
HEADER;
FILE_DESCRIPTION(('STEP AP214'),'1');
FILE_NAME('s25552_b159_a1_13.stp','2016-10-04T07:52:56',(' '),(' '),'Spatial InterOp 3D',' ',' ');
FILE_SCHEMA(('automotive_design'));
ENDSEC;
static Model read_file (String filename) throws STDevException, IOException {
Part21Parser parser = new Part21Parser();
return parser.parse(filename);
}
public static void main(String[] args) {
try {
Part21Parser parser = new Part21Parser();
try {
Model m1 = read_file("D:/Braunschweig_board.stp");
} catch (IOException e) {
e.printStackTrace();
}
} catch (STDevException e1) {
e1.printStackTrace();
}
But when I run, it gives exception that
Cannot find schema automotive_design
I am not sure what kind of schema is it expecting and what should be the valid schema as there is no help regarding this exception online. Any one who worked on STEP/EXPRESS files could please help
Following is stacktrace
com.steptools.stdev.SchemaNotFoundException: Cannot find schema automotive_design
at com.steptools.stdev.SchemaBase.forName(SchemaBase.java:61)
at com.steptools.stdev.p21.Part21Parser.getSchema(Part21Parser.java:693)
at com.steptools.stdev.p21.Part21Parser.getSchema(Part21Parser.java:673)
at com.steptools.stdev.p21.Part21Parser.getPopulation(Part21Parser.java:547)
at com.steptools.stdev.p21.Part21Parser.parse_DATA_SECTION(Part21Parser.java:561)
at com.steptools.stdev.p21.Part21Parser.parse_EXCHANGE_FILE(Part21Parser.java:302)
at com.steptools.stdev.p21.Part21Parser.parse(Part21Parser.java:230)
at com.steptools.stdev.p21.Part21Parser.parse(Part21Parser.java:112)
at com.steptools.stdev.p21.Part21Parser.parse(Part21Parser.java:92)
at com.steptools.stdev.p21.Part21Parser.parse(Part21Parser.java:80)
at CadParser.read_file(CadParser.java:26)
at CadParser.main(CadParser.java:35)
Caused by: java.lang.ClassNotFoundException: com.steptools.schemas.automotive_design.Schema
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)`enter code here`
at java.lang.Class.forName(Unknown Source)
at com.steptools.stdev.SchemaBase.forName(SchemaBase.java:59)
... 11 more
Related
I'm using a Spring Boot APP and I'm trying to set a System property programatically. I don't want to set the URL hardcoded, it must be loaded from the classpath
The problem is that my code runs well on IDE but when I try to execute the jar file I get:
Exception in thread "main" 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 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Unknown Source)
My Code:
public static void main(String[] args) {
try {
setSystemProperties();
} catch (IOException e) {
log.error("ERROR: Could not find my.properties file in classpath", e);
}
}
private static void setSystemProperties() throws IOException {
ClassPathResource resource = new ClassPathResource("my.properties");
System.setProperty("my.file", Paths.get(resource.getURI()).toString());
}
InvocationTargetException occurs when there's some underlying exception while calling method. Add the below catch block in your code to see the actual cause.
catch (InvocationTargetException e) {
// the real cause
e.getCause().printStackTrace();
}
I'm trying to connect to an external database and no matter what I do I keep getting the following error:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DbCon.main(DbCon.java:10)
My code to set up the driver:
import java.sql.*;
public class DbCon {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
}
}
I've tried omitting the driver entirely, and just trying to connect with:
String connectionUrl = "jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=xxxx;user=xxxx;password=xxxx;";
try {
Connection con = DriverManager.getConnection(connectionUrl);
} catch (SQLException e) {
e.printStackTrace();
}
This only gets me the following error:
java.sql.SQLException: No suitable driver found for xxxx
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DbCon.main(DbCon.java:15)
I've tried adding the jar to Eclipse's classpath, I've added the folder to the project's build path as an external class folder.
Is there something I'm missing?
Does anyone have a example about how to make a java mongoDB connector to use with JasperReports? I have been trying make it work but without any sucess... All example on internet looks like old versions of JasperReports...
I tried this code
GeneratePDF with JasperReports Library and MongoDB
String mongoURI = "mongodb://bdsandbox6:27017/test";
MongoDbConnection connection = null;
Map<String, Object> parameters = new HashMap<String, Object>();
try {
connection = new MongoDbConnection(mongoURI, null, null);
parameters.put(MongoDbDataSource.CONNECTION, connection);
File jasperFile;
jasperFile = new File("MongoDbReport.jasper");
JasperCompileManager.compileReportToFile("MongoDbReport.jrxml", "MongoDbReport.jasper");
JasperFillManager.fillReportToFile("MongoDbReport.jasper", parameters);
JasperExportManager.exportReportToPdfFile("MongoDbReport.jrprint");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.close();
}
}
But I ways got this error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/log4j/Logger at
com.jaspersoft.mongodb.connection.MongoDbConnection.(MongoDbConnection.java:64)
at serverTeste.Rest.main(Rest.java:22) Caused by:
java.lang.ClassNotFoundException: org.apache.log4j.Logger at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) ... 2 more
I know it seens I need log4j.jar but i tried it and I faill again. I guess I am using the wrong jars files...
I also tried it:
GeneratePDF with JasperReport Library and MongoDB
Without Sucess
I'm wanting to read an iCalendar (ics file) for a project and thinking it might be easier to just use an API. After much research I found iCal4j.
I'm new to ical4j, and have been searching for an answer, and trying to do research and found that the creator of it allows any form of logging they want, so I'm really baffled. I'm trying to get just a simple example I found working. I'm horrible with different APIs, and it kills me. I just have the iCal4j-2.0-beta1.jar in my classpath, and I have the following code:
import java.io.*;
import net.fortuna.ical4j.data.*;
import net.fortuna.ical4j.model.*;
public class iCalendarSupport
{
public static void main(String[] args)
{
try
{
FileInputStream fin = new FileInputStream("C:\\Users\\Mike\\Downloads\\basic (1).ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(fin);
System.out.println(calendar.getComponent("Event").toString());
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Here's the output I have in the console in eclipse.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at net.fortuna.ical4j.util.Configurator.<clinit>(Configurator.java:51)
at net.fortuna.ical4j.data.CalendarParserFactory.<clinit>(CalendarParserFactory.java:63)
at net.fortuna.ical4j.data.CalendarBuilder.<init>(CalendarBuilder.java:104)
at iCalendarSupport.main(iCalendarSupport.java:12)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
Any help would be much appreciated.
Classpath is missing the SLF4J (Simple Logging Facade) library. You can find it here:
http://www.slf4j.org/download.html
At the beginning I had an error java.lang.ClassNotFoundException. I solved this problem by adding jars to \war\WEB-INF\lib folder. But then I got java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.Orient error while applying to database. This is the server code:
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String greetServer(String input) throws IllegalArgumentException {
RegBugs rb = new RegBugs();
String a = rb.getDbAdres();
try {
//The error is here
ArrayList<String> table = rb.getAllGitRecords();
} catch (ParseException e) {
e.printStackTrace();
}
return a;
}
Compilation is finished successfully. And when I start to call to server I get An error occurred while attempting to contact the server. Please check your network connection and try again. from gwt. How could I solve this problem?
P.S. I use eclipse and gwt-plugin for it
The error occurs when I try to interrupt with orient database.
Trace:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.Orient
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.open(ODatabaseRaw.java:108)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:53)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:127)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:53)
at ru.sersem.testgwt.server.RegBugs.getBugRecordsCount(RegBugs.java:192)
at ru.sersem.testgwt.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:22)
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.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more