Good Day,
Im trying to deploy my war file in Karaf 3.0.2, my servlet is trying to read some S3 files, but I'm getting this error on Instantiating the AmazonS3Client
AmazonS3Client s3Client = new AmazonS3Client();
2015-01-09 13:04:02,205 | INFO | pool-7-thread-1 | S3Properties | 75 - my-domain - 3.0.1.SNAPSHOT | Loading file from S3: my-web.properties
2015-01-09 13:04:02,241 | WARN | pool-7-thread-1 | AbstractLifeCycle | 91 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.15.v20140411 | FAILED MyPerfFilter: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at com.amazonaws.util.VersionInfoUtils.userAgent(VersionInfoUtils.java:139)
at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:134)
at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:95)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:42)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:379)
I thought it was a problem on my static block but I'm thinking it's not, as I have tried to create a simplehelloworld servlet that calls the same class that has this static block and it worked reading the S3 files
static {
System.out.println("test 1");
instance = new MyProperties();
try {
System.out.println("test 2");
instance.load(PROPS_FILENAME);
reloadable = true;
System.out.println("test 3");
} catch (Exception e) {
try {
System.out.println("test 3");
// try to load the file from the classpath instead
instance.load(MyProperties.class.getResourceAsStream("/" + PROPS_FILENAME));
} catch (Exception e1) {
logger.error("Exception caught when loading properties: {}", PROPS_FILENAME, e);
}
}
}
Any suggestions or ideas would be appreciated
Thanks
Related
This is how I currently download a ZIP file from the internet in my MFC project:
strTargetZIP = theApp.GetWorkingPath() + _T("AutoUpdate\\MWBDataUpdate.zip");
strDownloadURL = _T("https://www.publictalksoftware.co.uk/mwbdata/MWBDataUpdate.zip");
// ask user to go on line
const BOOL bOnline = InternetGoOnline(strDownloadURL.GetBuffer(), hWnd, 0);
strDownloadURL.ReleaseBuffer();
if (!bOnline)
return false;
try
{
// our session should already be open
// try to open up Internet session to my URL
// Use flag INTERNET_FLAG_RELOAD
pWebFile = dynamic_cast<CHttpFile*>(iSession.OpenURL(strDownloadURL, 1,
INTERNET_FLAG_SECURE | INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD));
if (pWebFile != nullptr)
{
if (pWebFile->QueryInfoStatusCode(dwStatusCode))
{
// 20x codes mean success
if ((dwStatusCode / 100) == 2)
{
if (fileLocal.Open(strTargetZIP,
CFile::modeCreate | CFile::modeWrite | CFile::typeBinary))
{
iRead = pWebFile->Read(&szBuffer[0], 4096);
while (iRead > 0)
{
iBytesRead += iRead;
fileLocal.Write(&szBuffer[0], iRead);
iRead = pWebFile->Read(&szBuffer[0], 4096);
}
fileLocal.Close();
bOK = true;
}
}
else
{
// There was a problem!
strError.Format(IDS_TPL_INVALID_URL, dwStatusCode);
AfxMessageBox(strError, MB_OK | MB_ICONERROR);
}
}
}
else
{
// Note, there is no error log. Use new error message?
AfxMessageBox(IDS_STR_UPDATE_CHECK_ERR, MB_OK | MB_ICONERROR);
}
}
catch(CException *e_)
{
const gsl::not_null<CException*> e{ e_ };
e->ReportError();
e->Delete();
}
As you can see, I have tried to cater for caching issues. However, it seems that on occasion, for some users, the software does not download the latest ZIP and uses a cached version.
What further steps can I as a developer (or they as a user) take to ensure that my software does actually download the latest ZIP file on my website server?
Using the below code snippet, we created a file in Android 10, in a sub-folder under getExternalFilesDir(). However, immediately after creation, if we try to take persistableUriPermission, it throws an exception "No such permission exists....".
We need that check to know if that file will be available for read later in a common utility, else we have to make a copy. Please let us know what we might be doing wrong and how to fix this. Appreciate your help.
ParcelFileDescriptor filePFD =
cxt.getContentResolver().openFileDescriptor(Uri.parse(pathFileToSend), "r");
FileDescriptor fd = filePFD.getFileDescriptor();
FileInputStream fIn = new FileInputStream(fd);
File fileBaseFolder = new File(Utils.GetRootDirectory().getAbsolutePath(), Utils.DESTINATION);
if (!fileBaseFolder.exists())
fileBaseFolder.mkdirs();
if (fileBaseFolder.exists()) {
File copyFile = new File(fileBaseFolder.getAbsolutePath(), nameOfFile);
FileOutputStream fOut = new FileOutputStream(copyFile);
byte data[] = new byte[4096];
long total = 0;
int count;
while ((count = fIn.read(data)) != -1) {
total += count;
fOut.write(data, 0, count);
}
fOut.close();
Uri copiedFileUri =
FileProvider.getUriForFile(cxt,
cxt.getString(R.string.file_provider_authority),
copyFile);
if (null != copiedFileUri)
{
try {
/*At this line, an exception is thrown - No persistable permissions exist.. */
cxt.getContentResolver().takePersistableUriPermission(copiedFileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
} catch (Exception e) {
e.printStackTrace();
}
}
takePersistableUriPermission() is for Uri values that you get from the Storage Access Framework (e.g., ACTION_OPEN_DOCUMENT). It will not work for FileProvider. And, you do not need permissions to work with getExternalFilesDir() on Android 4.4 and higher.
I'm trying to read the path /var/cache/apt/archives with the following permissions:
drwxr-xr-x 3 root root 90112 ago 2 14:36 archives
And I got the following error:
ERROR: Error opening directory '/var/cache/apt/archives/partial': Permission denied
Can somebody give me a hand with this?
The source code is the following:
using Gtk;
using GLib;
private int64[] get_folder_data (File file, string space = "", Cancellable? cancellable = null) throws Error
{
FileEnumerator enumerator = file.enumerate_children (
"standard::*",
FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
cancellable);
int64 files = 0;
int64 size = 0;
int64[] data = new int64[2];
FileInfo info = null;
while (cancellable.is_cancelled () == false && ((info = enumerator.next_file (cancellable)) != null)) {
if (info.get_file_type () == FileType.DIRECTORY) {
File subdir = file.resolve_relative_path (info.get_name ());
get_folder_data (subdir, space + " ", cancellable);
} else {
files += 1;//Sum Files
size += info.get_size ();//Accumulates Size
}
}
if (cancellable.is_cancelled ()) {
throw new IOError.CANCELLED ("Operation was cancelled");
}
data[0] = files;
data[1] = size;
stdout.printf ("APT CACHE SIZE: %s\n", files.to_string());
stdout.printf ("APT CACHE FILES: %s\n", size.to_string());
return data;
}
public static int main (string[] args) {
Gtk.init (ref args);
File APT_CACHE_PATH = File.new_for_path ("/var/cache/apt/archives");
try {
get_folder_data (APT_CACHE_PATH, "", new Cancellable ());
} catch (Error e) {
stdout.printf ("ERROR: %s\n", e.message);
}
Gtk.main ();
return 0;
}
And the command I used for compile is the following:
valac --pkg gtk+-3.0 --pkg glib-2.0 --pkg gio-2.0 apt-cache.vala
If you run your app as a normal user, you have to exclude the "partial" dir, it has more restrictive permissions (0700):
drwx------ 2 _apt root 4096 Jul 29 11:36 /var/cache/apt/archives/partial
One way to exclude the partial dir is to just ignore any dir that is inaccessible:
int64[] data = new int64[2];
FileEnumerator enumerator = null;
try {
enumerator = file.enumerate_children (
"standard::*",
FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
cancellable);
}
catch (IOError e) {
stderr.printf ("WARNING: Unable to get size of dir '%s': %s\n", file.get_path (), e.message);
data[0] = 0;
data[1] = 0;
return data;
}
In addition it might be a good idea to always explicitly ignore the partial folder.
If you are planning to make your utility useful for the root user as well, you might even think of adding a command line option like "--include-partial-dir".
Also the same thing can be done with simple bash commands which is much easier than writing your own program.
du -sh /var/cache/apt/archives
find /var/cache/apt/archives -type f | wc -l
Note that du and find also warn about the inaccessible partial dir:
$ du -sh /var/cache/apt/archives
du: cannot read directory '/var/cache/apt/archives/partial': Permission denied
4.6G /var/cache/apt/archives
$ find /var/cache/apt/archives -type f | wc -l
find: '/var/cache/apt/archives/partial': Permission denied
3732
I am trying to run my code in studio but continuously getting this error :-
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> Unexpected constructor structure.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried a lot many approaches to solve this error but nothing seems to be working for me
Here is what was doing earlier in my code when this error initially arise :-
Fragment Call from FragmentActivity:-
public void showSelectVideoFragment() {
// TODO Auto-generated method stub
if (checkCurrentSelectedBtForLeftMenu(lMenuBtUploadVideoWRAP)) {
return;
}
setBtBackgroundForLeftMenu(lMenuBtUploadVideoWRAP);
addFragment(new SVideoFragment(mLeftMenu));
}
private void addFragment(Fragment fragment) {
if (fragmentManager != null) {
if (fragmentManager.getBackStackEntryCount() == 0) {
PVHomeFragment homeFragment = (PVHomeFragment) fragmentManager
.findFragmentByTag(FM_TAG_HOME_FRAGMENT);
fragmentManager.beginTransaction().hide(homeFragment).commit();
} else {
fragmentManager.popBackStack();
}
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, fragment, FM_TAG_TOP_FRAGMENT)
.addToBackStack(null).commit();
}
}
SVideoFragment Code :-
public class SVideoFragment extends PVBaseFragment {
private SlidingMenu mLeftMenu = null;
private static final String SLIDEMENU_KEY = "describable_key";
public SVideoFragment() {
}
#SuppressLint({"NewApi","ValidFragment"})
public SVideoFragment(SlidingMenu leftMenu) {
mLeftMenu = leftMenu;
}
#Override
protected void initFragment() {
// TODO Auto-generated method stub
}
#SuppressLint({"NewApi","ValidFragment"})
#Override
protected View initFragmentView(LayoutInflater inflater, ViewGroup container) {
// TODO Auto-generated method stub
View v = inflater.inflate(R.layout.fragment_select_video, container,
false);
Button btToggleLeftMenu = (Button) v
.findViewById(R.id.btToggleLeftMenu);
btToggleLeftMenu.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
if (mLeftMenu != null) {
mLeftMenu.toggle();
}
}
});
((Button) v.findViewById(R.id.btSelectVideo))
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
showVideoSelector();
}
});
return v;
}
I added below lines to build.gradle :-
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
allprojects {
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
}
}
dependencies {
compile project(':sdk')
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile project(':android-3.1')
compile project(':AVIOCtrlDefine')
compile project(':Facebook')
compile project(':SlidingMenu-master')
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
}
android.packagingOptions {
exclude 'the META-INF / DEPENDENCIES'
exclude 'the META-INF / LICENSE'
exclude 'the META-INF / LICENSE.txt'
exclude 'the META-INF / license.txt'
exclude 'the META-INF / NOTICE'
exclude 'the META-INF / the NOTICE.txt '
exclude ' the META-INF / NOTICE.txt '
exclude ' the META-INF / ASL2.0 '
exclude ' the META-INF / Services / javax.annotation.processing.Processor '
}
After doing all above i was still getting same error so i choose second method that is :-
I called Fragment like this :-
public void showSelectVideoFragment() {
SVideoFragment mSVideoFragment = new SVideoFragment();
// TODO Auto-generated method stub
if (checkCurrentSelectedBtForLeftMenu(lMenuBtUploadVideoWRAP)) {
return;
}
setBtBackgroundForLeftMenu(lMenuBtUploadVideoWRAP);
addFragment(mSVideoFragment.newInstance(mLeftMenu));
}
And In Fragment :-
public class SVideoFragment extends PVBaseFragment {
private SlidingMenu mLeftMenu = null;
private static final String SLIDEMENU_KEY = "describable_key";
public SVideoFragment() {
}
public static SVideoFragment newInstance(SlidingMenu leftMenu) {
SVideoFragment fragment = new SVideoFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(SLIDEMENU_KEY, leftMenu);
fragment.setArguments(bundle);
return fragment;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mLeftMenu = (SlidingMenu) getArguments().getSerializable(SLIDEMENU_KEY);
}
}
#Override
protected void initFragment() {
// TODO Auto-generated method stub
}
#SuppressLint({"NewApi","ValidFragment"})
#Override
protected View initFragmentView(LayoutInflater inflater, ViewGroup container) {
// TODO Auto-generated method stub
View v = inflater.inflate(R.layout.fragment_select_video, container,
false);
Button btToggleLeftMenu = (Button) v
.findViewById(R.id.btToggleLeftMenu);
btToggleLeftMenu.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
if (mLeftMenu != null) {
mLeftMenu.toggle();
}
}
});
((Button) v.findViewById(R.id.btSelectVideo))
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
showVideoSelector();
}
});
return v;
}
But still i am getting same error
** when i run ./gradlew assembleDebug in terminal i got :-**
What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero
exit value 1
Here is my app Dependencies :-
+--- project :sdk
+--- com.google.android.gms:play-services-ads:8.4.0 | --- com.google.android.gms:play-services-basement:8.4.0 | ---
com.android.support:support-v4:23.0.0 | ---
com.android.support:support-annotations:23.0.0
+--- project :android-3.1
+--- project :AVIOCtrlDefine
+--- project :Facebook | +--- com.android.support:support-v4:[21,22) -> 23.0.0 () | ---
com.parse.bolts:bolts-android:1.1.4
+--- project :SlidingMenu-master
+--- com.google.android.gms:play-services:8.4.0 | +--- com.google.android.gms:play-services-ads:8.4.0 () | +---
com.google.android.gms:play-services-analytics:8.4.0 | | ---
com.google.android.gms:play-services-basement:8.4.0 () | +---
com.google.android.gms:play-services-appindexing:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 | | ---
com.google.android.gms:play-services-basement:8.4.0
() | +--- com.google.android.gms:play-services-appinvite:8.4.0 |
| --- com.google.android.gms:play-services-base:8.4.0 () |
+--- com.google.android.gms:play-services-appstate:8.4.0 | | --- com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-auth:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-basement:8.4.0 () | +---
com.google.android.gms:play-services-cast:8.4.0 | | +---
com.google.android.gms:play-services-base:8.4.0 () | | ---
com.android.support:mediarouter-v7:23.0.0 | | ---
com.android.support:appcompat-v7:23.0.0 | | ---
com.android.support:support-v4:23.0.0 () | +---
com.google.android.gms:play-services-drive:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-fitness:8.4.0 | | +---
com.google.android.gms:play-services-base:8.4.0 () | | ---
com.google.android.gms:play-services-location:8.4.0 | |
+--- com.google.android.gms:play-services-base:8.4.0 () | | --- com.google.android.gms:play-services-maps:8.4.0 | |
--- com.google.android.gms:play-services-base:8.4.0
() | +--- com.google.android.gms:play-services-games:8.4.0 | |
+--- com.google.android.gms:play-services-base:8.4.0 () | | --- com.google.android.gms:play-services-drive:8.4.0 () | +---
com.google.android.gms:play-services-gcm:8.4.0 | | +---
com.google.android.gms:play-services-base:8.4.0 () | | ---
com.google.android.gms:play-services-measurement:8.4.0 | |
--- com.google.android.gms:play-services-basement:8.4.0
() | +--- com.google.android.gms:play-services-identity:8.4.0 |
| --- com.google.android.gms:play-services-base:8.4.0 () |
+--- com.google.android.gms:play-services-location:8.4.0 () | +--- com.google.android.gms:play-services-maps:8.4.0 () | +---
com.google.android.gms:play-services-measurement:8.4.0 () | +---
com.google.android.gms:play-services-nearby:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-panorama:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-plus:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-safetynet:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-vision:8.4.0 | | ---
com.google.android.gms:play-services-base:8.4.0 () | +---
com.google.android.gms:play-services-wallet:8.4.0 | | +---
com.google.android.gms:play-services-base:8.4.0 () | | +---
com.google.android.gms:play-services-identity:8.4.0 () | | ---
com.google.android.gms:play-services-maps:8.4.0 () | ---
com.google.android.gms:play-services-wearable:8.4.0 | ---
com.google.android.gms:play-services-base:8.4.0 () ---
com.android.support:multidex:1.0.0
Updated :-
I have tried every thing like adding up of jars one by one , Also Have created one new project in Android studio then put all the folders inside it , have also filter the google play services dependencies which are required for project , have added plugin for google play services too with gcm.jason file in it.
while running ./gradlew assembleDebug --stacktrace command
i am getting :-
Error:trouble processing "java/awt/font/NumericShaper.class":
Error:Ill-advised or mistaken usage of a core class (java.* or
javax.*)
i have done some search related this error and find that it seems to come because of android.jar replication in project but i have not found any duplicate file in my dependencies .
here is my updated gradle.build file :-
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.petzview.android"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
dexOptions {
incremental = true;
maxProcessCount 4
javaMaxHeapSize "4g"
dexInProcess = false
preDexLibraries = false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.android.gms:play-services-plus:9.0.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile project(':AVIOCtrlDefine')
compile project(':Facebook')
compile project(':SlidingMenu-master')
compile 'com.android.support:multidex:1.0.1'
}
android.packagingOptions {
exclude 'the META-INF / DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'the META-INF / LICENSE'
exclude 'the META-INF / LICENSE.txt'
exclude 'the META-INF / license.txt'
exclude 'the META-INF / NOTICE'
exclude 'the META-INF / the NOTICE.txt '
exclude ' the META-INF / NOTICE.txt '
exclude ' the META-INF / ASL2.0 '
exclude ' the META-INF / Services / javax.annotation.processing.Processor '
}
apply plugin: 'com.google.gms.google-services'
Can anybody suggest me a way to solve this problem in android studio.
I`ve got same problem and I fixed it with disabling Instant Run in Android Studio -> Preferences (search for "instant run" or) -> "Build, Execution, Deployment" -> Instant Run -> Enable Instant Run -> turn off
Thanks to #Balki for his answer !
try this: (this looks like it might be the problem)
public SVideoFragment() {
super();
}
#SuppressLint({"NewApi","ValidFragment"})
public SVideoFragment(SlidingMenu leftMenu) {
this();
mLeftMenu = leftMenu;
}
for more information: Difference between "this" and"super" keywords in Java
Hey is this project is migrated from eclipse to studio?I got the same error.I solved it by making the project multidex.Rebuild and sync it after that.Hope this will help.Remove the duplicates dependencies.
gradle - library duplicates in dependencies
My problem was this somewhat unusual constructor
public ActionRequest(BridgeActivity bridgeActivity, String url, Response.Listener<RestResult> listener) {
super(url, Method.POST, RestResult.class, bridgeActivity.new ResponseListener<RestResult>() {
#Override
public void onResponse(RestResult response) {
listener.onResponse(response);
}
});
I think the bidgeActivity.new ResponseListener<RestResult>() call in that constructor is not allowed, I guess that construction is not implemented by some code generator way down in the dex compiler.
We previously used the code below to set up BIRT Engine to use within our servlet, the migration guide says you just need to add the BIRT jars to the classpath, the BIRT jars were added to WEB-INF\lib.
When we run the app now, IReportEngineFactory returns null. Any help is appreciated.
public static synchronized IReportEngine getBirtEngine(ServletContext sc) throws Exception {
EngineConfig config = new EngineConfig();
config.setBIRTHome("");
config.setLogConfig("C:/Temp", Level.FINEST);
config.setLogFile("birtLog.log");
realPath = sc.getRealPath("/reports");
log.info("Server Info: " + sc.getServerInfo());
log.info(" Servlet Context Name: " + sc.getServletContextName());
log.info("Real Path: " + realPath);
log.info("#####Creating new Birt Engine#####");
//log.info("Birt Home is: " + config.getBIRTHome());
IPlatformContext context = new PlatformServletContext(sc);
config.setPlatformContext(context);
try {
Platform.startup(config);
//log.info("Birt Home is: " + config.getPlatformContext().toString());
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject
(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
birtEngine = factory.createReportEngine(config);
}
catch (Exception e ) {
throw e;
}
return birtEngine;
}
Adding the following line solved the problem in my custom BirtEngine.java configuration:
IPlatformContext context = new PlatformServletContext(sc);
config.getAppContext().put(EngineConstants.WEBAPP_CLASSPATH_KEY, "");
On many posts in the net I read you must not set BIRT home and platform context anymore. So your code should become something like this:
public static synchronized IReportEngine getBirtEngine() throws Exception {
EngineConfig config = new EngineConfig();
config.setLogConfig("C:/Temp", Level.FINEST);
config.setLogFile("birtLog.log");
try {
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject
(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
birtEngine = factory.createReportEngine(config);
}
catch (Exception e ) {
throw e;
}
return birtEngine;
}