XDocReport : XDocConverterException: Cannot find converters from=DOCX - xdocreport

I'm testing the sample code from XDocReport. And I combined, creating a docx and pdf report based on a docx template. However I keep on getting this message
Apr 21, 2016 5:39:10 PM fr.opensagres.xdocreport.converter.ConverterRegistry internalFindConverter
SEVERE: Cannot find converters from=DOCX
fr.opensagres.xdocreport.converter.XDocConverterException: Cannot find converters from=DOCX
at fr.opensagres.xdocreport.converter.ConverterRegistry.internalFindConverter(ConverterRegistry.java:121)
at fr.opensagres.xdocreport.converter.ConverterRegistry.findConverter(ConverterRegistry.java:74)
at fr.opensagres.xdocreport.document.AbstractXDocReport.getConverter(AbstractXDocReport.java:667)
at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:690)
at fr.opensagres.xdocreport.samples.docxandfreemarker.DocxProjectWithFreemarkerList.main(DocxProjectWithFreemarkerList.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Here's the code :
try
{
InputStream in = DocxProjectWithFreemarker.class.getResourceAsStream( "DocxProjectWithFreemarkerList.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );
FieldsMetadata metadata = report.createFieldsMetadata();
metadata.load( "developers", Developer.class, true );
IContext context = report.createContext();
Project project = new Project( "XDocReport" );
context.put( "project", project );
List<Developer> developers = new ArrayList<Developer>();
developers.add( new Developer( "ZERR", "Angelo", "angelo.zerr#gmail.com" ) );
developers.add( new Developer( "Leclercq", "Pascal", "pascal.leclercq#gmail.com" ) );
context.put( "developers", developers );
OutputStream out = new FileOutputStream( new File( "DocxProjectWithFreemarkerList_Out.docx" ) );
report.process( context, out );
// ===========================================================================================
Options options = Options.getTo(ConverterTypeTo.PDF);
OutputStream outt = new FileOutputStream(new File("DocxProjectWithFreemarkerList_Out.pdf"));
report.convert(context, options, outt);
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
Is there anything wrong with the code? How can I fix that error?

Your problem is the same than this issue.
You need to have fr.opensagres.xdocreport.converter.docx.xwpf JARs and her dependencies JARs (iText, etc) in your classpath.

Related

Unable To Perform Actions In Appium Because PageFactory Not Identified

I want to launch and perform actions like enter username details in application
but my execution is failing again and again because of error
My Code
public class VerifyProjectFromApp {
WebDriver driver;
AppLaunch toDoistAppLaunch;
HomePage homePage;
LoginPage login;
#BeforeMethod
public void startapplication() {
toDoistAppLaunch= new AppLaunch(driver);
this.driver=toDoistAppLaunch.launchApplication();
}
#Test
public void verifyCreatedProjectInApp() {
try{
//-Read create project value from properties file
Properties prop = new Properties();
InputStream input = null;
input = new FileInputStream(System.getProperty("user.dir") +
File.separator +"TodoistInputData.properties");
prop.load(input);
//-Read uuid from properties file
String email_id = prop.getProperty("email_id");
System.out.println("\t" + "email_id =" + email_id + "\r\n");
//-Read project name from properties file
String password = prop.getProperty("password");
System.out.println("\t" + "projectName =" + password + "\r\n");
login = new LoginPage(driver);
homePage = new HomePage(driver);
login.loginInApplication(email_id, password);
Utils.waitForPageLoadingToComplete(driver);
homePage.clickOnSideMenu();
Utils.pauseTestExecution(10);
} catch (Exception e) {
e.printStackTrace();
}
}
===================================================
public class LoginPage {
public static final String packageName = "com.todoist";
AndroidDriver<MobileElement> driver;
public LoginPage(WebDriver driver){
this.driver = (AndroidDriver<MobileElement>)driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
#AndroidFindBy(id=packageName+":id/btn_welcome_continue_with_email")
MobileElement continueButtonWithGmail;
#AndroidFindBy(id=packageName+":id/email_exists_input")
MobileElement enterEmailId;
#AndroidFindBy(id=packageName+":id/log_in_password")
MobileElement enterPassword;
#AndroidFindBy(id=packageName+":id/btn_continue_with_email")
MobileElement loginwithGmail;
#AndroidFindBy(id=packageName+":id/btn_log_in")
MobileElement loginButton;
public void clickOnContinueButtonWithGmail() {
continueButtonWithGmail.click();
}
public void enterEmailAddress(String emailId) {
enterEmailId.sendKeys(emailId);
}
public void enterPassword(String pass) {
enterPassword.sendKeys(pass);
}
public void clickOnGmailButton() {
loginwithGmail.click();
}
public void clickOnLoginButton() {
loginButton.click();
}
public void loginInApplication(String emailId,String password) {
try {
clickOnContinueButtonWithGmail();
Utils.waitForPageLoadingToComplete(driver);
enterEmailAddress(emailId);
Utils.waitForPageLoadingToComplete(driver);
clickOnGmailButton();
Utils.waitForPageLoadingToComplete(driver);
enterPassword(password);
Utils.waitForPageLoadingToComplete(driver);
clickOnLoginButton();
} catch(Exception e) {
e.printStackTrace();
}
}
=============================================================================================
Error Coming
[TestNG] Running:
C:\Users\Daffodil-255\AppData\Local\Temp\testng-eclipse--467741697\testng-customsuite.xml
Print app path E:\TodoistAutomation\Android_Todoist_Project\apkfile\Todoist_v12.8_apkpure.com.apk
Jul 25, 2018 11:57:52 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
email_id =tarun.dabbs#daffodilsw.com
projectName =123456
Jul 25, 2018 11:57:52 AM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown method' (405 expected)
FAILED CONFIGURATION: #AfterMethod closeApplication
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:14.902Z'
System info: host: 'DAFFODILLAP-265', ip: '172.18.1.128', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_65'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, databaseEnabled: false, desired: {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, deviceName: Nexus5X1, platformName: android, platformVersion: 7.1.1}, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: Android, platformVersion: 7.1.1, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 7333c28b-2ec8-48b2-89c0-b04e2c90ec74
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:438)
at com.todoist.tests.VerifyProjectFromApp.closeApplication(VerifyProjectFromApp.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:703)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
FAILED: verifyCreatedProjectInApp
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor
at com.todoist.pages.LoginPage.<init>(LoginPage.java:22)
at com.todoist.tests.VerifyProjectFromApp.verifyCreatedProjectInApp(VerifyProjectFromApp.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 26 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#19bb089b: 171 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#35bbe5e8: 14 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#6bdf28bb: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#1fbc7afb: 65 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#129a8472: 15 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 11 ms
Issue happens due this:
ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
to fix this you need to add cglib:cglib dependency:
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.7</version>
</dependency>
hope this helps,
Add both cglib and asm dependency in your project. This will solve your problem.
cglib-3.2.7.jar
asm-6.2.jar

how to configure a FileEntityStoreService

I'm trying to use a File EntityStore and I'm having an exception at activation because of slices being zero.
I assume it's an issue with configuration but I expected the default value to be 1.
I narrowed down to this assembly:
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.bootstrap.Energy4Java;
import org.apache.polygene.entitystore.file.assembly.FileEntityStoreAssembler;
import org.apache.polygene.index.rdf.assembly.RdfNativeSesameStoreAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
public class FileStoreException {
public static void main(String[] args) throws Exception {
Energy4Java polygene = new Energy4Java();
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
new FileConfigurationAssembler()
.visibleIn(Visibility.application)
.assemble(module);
new FileEntityStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
application.activate();
}
}
The end of the stacktrace:
Caused by: java.lang.ArithmeticException: / by zero
at method "get" of FileEntityStoreService:FileEntityStoreService in module [Module 1] of layer [Layer 1].(:0)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:277)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:328)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.get(FileEntityStoreMixin.java:138)
at org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin.entityStateOf(JSONMapEntityStoreMixin.java:193)
... 14 more
I'm using version 3.0.0 and I'm on linux.
Adding FileConfigurationAssembler gave me the false impression that my config was done.
I struggled to find a working example of an assembly using a FileEntityStoreAssembler so here's one:
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
ModuleAssembly config = module.layer().module("Config");
config.defaultServices();
new MemoryEntityStoreAssembler().assemble(config);
config.entities(FileEntityStoreConfiguration.class);
new FileEntityStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
And to configure it:
config.forMixin(FileEntityStoreConfiguration.class)
.declareDefaults()
.directory().set("/home/user/appdata/");

Javafxports on Android won't load image due to "Improper call to JPEG library in state 200"

When I run the application with IntelliJ the image is visible but when ported to Android (6.0 & 4.4.2) it isn't. The Image object is instantiated with an URL (website).
Logcat
W/linker: /data/app/com.xxxx.xxxx.scan.application.scanner-2/lib/arm/libjavafx_iio.so: is missing DT_SONAME will use basename as a replacement: "libjavafx_iio.so"
W/System.err: java.io.IOException: Improper call to JPEG library in state 200
//##The error below is thrown at the new Image(url) operation
W/System.err: at com.xxxx.xxxx.scan.application.scanner.controllers.ProductController.updateImageView(ProductController.java:117)
Method that loads the image
private synchronized void updateImageView(ProductEntry product) {
if (product.getExtraInfo() != null && product.getExtraInfo().size() > 0) {
ExtraInfo extraInfo = product.getExtraInfo().get(0);
figLabel.setText(extraInfo.getInfo());
image = new Image(extraInfo.getUrl());
imageView.fitHeightProperty().bind(pane.heightProperty());
imageView.fitWidthProperty().bind(pane.widthProperty());
imageView.setPreserveRatio(true);
// imageView.setSmooth(true);
// imageView.setCache(true);
imageView.setImage(image);
}
}
build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'http://xxxx.xxxx.com:8080/artifactory/plugins-release'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:+"
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: "com.jfrog.artifactory"
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-release-local'
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
maven = true
}
}
}
repositories {
jcenter()
mavenLocal()
}
mainClassName = 'com.essers.pxl2016.scan.application.scanner.MainApplication'
dependencies {
compile(group: 'com.essers.pxl2016', name: 'scan-server-definition', version: '0.0.1-SNAPSHOT')
compile(group: 'com.xxxx.xxxx', name: 'client', version: '1.0-SNAPSHOT')
compile('com.google.code.gson:gson:2.2.4')
testCompile "junit:junit:4.12"
}
jfxmobile {
javafxportsVersion = '8.60.7'
ios {
forceLinkClasses = ['com.xxxx.xxxx.scan.**.*']
}
android {
applicationPackage = 'com.xxxx.xxxx.scan.application.scanner'
}
}
test {
exclude 'com/xxxx/xxxx/scan/application/scanner/**'
}
src/main/resources/java.custom.properties
# Solves crash when clicking the menu.
monocle.stackSize=128000
Kind regards
The cause of the problem appears to be the file size of the image. The image showed up after reducing the file size.

How can I externalise my selenium setup in order to make my selenium tests configurable

I would like to externalise my selenium tests setting in order to make them more configurable.
I would like to externalise my testURL and my node URLS.
Here is my code :
public void setup () throws MalformedURLException
{ //the URL of the application to be tested
TestURL = "http://frstmwarwebsrv2.orsyptst.com:9000";
//Hub URL
BaseURL = "http://10.2.128.126";
//Node1 URL
winURL = "http://10.2.128.120:5556/wd/hub";
//Node2 URL
androidURL ="http://10.2.128.120:5555/wd/hub";
At the moment I have added this setup function in every test I would like to have it in an XML file for an example in order to make it configurable, any suggestions?
Thanks
Thanks for your help
Update :
Here is what i did so far :
Added a config.properties file with this content :
# This is my test.properties file
AppURL = http://************
HubURL= http://*****************
WinURL= http://*********/wd/hub
AndroidURL =
iOSURL
And created a classe to read properties :
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
public class ReadPropertiesFile {
public static void main(String[] args) {
try {
File file = new File("config.properties");
FileInputStream fileInput = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInput);
fileInput.close();
Enumeration enuKeys = properties.keys();
while (enuKeys.hasMoreElements()) {
String key = (String) enuKeys.nextElement();
String value = properties.getProperty(key);
System.out.println(key + ": " + value);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
when running this i get this error :
java.io.FileNotFoundException: config.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at ReadPropertiesFile.main(ReadPropertiesFile.java:15)
my properties file is under src folder
Two basic ways you could do this are:
Pass in JVM argument and access it using System.getProperty(...)
Externalize your configuration in to properties files, like here
I recently implemented the second one in my Selenium tests and can expand this answer to give more details if you need them.
In my tests, I resolved it that I created Java class called Environment to store information about given Environment:
Few snippets of code:
public enum NameOfEnvironment {
SYSTEMTEST, ACCEPTANCE
}
stores the Name of given Environment :)
public String getBaseUrl() {
switch (actualEnvironment) {
case SYSTEMTEST: {
baseUrl = getPrefix() + "172.23.32.251:9092/pages/index.html";
break;
}
will return me the URL to the environment. And on beginning of the test I have something like this:
public static final Environment USED_ENVIRONMENT = new Environment(Environment.NameOfEnvironment.SYSTEMTEST);
And later on I just call USED_ENVIRONMENT.getBaseUrl() which will return me the link which is being actual for current run
Btw, to fill in the blanks, here is the constructor f the class
public Environment(NameOfEnvironment env) {
this.actualEnvironment = env;
}

Cannot make database connection due to servlet errors

In the below code I have two files. One is for my database connectivity and the other is for my html based jsp file. I am attempting to check the version of my database and print it to the screen. I am trying to return the value of CheckVersion and use out.println to put it on the webpage.
I am getting the follow errors.
type Exception report
message
descriptionThe server encountered an internal error () that prevented
it from fulfilling this request.
exception
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation
for JSP
PWC6199: Generated servlet error: package
com.sun.xml.rpc.processor.modeler.j2ee.xml does not exist
PWC6199: Generated servlet error: package databaseFiles does not exist
PWC6197: An error occurred at line: 18 in the jsp file: /index.jsp
PWC6199: Generated servlet error: cannot find symbol symbol: class
DatabaseManagement location: class org.apache.jsp.index_jsp
PWC6197: An error occurred at line: 18 in the jsp file: /index.jsp
PWC6199: Generated servlet error: cannot find symbol symbol: class
DatabaseManagement location: class org.apache.jsp.index_jsp
What am I doing wrong? I am using netbeans and it is not reporting any problems with the way I created my file. index.jsp is in the root area and I created a folder named databaseFiles that is holding my DatabaseManagement.java file.
Thanks.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package databaseFiles;
import com.sun.corba.se.impl.util.Version;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* #author Aaron
*/
public class DatabaseManagement {
private final String urlDB = "jdbc:mysql://correct:3306/javaBBS";
private final String userDB = "correct";
private final String passwordDB = "correct";
Connection conDB = null;
Statement st = null;
ResultSet rs = null;
/*
*
*
*/
public DatabaseManagement() {
}
/*
*
*/
public void OpenConnection()
{
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(Exception e) {
System.out.println("Could not load database driver");
}
conDB = DriverManager.getConnection(urlDB, userDB, passwordDB);
} catch(SQLException ex) {
Logger lgr = Logger.getLogger(Version.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
}
}
/*
* Closes the current database object
*/
public void CloseConnection() {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (conDB != null) {
conDB.close();
}
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Version.class.getName());
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
}
/**
* Checks the database version
*/
public String CheckVersion() throws SQLException {
try {
st = conDB.createStatement();
rs = st.executeQuery("SELECT VERSION()");
} catch(Exception e) {
System.out.println("Could not get the version of the DB.");
}
if (rs.next()) {
System.out.println(rs.getString(1));
}
return rs.getString(1);
}
}
The below is index.jsp.
<%--
Document : index
Created on : May 30, 2013, 1:48:03 PM
Author : Aaron
--%>
<%#page import="com.sun.xml.rpc.processor.modeler.j2ee.xml.string"%>
<%#page import="databaseFiles.DatabaseManagement"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%
out.println("<br/>Your IP address is " + request.getRemoteAddr());
String userAgent = request.getHeader("user-agent");
String browser = "unknown";
out.print("<br/>and your browser is ");
if (userAgent != null) {
if (userAgent.indexOf("MSIE") > -1) {
browser = "MS Internet Explorer";
}
else if (userAgent.indexOf("Firefox") > -1) {
browser = "Mozilla Firefox";
}
else if (userAgent.indexOf("Opera") > -1) {
browser = "Opera";
}
else if (userAgent.indexOf("Chrome") > -1) {
browser = "Google Chrome";
}
else if (userAgent.indexOf("Safari") > -1) {
browser = "Apple Safari";
}
}
out.println(browser);
DatabaseManagement dbConnector = new DatabaseManagement();
dbConnector.OpenConnection();
out.println(dbConnector.CheckVersion());
dbConnector.CloseConnection();
%>
</body>
</html>
I think your project layout is the problem. It should be something like this:
root
WEB-INF
classes
databaseFiles
DatabaseManagement.class
index.jsp
So you should have your compiled .class files in the WEB-INF/classes directory and your .jsp files can go anywhere in the web application's root directory. Also, be sure that you're using the .class file and not the .java file.

Resources