I have a problem with Magento 1.9 and PHPUNit 7.4. PHP version is 7.2.
Below the tree. http is the folder of Magento.
root/
├── http/
│ └── app
├── php-unit -> (with composer)
├── test/
│ └── unit/
│ ├── bootstrap.php
│ └── testsuite/
│ └── module
└── phpunit.xml
Below XML source file.
<!-- phpunit.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd"
backupStaticAttributes="false"
bootstrap="tests/unit/bootstrap.php"
cacheTokens="true"
backupGlobals="true"
forceCoversAnnotation="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
stopOnFailure="false"
testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
colors="true"
verbose="true">
<testsuites>
<testsuite name="Test Suite">
<directory>tests/unit/testsuite/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">http/app/code/local/</directory>
<exclude>
<file>http/app/Mage.php</file>
<directory suffix=".php">http/app/code/core</directory>
<directory suffix=".php">http/app/code/local/Credis</directory>
<directory suffix=".phtml">http/app/design</directory>
<directory suffix=".php">http/lib/Varien</directory>
<directory suffix=".php">http/lib/Zend</directory>
<directory suffix=".php">http/lib/Magento</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Below bootstrap.php.
//bootstrap.php
class Bootstrap {
public function __construct() {
echo "Loading Magento\n";
# ABSOLUTE PATH SERVER
require_once( getcwd().'/http/app/Mage.php' );
echo "require_once Mage\n";
Mage::app(); <--- Error
echo "start Mage::app()\n";
The error message, finally:
PHP Fatal error: Uncaught CredisException: Connection to Redis redis:6379 failed after 2 failures.
Last Error : (0) php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /myfolder/http/app/code/local/Credis/Client.php:475
Related
I work with the old legacy project and trying to switch it to Java 11.
At the moment I am able to compile it successfully, but it crashes when starting.
The project consists of several eclipse plugins modules and final eclipse-repository module which has product file (there is also pom file compiles all modules and creates executable file in target folder of the eclipse-repository module)
Targed definition file is resolved succesfully too and looks like
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="phoenixldm-artifactory-p2" sequenceNumber="259">
<locations>
<location includeAllPlatforms="true" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/releases/2019-09"/>
<unit id="org.eclipse.birt.feature.group" version="4.7.0.v201706222054"/>
</location>
<location includeAllPlatforms="true" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/releases/2020-12"/>
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.21.0.v20201128-0731"/>
<unit id="org.eclipse.sdk.feature.group" version="4.18.0.v20201202-1800"/>
<unit id="org.eclipse.jst.enterprise_ui.feature.feature.group" version="3.20.0.v202011230434"/>
<unit id="org.eclipse.jst.web_ui.feature.feature.group" version="3.20.0.v202011230434"/>
<unit id="org.eclipse.pde.feature.group" version="3.14.600.v20201202-1800"/>
<unit id="org.eclipse.wst.web_ui.feature.feature.group" version="3.20.0.v202011230431"/>
<unit id="org.eclipse.wst.xml_ui.feature.feature.group" version="3.20.0.v202011230430"/>
</location>
<location includeAllPlatforms="true" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://artifactory.in.XXX.com/artifactory/YYY/platform"/>
<unit id="com.company.orm.platform.feature.feature.group" version="2.1.2"/>
<unit id="com.company.orm.platform.feature.source.feature.group" version="2.1.2"/>
</location>
<location includeAllPlatforms="true" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://artifactory.in.XXX.com/artifactory/YYY/application"/>
<unit id="com.company.orm.core.feature.feature.group" version="2.1.2"/>
<unit id="com.company.orm.core.feature.source.feature.group" version="2.1.2"/>
<unit id="com.company.update.feature.feature.group" version="2.1.2"/>
<unit id="com.company.update.feature.source.feature.group" version="2.1.2"/>
</location>
</locations>
</target>
I'm using two version of eclipse: the latest 2020-12, and 2019-09 because this is the latest version with BIRT whose is used in our project.
My product file is feature-oriented, so the product file looks like
<product name="Noname" uid="noname" version="1.1.1" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>
<launcherArgs>
<programArgsLin>-os ${target.os} -ws ${target.ws} -arch ${target.arch} -consoleLog
</programArgsLin>
<programArgsWin>-os ${target.os} -ws ${target.ws} -arch ${target.arch} -consoleLog
</programArgsWin>
<vmArgsLin>-Xmx2048m -Xms512m -XX:+UseParallelGC -Xshare:auto -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dlogback.configurationFile=log.xml
</vmArgsLin>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
<vmArgsWin>-Xmx768m -Xms256m -Xshare:auto -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dlogback.configurationFile=log.xml
</vmArgsWin>
</launcherArgs>
<windowImages/>
<launcher name="phoenix">
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
</plugins>
<features>
<feature id="com.company.comp.feature"/>
<feature id="com.company.orm.core.feature"/>
<feature id="com.company.orm.platform.feature"/>
<feature id="org.eclipse.pde"/> <!-- added because can't find org.eclipse.equinox.simpleconfigurator -->
</features>
<configurations>
<!-- all plug-ins from my features above -->
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
<preferencesInfo>
<targetfile overwrite="false"/>
</preferencesInfo>
<cssInfo>
</cssInfo>
</product>
there is plugin in pom file
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
</plugin>
</plugins>
</build>
which creates executable for the product.
If I start the executable I'll get "Segmetation fault"
When I start it as Run Configuration - Eclipse Application, then it will craches with log
!ENTRY org.eclipse.equinox.launcher 4 0 2021-01-30 12:46:42.659
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:650)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1461)
at org.eclipse.equinox.launcher.Main.main(Main.java:1434)
Unforunatelly, I am not sure that I do everything properly. May be someone could tell me where I'm wrong.
It seems to me that I found the root cause of my problem. At least my application can be running without crashing into a Segmentation fault. Unfortunately, it still complains about unresolved dependencies but it's a big step forward.
So, the problem was in
<programArgsLin>-os ${target.os} -ws ${target.ws} -arch ${target.arch} -consoleLog
in my product file.
removing -os ${target.os} -ws ${target.ws} -arch ${target.arch}
let the application run.
Thanks #greg-449, you're absolutely right about org.eclipse.pde - it is not a feature which I need.
I've refactored my product and it looks like
...
<launcherArgs>
<programArgs>-consoleLog
</programArgs>
<vmArgs>-Xshare:auto -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dlogback.configurationFile=log.xml
</vmArgs>
<vmArgsLin>
<argsX86_64>-Xmx2048m -Xms512m -XX:+UseParallelGC</argsX86_64>
</vmArgsLin>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
<vmArgsWin>-Xmx768m -Xms256m
</vmArgsWin>
</launcherArgs>
...
<vm>
<linux include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11</linux>
<macos include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11</macos>
</vm>
...
<features>
... list of my features ...
<feature id="org.eclipse.e4.rcp" installMode="root"/>
<feature id="org.eclipse.emf.ecore" installMode="root"/>
<feature id="org.eclipse.emf.common" installMode="root"/>
</features>
<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
I am trying to use -fsanitize=address feature in clang compiler, but I am interested in to see my local project errors only, so I will ignore the incoming error from 3rdparty libraries, specifically I have a project configured to ignore the errors who become from dbus.
My system:
cmake version 3.9.5
Linux hostname 4.14.0-2-amd64 #1 SMP Debian 4.14.7-1 (2017-12-22) x86_64 GNU/Linux
clang version 4.0.1-8 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
My mcve:
.
├── CMakeLists.txt
├── CTestConfig.cmake
├── CTestCustom.cmake
├── MyASan.supp
└── src
├── CMakeLists.txt
├── entityitem.cc
├── mainwindow.cc
├── mainwindow.h
└── mainwindow.ui
1 directory, 10 files
CMakeLists.txt:
cmake_minimum_required(VERSION 3.9.0 FATAL_ERROR)
project(SanitizerTest)
set(CMAKE_C_STANDARD 14)
set(CMAKE_CXX_STANDARD 14)
include(CTest)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
CTestConfig.cmake:
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
##
## # The following are required to submit to the CDash dashboard:
## ENABLE_TESTING()
## INCLUDE(CTest)
set(CTEST_PROJECT_NAME "Exampling")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "localhost:8090")
set(CTEST_DROP_LOCATION "/submit.php?project=Exampling")
set(CTEST_DROP_SITE_CDASH TRUE)
CTestCustom.cmake:
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_MEMORYCHECK_TYPE "AddressSanitizer")
set(CTEST_SOURCE_DIRECTORY ${CTEST_SCRIPT_DIRECTORY})
set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CTEST_SOURCE_DIRECTORY}/MyASan.supp)
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
set(CTEST_MEMORYCHECK_TYPE "AddressSanitizer")
ctest_start(Experimental)
set(CONFIGURE_OPTIONS
"-DCMAKE_BUILD_TYPE=Debug"
"-DCMAKE_CXX_FLAGS=-g -O0 -fno-omit-frame-pointer -fsanitize=address"
"-DCMAKE_C_FLAGS=-g -O0 -fno-omit-frame-pointer -fsanitize=address"
"-DCMAKE_GENERATOR=Unix Makefiles"
"-DCMAKE_CXX_COMPILER=clang"
"-DCMAKE_C_COMPILER=clang"
)
ctest_configure(OPTIONS "${CONFIGURE_OPTIONS}")
ctest_build()
MyASan.supp:
interceptor_via_lib:dbus-1
src/CMakeLists.txt:
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
add_library(module
${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.cc)
target_include_directories(module INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/module_autogen/include>)
target_link_libraries(module
PUBLIC stdc++
PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets)
add_executable(main
${CMAKE_CURRENT_SOURCE_DIR}/entityitem.cc)
target_link_libraries(main module)
src/entityitem.cc:
#include <QtWidgets/QApplication>
#include <QtCore/QDebug>
#include "mainwindow.h"
int main(int argc, char *argv[]) {
QApplication a{argc, argv};
MainWindow d;
qDebug() << d.width();
return EXIT_SUCCESS;
}
src/mainwindow.cc:
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
int *i{new int};
ui.setupUi(this);
}
src/mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
private:
Ui::MainWindow ui;
};
#endif // MAINWINDOW_H
src/mainwindow.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
My problem, from the project root dir execute:
mkdir build
cd build
ctest -DCTEST_BINARY_DIRECTORY="." --verbose -S ../CTestCustom.cmake
./src/main
And then the output is:
=================================================================
==24262==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 6912 byte(s) in 27 object(s) allocated from:
#0 0x4d0810 (/home/adacosta/WORK/fffffffffff/Sanitazer/build/src/main+0x4d0810)
#1 0x7f75480378ed (/usr/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1d8ed)
Direct leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x4d0810 (/home/adacosta/WORK/fffffffffff/Sanitazer/build/src/main+0x4d0810)
#1 0x7f75529b1097 (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x90097)
#2 0x50a80f (/home/adacosta/WORK/fffffffffff/Sanitazer/build/src/main+0x50a80f)
#3 0x7f7550369f29 (/lib/x86_64-linux-gnu/libc.so.6+0x20f29)
Indirect leak of 4239 byte(s) in 5 object(s) allocated from:
#0 0x4d0c35 (/home/adacosta/WORK/fffffffffff/Sanitazer/build/src/main+0x4d0c35)
#1 0x7f754545b47c (/lib/x86_64-linux-gnu/libdbus-1.so.3+0x3247c)
Indirect leak of 1824 byte(s) in 57 object(s) allocated from:
#0 0x4d0a18 (/home/adacosta/WORK/fffffffffff/Sanitazer/build/src/main+0x4d0a18)
#1 0x7f7548037fd8 (/usr/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1dfd8)
.
.
.
As you can see I have a "Indirect leak of" from dbus lib.
Solution:
Change the set(CTEST_MEMORYCHECK_TYPE "AddressSanitizer") to
set(CTEST_MEMORYCHECK_TYPE "LeakSanitizer").
Change the interceptor_via_lib:dbus-1 to leak:libdbus-1.
This will to send LSAN_OPTIONS instead of ASAN_OPTIONS to the process execution.
More info: https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions
I want to access files (images, text files etc.) from an USB stick on my Raspberry Pi 2 using Windows 10 IoT Core.
So I've added the to the appxmanifest file.
When using this code in my IBackgroundTask I get an access denied error in the second line:
public sealed class StartupTask : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
//...
Windows.Storage.StorageFolder sf = Windows.Storage.KnownFolders.RemovableDevices;
//get list of drives
IReadOnlyList<Windows.Storage.StorageFolder> list = await sf.GetFoldersAsync();
...
}
}
I found that I should add the fileTypeAssociation with the file types I'd like to access in Package.appxmanifest so I did that:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp iot">
<Identity Name="test-uwp" Publisher="CN=user" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="8f31dff8-3a2b-4df1-90bb-2c5267f32980" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>test</DisplayName>
<PublisherDisplayName>user</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App">
<uap:VisualElements DisplayName="test" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="test" BackgroundColor="transparent" AppListEntry="none">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<Extension Category="windows.backgroundTasks" EntryPoint="test.StartupTask">
<BackgroundTasks>
<iot:Task Type="startup" />
</BackgroundTasks>
</Extension>
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="myimages">
<uap:SupportedFileTypes>
<uap:FileType ContentType="image/jpeg">.jpg</uap:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="removableStorage" />
</Capabilities>
</Package>
If I want to deploy that, I get the following error:
Severity Code Description Project File Line Suppression State
Error Error : DEP0700 : Registration of the app failed.
AppxManifest.xml(37,10): error 0x80070490: Cannot register the
test-uwp_1.0.0.0_arm__yzekw4x8qxe1g package because the following
error was encountered while parsing the windows.fileTypeAssociation
Extension element: Element not found. . Try again and contact the
package publisher if the problem persists. (0x80073cf6)
As soon as I remove the uap:Extension element, the error goes away (but the access denied is still there).
Did I miss anything? Is it not possible to access files from an USB stick using a background service (I want to run that headless with no user interaction)?
At the moment you can't register a headless app that uses filetypeAssociation.
There is a workaround - see here: https://github.com/ms-iot/ntvsiot/issues/62
Simply add a headed app (project) to your solution (no need for any special code there).
Add a reference to this project in your headless app.
Now change the manifest of the headless (file asso..) and add Executable: YourHeadedApp.exe and EntryPoint: YourHeadedApp.App now with the next deploy the EXE will be included in deployment - so it can be found when the manifest is checked.
I have just setup my first project using apache ant with ivy as dependency manager. It is working great! But I have one thing I cannot get over. Since I have several dependencies that use slf4j there is a conflict with version mismatches. So I defined a conflict tag in the ivy.xml to force a certain version (1.5.6 in this case). Running the Ivy resolve with eclipse plugin IvyIDE works without error. But when using my ant build file to build my application I get a xml syntax error:
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Buildfile: B:\core-lib\build.xml
parsing buildfile B:\core-lib\build.xml with URI = file:/B:/core-lib/build.xml
Project base dir set to: B:\core-lib
parsing buildfile jar:file:/C:/Program%20Files/InformDevTools/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Program%20Files/InformDevTools/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `resolve' is [clean, init, resolve]
Complete build sequence is [clean, init, resolve, compile, resources, test, dist, ]
clean:
[delete] Deleting directory B:\core-lib\build
[delete] Deleting directory B:\core-lib\build\lib
[delete] Deleting directory B:\core-lib\build\main
[delete] Deleting directory B:\core-lib\build\report\test
[delete] Deleting directory B:\core-lib\build\report
[delete] Deleting directory B:\core-lib\build\test
[delete] Deleting directory B:\core-lib\build
[delete] Deleting directory B:\core-lib\dist
[delete] Deleting directory B:\core-lib\dist
init:
Override ignored for property "DSTAMP"
Override ignored for property "TSTAMP"
Override ignored for property "TODAY"
[mkdir] Created dir: B:\core-lib\build
[mkdir] Created dir: B:\core-lib\build\main
[mkdir] Created dir: B:\core-lib\build\lib
[mkdir] Created dir: B:\core-lib\dist
[mkdir] Created dir: B:\core-lib\build\test
[mkdir] Created dir: B:\core-lib\build\report\test
resolve:
parsing buildfile jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/ant/antlib.xml with URI = jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/ant/antlib.xml from a zip file
[ivy:retrieve] No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used
[ivy:retrieve] Loading jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/core/settings/ivy.properties
[ivy:retrieve] searching settings file: trying B:\core-lib\ivysettings.xml
[ivy:retrieve] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] jakarta commons httpclient not found: using jdk url handling
[ivy:retrieve] :: loading settings :: file = B:\core-lib\ivysettings.xml
[ivy:retrieve] no default ivy user dir defined: set to C:\Users\admin\.ivy2
[ivy:retrieve] no default cache defined: set to C:\Users\admin\.ivy2\cache
[ivy:retrieve] settings loaded (31ms)
[ivy:retrieve] default cache: C:\Users\admin\.ivy2\cache
[ivy:retrieve] default resolver: inform-artifactory
[ivy:retrieve] -- 5 resolvers:
[ivy:retrieve] inform [release] [ibiblio]
[ivy:retrieve] inform [snapshot] [ibiblio]
[ivy:retrieve] inform [proxied] [ibiblio]
[ivy:retrieve] inform-artifactory [chain] [inform [proxied], inform [third-party], inform [release], inform [snapshot]]
[ivy:retrieve] inform [third-party] [ibiblio]
[ivy:retrieve] no resolved descriptor found: launching default resolve
Overriding previous definition of property "ivy.version"
[ivy:retrieve] using ivy parser to parse file:/B:/core-lib/ivy.xml
[ivy:retrieve] [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
[ivy:retrieve] ]
BUILD FAILED
B:\core-lib\build.xml:77: syntax errors in ivy file: java.text.ParseException: [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
]
at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:396)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
at org.apache.ivy.ant.IvyPostResolveTask.ensureResolved(IvyPostResolveTask.java:231)
at org.apache.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolveTask.java:178)
at org.apache.ivy.ant.IvyRetrieve.doExecute(IvyRetrieve.java:87)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: java.text.ParseException: [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
]
at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractParser.checkErrors(AbstractModuleDescriptorParser.java:89)
at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractParser.getModuleDescriptor(AbstractModuleDescriptorParser.java:344)
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescriptor(XmlModuleDescriptorParser.java:117)
at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:48)
at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:184)
at org.apache.ivy.Ivy.resolve(Ivy.java:503)
at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:326)
... 20 more
Total time: 500 milliseconds
If I remove the conflict definition, the build works as expected. Here is the ivy.xml:
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="eu.inform" module="isac3-core" revision="1.0-snapshot"></info>
<configurations>
<conf name="build" description="provide business logic for isac3"/>
<conf name="test" extends="build" visibility="private" description="just for JUnit testing"/>
</configurations>
<publications>
<artifact name="core-lib" type="jar" conf="build" ext="jar"/>
</publications>
<dependencies>
<dependency org="org.apache.commons" name="commons-lang3" rev="3.1" conf="build->default"/>
<dependency org="commons-codec" name="commons-codec" rev="1.6" conf="build->default"/>
<dependency org="org.apache.mina" name="mina-core" rev="2.0.4" conf="build->default"/>
<dependency org="org.apache.tika" name="tika-app" rev="1.1" conf="build->default"/>
<!--
Resolve conflict for SLF4J by selecting the latest compatible version:
Apache tika comes packaged with slf4j 1.5.6, so we cannot exclude this dependency because it is part of the jar.
Hibernate specifies a dependency to slf4j 1.6.1 by maven pom file.
-->
<conflict org="org.slf4j" rev="1.5.6"/>
<dependency org="org.springframework" name="spring-aop" rev="3.1.1.RELEASE" conf="build->default"/>
<dependency org="org.aspectj" name="aspectjweaver" rev="1.5.4" conf="build->default"/>
<dependency org="org.springframework" name="spring-orm" rev="3.1.1.RELEASE" conf="build->default">
<!-- don't include any ORM implementation since we defined the one we use -->
<exclude org="org.eclipse.persistence" />
<exclude org="toplink.essentials" />
<exclude org="org.apache.ibatis" />
<exclude org="org.apache.openjpa" />
<exclude org="org.hibernate" />
</dependency>
<dependency org="org.hibernate" name="hibernate-core" rev="4.1.4.Final" conf="build->default"/>
<dependency org="org.hibernate" name="hibernate-ehcache" rev="4.1.4.Final" conf="build->default"/>
<dependency org="org.hibernate" name="hibernate-envers" rev="4.1.4.Final" conf="build->default"/>
<dependency org="org.hibernate" name="hibernate-search-engine" rev="4.1.1.Final" conf="build->default"/>
<dependency org="org.hibernate" name="hibernate-search-orm" rev="4.1.1.Final" conf="build->default"/>
<dependency org="c3p0" name="c3p0" rev="0.9.1.2" conf="build->default"/>
<dependency org="de.jollyday" name="jollyday" rev="0.4.6" conf="build->default"/>
<dependency org="log4j" name="log4j" rev="1.2.17" conf="build->default"/>
<!-- JDBC drivers -->
<dependency org="net.sourceforge.jtds" name="jtds" rev="1.2.4" conf="build->default"/>
<dependency org="com.microsoft" name="sqljdbc4" rev="4.0" conf="build->default"/>
<dependency org="com.oracle" name="ojdbc6" rev="11.2.0.3" conf="build->default"/>
<!-- dependencies solely for testing purposes (none-deployed) -->
<dependency org="junit" name="junit" rev="4.10" conf="test->default"/>
</dependencies>
And that is the ant build.xml (I left out unnecessary lines to keep it more compact):
<?xml version="1.0" encoding="ISO-8859-1"?>
<property name="src_base" location="src/main" />
<property name="src" location="${src_base}/java" />
<property name="config" location="${src_base}/config" />
<property name="resource" location="${src_base}/resource" />
<property name="build" location="build" />
<property name="buildSrc" location="${build}/main" />
<property name="lib" location="${build}/lib" />
<property name="dist" location="dist" />
<property name="distName" value="isac3-core-lib" />
<property name="distFileName" value="${distName}-${build.timestamp}.jar" />
<property name="zipFileName" value="${distName}-${build.timestamp}.zip" />
<property name="test.src" location="src/test/java" />
<property name="test.build" location="build/test" />
<property name="test.reports" location="build/report/test" />
<property name="ant.build.javac.source" value="1.7" />
<!-- Source-level version number -->
<property name="ant.build.javac.target" value="1.7" />
<!-- Class-compatibility version number -->
<property name="build.compiler" value="modern" />
...
<!-- =================================
target: init
================================= -->
<target name="init" depends="clean">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
<mkdir dir="${buildSrc}" />
<mkdir dir="${lib}" />
<mkdir dir="${dist}" />
<mkdir dir="${test.build}" />
<mkdir dir="${test.reports}" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="init" description="retrieve dependencies with ivy">
<ivy:retrieve pattern="${lib}/[conf]/[artifact].[ext]" />
</target>
...
The error happens in the ant target 'resolve'. Ivy seems to be loaded an the settings file is also used as expected. But as already mentioned I get that syntax error.
Has anyone seen this before and can give me a hint?
Regards,
Sebastian
I copied your work and I had the same error, but not in German ;)
Anyway, I tried putting the conflict tag at the end and it worked.
so now it looks like this:
<dependencies>
... all dependencies
<!-- dependencies solely for testing purposes (none-deployed) -->
<dependency org="junit" name="junit" rev="4.10" conf="test->default"/>
<conflict org="org.slf4j" rev="1.5.6" />
</dependencies>
Another thing, it might be a copy-paste mistake, but you have to make sure ivy.xml file ends with
</ivy-module>.
Let us know.
I'm trying to configure sl4j/logback under Weblogic12.
I deploy ear file, which has war file, which has WEB-INF\classes\logback.xml
Here is the config:
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
My code to log :
private static final Logger logger = LoggerFactory.getLogger(FrontEndServlet.class);
//......
logger.info("info test");
logger.debug("debug test");
logger.error("error test");
What I see in the standart output is :
ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
INFO: info test
ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
SEVERE: error test
So, it looks like config file is not picked up.
What am I doing wrong?
The problem is discussed here in detail: https://stagingthinking.wordpress.com/2012/06/02/annoying-slf4j-problem-in-weblogic-server-12c/
The exact package you need to put to the prefer-application-packages mechanism is org.slf4j, like this:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-application>
<prefer-application-packages>
<package-name>org.slf4j</package-name>
</prefer-application-packages>
</weblogic-application>
Note: Also this question is already answered, I want to add that you should also add prefer-application-resources.
Answer: Add a file called META-INF/weblogic-application.xml to your ear, containing both prefer-application-packages and prefer-application-resources!
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application
xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.5/weblogic-application.xsd"
version="6">
<!-- http://www.torsten-horn.de/techdocs/jee-oracleweblogic.htm -->
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
<!-- if not using prefer-application-resources you will get a warning like this: -->
<!-- Class path contains multiple SLF4J bindings -->
<!-- SLF4J: Found binding in [jar:file:/C:/wls1211/modules/org.slf4j.jdk14_1.6.1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] -->
<prefer-application-resources>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
</prefer-application-resources>
</weblogic-application>
The problem was - sl4j did not pick up logback and used Weblogic's slf4j-jdk logging instead. Can be fixed with Weblogic's config weblogic-application.xml, option prefer-application-packages
Alternatively or if you have problems with more than just slf4j, you could use
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
Instead of
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
Source: Oracle
Environment: Weblogic 12.2.1
Logging Framework : Slf4j and Logback
Requirement : Log to a file of my choosing (per application) as well as Weblogic server logs
Using the <prefer-application-packages/> or <prefer-web-inf-classes> in weblogic.xml did not satisfy the requirement. In my testing, using one or the other tags (you can't use both) will result in the application logback.xml to be picked up and logging will go to the file defined in logback.xml. However, the typical STDOUT defintion using logback's ConsoleAppender will not log to the server logs.
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
Removing the following from weblogic.xml
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
will result in using the bundled SLF4j binding, which in Weblogic 12.2.1, is Java Util logging. In this case, log statements will go to the server logs and not to the file definition in the application level logback.xml. In my research, it appears at one time, some version of Weblogic 12 allowed the internal SLF4j to be bound to Log4j but was removed in one of the minor releases. This was my case; I did not have the option of enabling Log4j as the primary logging Framework in Weblogic through the Admin console. I am fairly sure this wouldn't have helped me, but I did want to note it because several documents I read indicated this would be available.
After much research and fighting configuration with weblogic.xml, configuration of POM (exclusions etc) and trying to use different bindings and bridges, I was unable to achieve the logging configuration that I wanted. It appears that Weblogic's slf4j is bound to Java utility logging, for better or worse. If you choose your own implementation of slf4j and binding (in my case Logback), there is no way that I could find to route those messages to Weblogic server logs through configuration. There can only be one binding in slf4j, and although many frameworks can be routed to that one binding, (I found this diagram useful) Weblogic 12.2.1 only employs Java util logging binding, there is no way to (at the application configuration level) to wire Weblogic to use the Logback binding that you provide to log to its server logs. There might be some way to use log4j and bridges to accomplish this, but for me that's entirely too much bloat and configuration to accomplish a simple logging task.
Giving up on trying to conquer this by configuration, I decided to simply write my own logback appender that translates a logging event into a JUL logging event. I replaced the standard STDOUT definition seen in many Logback examples with my own implementation of Logback's AppenderBase. At this point I can now log using per application logging configuration and also log to the Weblogic Server log.
Relevant POM Dependencies:
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
weblogic.xml (Note here that Hibernate comes with JbossLogging which will bridge to slf4j automatically)
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/2.0/weblogic-web-app.xsd">
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<debug>true</debug>
</jsp-descriptor>
<context-root>YourContextRoot</context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>ch.qos.logback.*</wls:package-name>
<wls:package-name>org.jboss.logging.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>org/slf4j/impl/StaticLoggerBinder.class</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
Logback AppenderBase implementation
import java.util.logging.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
public class WeblogicAppender extends AppenderBase<ILoggingEvent> {
private final Logger logger = Logger.getLogger(WeblogicAppender.class.getName());
ILoggingEvent event = null;
#Override
protected void append(ILoggingEvent event) {
this.event = event;
logger.log(getJULLevel(), event.getFormattedMessage());
}
private java.util.logging.Level getJULLevel() {
if (this.event == null) {
return java.util.logging.Level.SEVERE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.ALL) {
return java.util.logging.Level.ALL;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.DEBUG) {
return java.util.logging.Level.FINE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.ERROR) {
return java.util.logging.Level.SEVERE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.INFO) {
return java.util.logging.Level.INFO;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.TRACE) {
return java.util.logging.Level.FINEST;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.WARN) {
return java.util.logging.Level.WARNING;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.OFF) {
return java.util.logging.Level.OFF;
} else {
return java.util.logging.Level.INFO;
}
}
}
Logback.xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="com.your.package.WeblogicAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger: LineNumber:%L - %message%n</pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>yourlog.log
</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>yourlog.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>25MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger: LineNumber:%L - %message%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
Hopefully I can save others some of the pain that I went through trying to get this working the way I wanted.