I am seeing this log message when using the create-domain command with GlassFish 3.1.1
No domain initializers found, bypassing customization step
What can be accomplished with domain initializers? Is there any documentation?
Examples of create-domain usages with logging output is shown here,
http://docs.oracle.com/cd/E18930_01/html/821-2433/create-domain-1.html
The reference manual reports:
If domain customizers are found in JAR files in the as-install/modules
directory when the create-domain subcommand is run, the customizers
are processed. A domain customizer is a class that implements the
DomainInitializer interface.
I did found no documentation about customization but based on the source I can figure out that domain initializers are used to customize domain.xml during domain creation.
package org.glassfish.api.admin.config;
import org.jvnet.hk2.annotations.Contract;
import org.glassfish.api.admin.config.Container;
/**
* Marker interface to mark inhabitants that require some minimal initial
* configuration to be inserted into a newly create domain's domain.xml
*
* #author Nandini Ektare
*/
#Contract
public interface DomainInitializer {
/**
* The actual initial config that needs to be inserted into
* the fresh domain.xml
*
* See {#link Attribute#value()} for how the default value is inferred.
*
*/
public <T extends Container> T getInitialConfig(DomainContext initialCtx);
}
You can find source here.
the getInitialConfig method returns a Container instance. Container interface extends org.jvnet.hk2.config.ConfigBeanProxy interface that appears to be a proxy to Dom class:
/**
* Marker interface that signifies that the interface
* is meant to be used as a strongly-typed proxy to
* {#link Dom}.
*
* <p>
* To obtain the Dom object, use {#link Dom#unwrap(ConfigBeanProxy)}.
* This design allows the interfaces to be implemented by other code
* outside DOM more easily.
*
* #author Kohsuke Kawaguchi
* #see Dom#unwrap(ConfigBeanProxy)
* #see DuckTyped
* #see Element
* #see Attribute
*/
public interface ConfigBeanProxy {
I figure out that hk2 is the key to understand how domain customization works.
I hope someone else can give you some more useful info.
Related
I'm trying to migrate the extension pb_social to TYPO3 10 LTS but I'm stuck in the migration of the scheduler task that updates TYPO3 data from the social feeds.
I learned how to register a Symfony Console Command with the Services.yaml file so I can execute the command.
The problem is that the pb_social extension relies on Extbase same as its actual updateFeedDataCommand command.
So I tried to create a new command in the Symfony style and in its method execute() I instantiated:
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** #var PBSocialCommandController $controller */
$controller = $objectManager->get(PBSocialCommandController::class);
I already updated the properties of pb_social methods to use the new #TYPO3\CMS\Extbase\Annotation\Inject but still the injections seems not to work.
E.g. with:
/**
* #var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
* #TYPO3\CMS\Extbase\Annotation\Inject
*/
protected $configurationManager;
$this->configurationManager is null when used.
What could be the problem?
Soved using Method Injection
/**
* #param ConfigurationManager $configurationManager
*/
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
}
In my User.php I have the following Route:
/**
* #ORM\Table(name="app_users")
* #ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
But I get an error in my log file:
Authentication request failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationServiceException(code: 0): The \"App\\Entity\\User\" entity has a repositoryClass set to \"App\\Repository\\UserRepository\", but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with \"doctrine.repository_service\". at /Users/work/project/vendor/symfony/security/Core/Authentication/Provider/DaoAuthenticationProvider.php:85, RuntimeException(code: 0): The \"App\\Entity\\User\" entity has a repositoryClass set to \"App\\Repository\\UserRepository\", but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with \"doctrine.repository_service\". at /Users/work/project/vendor/doctrine/doctrine-bundle/Repository/ContainerRepositoryFactory.php:71)"} []
If App\Repository\UserRepository.php doesn't exist.
Either create a valid repository class there, or remove that annotation from the entity if you don't need one.
If the file does exist then perhaps the filename or class definition the the file has a typo, e.g. wrong capital somewhere.
I moved my code from :
/**
* #ORM\Entity(repositoryClass=ParcCarburantRepository::class)
*/
To :
/**
* #ORM\Entity(repositoryClass="App\Repository\ParcCarburantRepository")
*/
It works perfectly , sorry I don't know why .. but It works.
Change :
/**
* #ORM\Table(name="CommandeLigne")
* #ORM\Entity(repositoryClass="App\Repository\CommandeLigneRepository")
*/
To :
/**
* #ORM\Entity
* #ORM\Table(name="CommandeLigne")
* (repositoryClass="App\Repository\CommandeLigneRepository")
*/
I'm currently trying to set up the phpleague/oauth-server in a symfony 3.3 project. For that reason i want to specify the AuthorizationServer as service to be able to load it from the container (an not set up the whole thing everywhere its used).
To set the AuthorizationServer as service I need to inject multiple repositories as arguments.
This is the service definition for the AuthorizationServer:
app.oauth2.authorization_server:
class: League\OAuth2\Server\AuthorizationServer
arguments: ["#app.oauth2.client_repository", "#app.oauth2.access_token_repository", "#app.oauth2.scope_repository", "%oauth_private_key%", "%oauth_encryption_key%"]
configurator: "app.oauth2.authorization_server.configurator:configure"
The current definition of the repositories looks like this:
app.oauth2.client_repository:
class: Appbundle\Repository\OAuth2\ClientRepository
factory: 'doctrine.orm.entity_manager:getRepository'
arguments: [AppBundle\Entity\OAuth2\Client]
...
I tried many ways of defining the repositories as services but everytime i get the same error:
Type error: Argument 1 passed to League\\OAuth2\\Server\\AuthorizationServer::__construct() must be an instance of League\\OAuth2\\Server\\Repositories\\ClientRepositoryInterface, instance of Doctrine\\ORM\\EntityRepository given
This is how the ClientRepository looks like:
<?php
namespace AppBundle\Repository\OAuth2;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
class ClientRepository implements ClientRepositoryInterface
{
/**
* Get a client.
*
* #param string $clientIdentifier The client's identifier
* #param string $grantType The grant type used
* #param null|string $clientSecret The client's secret (if sent)
* #param bool $mustValidateSecret If true the client must attempt to validate the secret if the client
* is confidential
*
* #return ClientEntityInterface
*/
public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true)
{
// TODO: Implement getClientEntity() method.
}
}
Here are some other ways i tried to implement it:
https://matthiasnoback.nl/2014/05/inject-a-repository-instead-of-an-entity-manager/
How to configure dependency injection for repository class in symfony 3
Neither of them worked. Has any one of you an idea why the service definition of my repository is not accepted as valid input for the AuthorizationServer?
Yours,
FMK
I had tried to extend the EntityRepository but forgot to define the repository in the Entities. With the repositories extending the entityRepository and the ORM\Entity definition in the Entities it seems to work!
I am upgrading an application from Symfony 2.0 to Symfony 2.1, I followed this upgrade file and all works fine except that after a cache:clear I get an error when using some repositories. Here is the error:
[Semantical Error] The annotation "#ORM\Table" in class
edasiclinic\AlertesBundle\Repository\AlertesRepository was never imported. Did you maybe
forget to add a "use" statement for this annotation?
This is one example, I get this error with other repositories. I don't understand why I have to import #ORM\Table inside a repository file if I don't use annotation there.
Also if I wait for ~10 seconds and then refresh the browser, it works...
EDIT
This is the Entity:
<?php
namespace edasiclinic\DatabaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* edasiclinic\DatabaseBundle\Entity\Alertes
*
* #ORM\Table(name="alertes")
* #ORM\Entity(repositoryClass="edasiclinic\AlertesBundle\Repository\AlertesRepository")
* #ORM\HasLifecycleCallbacks()
*/
class Alertes
{
/**
* #var integer $id
*
* #ORM\Id
* #ORM\Column(name="idAlerta", type="integer")
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
...
}
And this the repository class:
<?php
namespace edasiclinic\AlertesBundle\Repository;
use Doctrine\ORM\EntityRepository;
use edasiclinic\DasiBundle\Funcions\AES;
class AlertesRepository extends EntityRepository
{
public function countUnread($user, $idioma, $fus)
{
// ...
}
}
Thanks
I had this very same problem today. the solution, after some googling, is apparently to include a comment block before the Repository class definition.
in your case:
/**
* AlertesRepository
*/
class AlertesRepository extends EntityRepository
{
...
}
without that comment block, you will receive the nonsensical error about "#ORM\Table". yet another Symfony/Doctrine oddity >_>
It was a PHP bug in versions prior to 5.3.8. From the symfony system requirements:
$this->addRecommendation(
version_compare($installedPhpVersion, '5.3.8', '>='),
'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156',
'Install PHP 5.3.8 or newer if your project uses annotations.'
);
See PHP bug #55156 for more details and possible workaround if you're unable to upgrade to a PHP version >= 5.3.8.
Looks like you forgot to add the use statement.
<?php
namespace Acme\MyBundle\Entity;
// Remember to include this use statement
use Doctrine\ORM\Mapping as ORM;
/**
* My Entity
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="Acme\MyBundle\Entity\MyEntityRepository")
*/
class MyEntity
{
}
For me it only hapens with certain versions of PHP and the solution was to put the Repository class in a folder above the folder of entity class
(I'm going to explain situation, incase someone knows of a better way to accomplice what I want to do).
Using Symfony2 + Behat + Symfony2Extension + Mink +
We have an application with multiple urls that will be visited during scenarios.
I do understand that you use the parameters sent in from the FeatureContext __construct method, but what I'm trying to do is set up the urls in the behat.yml file so that we can use them in our custom Context to visit the urls.
Looking at how the extensions work I have setup the dependency injection as follows:
class Extension implements ExtensionInterface
{
/**
* Loads a specific configuration.
*
* #param array $config Extension configuration hash (from behat.yml)
* #param ContainerBuilder $container ContainerBuilder instance
*/
public function load(array $config, ContainerBuilder $container)
{
$container->setParameter('url_one', $config['url_one']);
$container->setParameter('url_two', $config['url_two']);
}
/**
* Setups configuration for current extension.
*
* #param ArrayNodeDefinition $builder
*/
public function getConfig(ArrayNodeDefinition $builder)
{
$builder->
children()->
scalarNode('one_url')->
isRequired()->
end()->
scalarNode('two_url')->
isRequired()->
end()->
end();
}
code continues....
And my behat.yml looks like this:
default:
extensions:
Behat\MinkExtension\Extension:
goutte: ~
selenium2: ~
Behat\Symfony2Extension\Extension: ~
Acme\AcmeExtension\Extension:
url_one: 'http://example1.com'
url_two: 'http:/example2.com'
Now in my FeatureContext.php class I would like to do the following:
$url = $kernel->getContainer()->getParameter('url_one');
But this is not working, it is returning parameters from my Symfony2 application, which is expected since I have symfony2extension enabled. But I can not access the parameters or services from the extension class.
(Please note that if I'm in the Extension class in the load method and I call the parameter I just set it returns it, so I know it is set, but it must be set to a different container?)
First off is this possible? And if so what should I do to make it work.
Many thanks for any help.
Obviously, $kernel->getContainer() returns you container of the Symfony2 app kernel. Those kernel and container are not shared with Behat. Behat has its own container instance, which it uses to manage own services. Which means that extension is setting parameters inside Behat container, but you are attempting to access your app kernel container. That's why you have different results.
Now, the question is, how would you pass some value from your extension to context class. Answer is context initialiser. Check out:
https://github.com/Behat/MinkExtension/blob/master/src/Behat/MinkExtension/services/core.xml#L43-L47
https://github.com/Behat/MinkExtension/blob/master/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php#L26-L77