问:
java.lang.reflect.InvocationTargetException when using Hibernate to get data from a database
I am testing JavaFX in combination with Hibernate. I want to take user input over a textfield to get a name from the actor table in the sakila database. But every time I try to execute the query, the following errors occur:

```<code>Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
    at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8792)
    at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
    at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
    at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3897)
    at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1878)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2623)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
    at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:557)
    at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:943)
    at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1854)
    ... 44 more
Caused by: javax.persistence.PersistenceException: Unable to locate persistence units
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:85)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
    at java.persistence@2.2/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at java.persistence@2.2/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at com.example.demo/com.example.demo.ActorEntity.getActorName(ActorEntity.java:71)
    at com.example.demo/com.example.demo.HelloController.search(HelloController.java:24)
    ... 55 more
Caused by: java.lang.IllegalArgumentException: Unrecognized JPA persistence.xml XSD version : `3.0`
    at org.hibernate.boot.xsd.ConfigXsdSupport.jpaXsd(ConfigXsdSupport.java:52)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.validate(PersistenceXmlParser.java:474)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl(PersistenceXmlParser.java:446)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:249)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:240)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.doResolve(PersistenceXmlParser.java:234)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.locatePersistenceUnits(PersistenceXmlParser.java:68)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:81)
    ... 61 more
</code>```

this is my persistence.xml:

`

```<code>  <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
  <class>com.example.demo.ActorEntity</class>
  <class>com.example.demo.AddressEntity</class>
  <class>com.example.demo.CategoryEntity</class>
  <class>com.example.demo.CityEntity</class>
  <class>com.example.demo.CountryEntity</class>
  <class>com.example.demo.CustomerEntity</class>
  <class>com.example.demo.FilmEntity</class>
  <class>com.example.demo.FilmActorEntity</class>
  <class>com.example.demo.FilmCategoryEntity</class>
  <class>com.example.demo.FilmTextEntity</class>
  <class>com.example.demo.InventoryEntity</class>
  <class>com.example.demo.LanguageEntity</class>
  <class>com.example.demo.PaymentEntity</class>
  <class>com.example.demo.RentalEntity</class>
  <class>com.example.demo.StaffEntity</class>
  <class>com.example.demo.StoreEntity</class>
  <class>com.example.demo.ActorInfoEntity</class>
  <class>com.example.demo.CustomerListEntity</class>
  <class>com.example.demo.FilmListEntity</class>
  <class>com.example.demo.NicerButSlowerFilmListEntity</class>
  <class>com.example.demo.SalesByFilmCategoryEntity</class>
  <class>com.example.demo.SalesByStoreEntity</class>
  <class>com.example.demo.StaffListEntity</class>
  <properties>
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/Sakila"/>
      <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
      <property name="hibernate.connection.username" value="root"/>
      <property name="hibernate.connection.password" value="ß§%Y-Sn_ß-DF/n-/%D5-m274-§_9s%"/>
  </properties>
</code>```

`

my hibernate.cfg.xml : `

```<code><?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url"/>
    <property name="connection.driver_class"/>
    <!-- <property name="connection.username"/> -->
    <!-- <property name="connection.password"/> -->

    <!-- DB schema will be updated if needed -->
    <!-- <property name="hibernate.hbm2ddl.auto">update</property> -->
  </session-factory>
</hibernate-configuration>
</code>```

the method that returns the query result:

```<code>public String getActorName(String id) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("default");
        EntityManager em = emf.createEntityManager();
        String query = "SELECT first_name, last_name from actor where actor_id =" + id;
        Query actorQuery = em.createNativeQuery(query);
        List<String[]> actorName = actorQuery.getResultList();
        String result = actorName.get(0)[0] + " " + actorName.get(0)[1];
        return result;
    }
}
</code>```

Body:
I am testing JavaFX in combination with Hibernate. I want to take user input over a textfield to get a name from the actor table in the sakila database. But every time I try to execute the query, the following errors occur:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
    at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8792)
    at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
    at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
    at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3897)
    at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1878)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2623)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
    at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:557)
    at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:943)
    at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1854)
    ... 44 more
Caused by: javax.persistence.PersistenceException: Unable to locate persistence units
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:85)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
    at java.persistence@2.2/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at java.persistence@2.2/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at com.example.demo/com.example.demo.ActorEntity.getActorName(ActorEntity.java:71)
    at com.example.demo/com.example.demo.HelloController.search(HelloController.java:24)
    ... 55 more
Caused by: java.lang.IllegalArgumentException: Unrecognized JPA persistence.xml XSD version : `3.0`
    at org.hibernate.boot.xsd.ConfigXsdSupport.jpaXsd(ConfigXsdSupport.java:52)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.validate(PersistenceXmlParser.java:474)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl(PersistenceXmlParser.java:446)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:249)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:240)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.doResolve(PersistenceXmlParser.java:234)
    at org.hibernate.jpa.boot.internal.PersistenceXmlParser.locatePersistenceUnits(PersistenceXmlParser.java:68)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:81)
    ... 61 more

this is my persistence.xml:

`

  <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
  <class>com.example.demo.ActorEntity</class>
  <class>com.example.demo.AddressEntity</class>
  <class>com.example.demo.CategoryEntity</class>
  <class>com.example.demo.CityEntity</class>
  <class>com.example.demo.CountryEntity</class>
  <class>com.example.demo.CustomerEntity</class>
  <class>com.example.demo.FilmEntity</class>
  <class>com.example.demo.FilmActorEntity</class>
  <class>com.example.demo.FilmCategoryEntity</class>
  <class>com.example.demo.FilmTextEntity</class>
  <class>com.example.demo.InventoryEntity</class>
  <class>com.example.demo.LanguageEntity</class>
  <class>com.example.demo.PaymentEntity</class>
  <class>com.example.demo.RentalEntity</class>
  <class>com.example.demo.StaffEntity</class>
  <class>com.example.demo.StoreEntity</class>
  <class>com.example.demo.ActorInfoEntity</class>
  <class>com.example.demo.CustomerListEntity</class>
  <class>com.example.demo.FilmListEntity</class>
  <class>com.example.demo.NicerButSlowerFilmListEntity</class>
  <class>com.example.demo.SalesByFilmCategoryEntity</class>
  <class>com.example.demo.SalesByStoreEntity</class>
  <class>com.example.demo.StaffListEntity</class>
  <properties>
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/Sakila"/>
      <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
      <property name="hibernate.connection.username" value="root"/>
      <property name="hibernate.connection.password" value="ß§%Y-Sn_ß-DF/n-/%D5-m274-§_9s%"/>
  </properties>

`

my hibernate.cfg.xml : `

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url"/>
    <property name="connection.driver_class"/>

  </session-factory>
</hibernate-configuration>

the method that returns the query result:

public String getActorName(String id) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("default");
        EntityManager em = emf.createEntityManager();
        String query = "SELECT first_name, last_name from actor where actor_id =" + id;
        Query actorQuery = em.createNativeQuery(query);
        List<String[]> actorName = actorQuery.getResultList();
        String result = actorName.get(0)[0] + " " + actorName.get(0)[1];
        return result;
    }
}


来源: stackexchange

问:
UriFormatException getting caught in exception handler for ASP .Net Core
I've added exception handling to my Asp .Net Core application to log any unhandled exceptions. I am getting unhandled UriFormatExceptions within the middleware due to what appears to be traffic from various web crawlers targeting non-existent endpoints. I am not sure how to fix this, or at least elegantly silence it so it does not show up in my telemetry. In general, I'd like to ignore traffic hitting endpoints not defined by my application.

Exception logged

[Unhandled exception][UriString][https:///favicon.ico][Exception]
[System.UriFormatException: Invalid URI: The hostname could not be parsed.]

Stacktrace:

```<code>   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Microsoft.AspNet.OData.Routing.ODataPathRouteConstraint.Match(HttpContext httpContext, IRouter route, String routeKey, RouteValueDictionary values, RouteDirection routeDirection)
   at Microsoft.AspNetCore.Routing.RouteConstraintMatcher.Match(IDictionary`2 constraints, RouteValueDictionary routeValues, HttpContext httpContext, IRouter route, RouteDirection routeDirection, ILogger logger)
   at Microsoft.AspNetCore.Routing.RouteBase.RouteAsync(RouteContext context)
   at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)]
</code>```

Exception Handler

```<code>app.UseExceptionHandler(exceptionHandlerApp =>
{
    exceptionHandlerApp.Run(async context =>
    {
        context.Response.StatusCode = StatusCodes.Status500InternalServerError;
        IExceptionHandlerPathFeature exceptionHandlerPathFeature =
        context.Features.Get<IExceptionHandlerPathFeature>();

        string uriString = null;
        uriString = context.Request.GetEncodedUrl();

        Logger.EmitLog(
            "Unhandled exception",
            "UriString",
            uriString,
            "Exception",
            exceptionHandlerPathFeature?.Error);
    });
});
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I've added exception handling to my Asp .Net Core application to log any unhandled exceptions. I am getting unhandled UriFormatExceptions within the middleware due to what appears to be traffic from various web crawlers targeting non-existent endpoints. I am not sure how to fix this, or at least elegantly silence it so it does not show up in my telemetry. In general, I'd like to ignore traffic hitting endpoints not defined by my application.

Exception logged

[Unhandled exception][UriString][https:///favicon.ico][Exception]
[System.UriFormatException: Invalid URI: The hostname could not be parsed.]

Stacktrace:

   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Microsoft.AspNet.OData.Routing.ODataPathRouteConstraint.Match(HttpContext httpContext, IRouter route, String routeKey, RouteValueDictionary values, RouteDirection routeDirection)
   at Microsoft.AspNetCore.Routing.RouteConstraintMatcher.Match(IDictionary`2 constraints, RouteValueDictionary routeValues, HttpContext httpContext, IRouter route, RouteDirection routeDirection, ILogger logger)
   at Microsoft.AspNetCore.Routing.RouteBase.RouteAsync(RouteContext context)
   at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)]

Exception Handler

app.UseExceptionHandler(exceptionHandlerApp =>
{
    exceptionHandlerApp.Run(async context =>
    {
        context.Response.StatusCode = StatusCodes.Status500InternalServerError;
        IExceptionHandlerPathFeature exceptionHandlerPathFeature =
        context.Features.Get<IExceptionHandlerPathFeature>();

        string uriString = null;
        uriString = context.Request.GetEncodedUrl();

        Logger.EmitLog(
            "Unhandled exception",
            "UriString",
            uriString,
            "Exception",
            exceptionHandlerPathFeature?.Error);
    });
});


问:
How to enlarge a part of the figure and insert it on top of the same plot?
I would like to zoom a portion of data/image and plot it on top of the same figure.

I want to zoom in the shape all over the x-axis and from -3 to 15 in the y-axis.
And put the zoomed one on the top of original figure, with connect them to describe the zoomed area related to which area in original figure.

Also attached the full figure plot and a portion of it as images.

The full code for this graph is here

Matplotlib - how to break y-axis?


问:
Flutter Unexpected error, opens Heros.dart file
In my app there is 3 button.
Among them Login and Register button is working on onPressed but Settings Button (...) is not working. Once I click settings button I get this error.

Here is my Navigator code

```<code>ElevatedButton(
          style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) {
                  return const SettingsPage();
                },
              ),
            );
          },
          child: const Text(
            '...',
            style: TextStyle(fontSize: 25),
          ),
        ),
</code>```

This is my entire screen including emulator.

Here is my WelcomePage full code.

```<code>    import 'package:flutter/material.dart';
import 'package:test_app_2nd/login_page.dart';
import 'package:test_app_2nd/register_page.dart';
import 'package:test_app_2nd/settings.dart';

class WelcomePage extends StatefulWidget {
  const WelcomePage({super.key});

  @override
  State<WelcomePage> createState() => _WelcomePage();
}

class _WelcomePage extends State<WelcomePage> {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: Scaffold(
        appBar: AppBar(
          title: const Text('Welcome'),
          centerTitle: true,
          backgroundColor: Colors.red,
        ),
        backgroundColor: Colors.white,
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset('images/flame-sign-in.png'),
            const SizedBox(
              height: 35.0,
            ),
            const SizedBox(
              height: 30.0,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ElevatedButton(
                  style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
                  onPressed: () {
                    Navigator.of(context)
                        .push(MaterialPageRoute(builder: (context) {
                      return const LoginPage();
                    }));
                  },
                  child: const Text('Login'),
                ),
                const SizedBox(
                  width: 55.0,
                ),
                ElevatedButton(
                  style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (context) {
                          return const RegisterPage();
                        },
                      ),
                    );
                  },
                  child: const Text('Register'),
                ),
              ],
            ),
            const SizedBox(
              height: 35.0,
            ),
            ElevatedButton(
              style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) {
                      return const SettingsPage();
                    },
                  ),
                );
              },
              child: const Text(
                '...',
                style: TextStyle(fontSize: 25),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
</code>```

Here is my settings page full code:

```<code>    import 'package:flutter/material.dart';

class SettingsPage extends StatefulWidget {
  const SettingsPage({super.key});

  @override
  State<SettingsPage> createState() => _SettingsPageState();
}

String imagePath1 = 'images/flame-4.png';
String imagePath2 = 'images/flame-134.png';
String currentImagePath = imagePath1;

class _SettingsPageState extends State<SettingsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Settings'),
        actions: [
          FloatingActionButton(
            onPressed: () {},
            child: const Icon(
              Icons.add,
            ),
          ),
          const SizedBox(
            width: 5,
          ),
          FloatingActionButton(
            onPressed: () {},
            child: const Text(
              '...',
              style: TextStyle(fontSize: 20.0),
            ),
          )
        ],
      ),
      drawerEnableOpenDragGesture: false,
      backgroundColor: Colors.white,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                setState(() {
                  if (currentImagePath == imagePath1) {
                    currentImagePath = imagePath2;
                  } else {
                    currentImagePath = imagePath1;
                  }
                });
              },
              child: const Text('Click Me'),
            ),
            Image.asset(currentImagePath),
          ],
        ),
      ),
    );
  }
}
</code>```

Here is my error page screen shoot:

Body:
In my app there is 3 button.
Among them Login and Register button is working on onPressed but Settings Button (...) is not working. Once I click settings button I get this error.

Here is my Navigator code

ElevatedButton(
          style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) {
                  return const SettingsPage();
                },
              ),
            );
          },
          child: const Text(
            '...',
            style: TextStyle(fontSize: 25),
          ),
        ),

This is my entire screen including emulator.

Here is my WelcomePage full code.

    import 'package:flutter/material.dart';
import 'package:test_app_2nd/login_page.dart';
import 'package:test_app_2nd/register_page.dart';
import 'package:test_app_2nd/settings.dart';

class WelcomePage extends StatefulWidget {
  const WelcomePage({super.key});

  @override
  State<WelcomePage> createState() => _WelcomePage();
}

class _WelcomePage extends State<WelcomePage> {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: Scaffold(
        appBar: AppBar(
          title: const Text('Welcome'),
          centerTitle: true,
          backgroundColor: Colors.red,
        ),
        backgroundColor: Colors.white,
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset('images/flame-sign-in.png'),
            const SizedBox(
              height: 35.0,
            ),
            const SizedBox(
              height: 30.0,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ElevatedButton(
                  style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
                  onPressed: () {
                    Navigator.of(context)
                        .push(MaterialPageRoute(builder: (context) {
                      return const LoginPage();
                    }));
                  },
                  child: const Text('Login'),
                ),
                const SizedBox(
                  width: 55.0,
                ),
                ElevatedButton(
                  style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (context) {
                          return const RegisterPage();
                        },
                      ),
                    );
                  },
                  child: const Text('Register'),
                ),
              ],
            ),
            const SizedBox(
              height: 35.0,
            ),
            ElevatedButton(
              style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) {
                      return const SettingsPage();
                    },
                  ),
                );
              },
              child: const Text(
                '...',
                style: TextStyle(fontSize: 25),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Here is my settings page full code:

    import 'package:flutter/material.dart';

class SettingsPage extends StatefulWidget {
  const SettingsPage({super.key});

  @override
  State<SettingsPage> createState() => _SettingsPageState();
}

String imagePath1 = 'images/flame-4.png';
String imagePath2 = 'images/flame-134.png';
String currentImagePath = imagePath1;

class _SettingsPageState extends State<SettingsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Settings'),
        actions: [
          FloatingActionButton(
            onPressed: () {},
            child: const Icon(
              Icons.add,
            ),
          ),
          const SizedBox(
            width: 5,
          ),
          FloatingActionButton(
            onPressed: () {},
            child: const Text(
              '...',
              style: TextStyle(fontSize: 20.0),
            ),
          )
        ],
      ),
      drawerEnableOpenDragGesture: false,
      backgroundColor: Colors.white,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                setState(() {
                  if (currentImagePath == imagePath1) {
                    currentImagePath = imagePath2;
                  } else {
                    currentImagePath = imagePath1;
                  }
                });
              },
              child: const Text('Click Me'),
            ),
            Image.asset(currentImagePath),
          ],
        ),
      ),
    );
  }
}

Here is my error page screen shoot:


问:
Cannot GET /path on page reload in MERN app after heroku deployment
I deployed my mern app on heroku, when i click on different route, the page changes.However, when i reload the page, It shows 'Cannot GET /path/'. I have tried some answers on stack overflow but it was not working for me.

This is what i Have in my app.js file,

```<code>if (process.env.NODE_ENV === 'production') {
  app.use(express.static('client/build'));

  app.get('/', (req, res) => {
    let filePath = path.resolve(__dirname, 'client/build', 'index.html');

    res.sendFile(filePath);
  });
}
</code>```

One of the answers on stackOverflow recommended changing '/' to '/*' in app.get but when i tried it, I was able to reload the page but my api endpoints stop working.

```<code>if (process.env.NODE_ENV === 'production') {
      app.use(express.static('client/build'));

      app.get('/*', (req, res) => {
        let filePath = path.resolve(__dirname, 'client/build', 'index.html');

        res.sendFile(filePath);
      });
    }
</code>```

This is how i set up my routes

```<code>app.use('/api/v1/carers', carerRoutes);
app.use('/api/v1/task', taskRoutes)
</code>```

This is my folder structure, all the files is stored in 'server' folder, 'client' is the frontend

What am i doing wrongly? I need help, please

My react frontend route. N.B the admin route is nested. it has the 'carer' route within it.

```<code><Route path="admin/*"
            element={
              <ProtectedRoute
                isAllowed={!!currentUser && currentUser.role === 'admin'}
                redirectPath="/signin"
              >
                {' '}
                <AdminHomePage />
              </ProtectedRoute>
            }
          />

          <Route path="signin" element={<SignIn />} />
    </Routes>
</code>```

Body:
I deployed my mern app on heroku, when i click on different route, the page changes.However, when i reload the page, It shows 'Cannot GET /path/'. I have tried some answers on stack overflow but it was not working for me.

This is what i Have in my app.js file,

if (process.env.NODE_ENV === 'production') {
  app.use(express.static('client/build'));

  app.get('/', (req, res) => {
    let filePath = path.resolve(__dirname, 'client/build', 'index.html');

    res.sendFile(filePath);
  });
}

One of the answers on stackOverflow recommended changing '/' to '/*' in app.get but when i tried it, I was able to reload the page but my api endpoints stop working.

if (process.env.NODE_ENV === 'production') {
      app.use(express.static('client/build'));

      app.get('/*', (req, res) => {
        let filePath = path.resolve(__dirname, 'client/build', 'index.html');

        res.sendFile(filePath);
      });
    }

This is how i set up my routes

app.use('/api/v1/carers', carerRoutes);
app.use('/api/v1/task', taskRoutes)

This is my folder structure, all the files is stored in 'server' folder, 'client' is the frontend

What am i doing wrongly? I need help, please

My react frontend route. N.B the admin route is nested. it has the 'carer' route within it.

<Route path="admin/*"
            element={
              <ProtectedRoute
                isAllowed={!!currentUser && currentUser.role === 'admin'}
                redirectPath="/signin"
              >
                {' '}
                <AdminHomePage />
              </ProtectedRoute>
            }
          />

          <Route path="signin" element={<SignIn />} />
    </Routes>


问:
pass the value from form with autocomplete jquery to view in django
I made a form to send data to a view with a jquery autocomplete.

the url where the form is located

```<code>path('cherche/',MyView.as_view(), name='recherche'),

<form  method="GET" >
     {% csrf_token %}
           <label for="villeselect">Product</label>
    <input type="text"  name="name" id="villeselect" >
    <button type="submit">Go</button>
</form>
<script>
    $(function () {
        $("#villeselect").autocomplete({
            source: "{% url 'recherche' %}",
            minLength: 3
        });
    });
</script>
</code>```

the  view to manages this form and the autocomplete

```<code>class MyView(View):
model = VilleFrance
template_name = "ville_recherche.html"
context_object_name = 'myville'
def get(self, request):
    term = request.GET.get('term')
    if term:
        cible = list(VilleFrance.objects.filter(
            name__istartswith=request.GET.get('term')
        ).values_list('name', flat=True).order_by("name"))
        return JsonResponse(cible, safe=False)

    return render(request, 'ville/ville_recherche.html')
</code>```

how to pass the submit value to this details view. I tried but I can't find the solution

my question is what should i change in the url to display the value  on the same page as the form
and is it possible to also retrieve the id of the table in relation to the value passed by the form (the "name" column)?

thank

Body:
I made a form to send data to a view with a jquery autocomplete.

the url where the form is located

path('cherche/',MyView.as_view(), name='recherche'),

<form  method="GET" >
     {% csrf_token %}
           Product
    <input type="text"  name="name" id="villeselect" >
    <button type="submit">Go</button>
</form>

the  view to manages this form and the autocomplete

class MyView(View):
model = VilleFrance
template_name = "ville_recherche.html"
context_object_name = 'myville'
def get(self, request):
    term = request.GET.get('term')
    if term:
        cible = list(VilleFrance.objects.filter(
            name__istartswith=request.GET.get('term')
        ).values_list('name', flat=True).order_by("name"))
        return JsonResponse(cible, safe=False)

    return render(request, 'ville/ville_recherche.html')

how to pass the submit value to this details view. I tried but I can't find the solution

my question is what should i change in the url to display the value  on the same page as the form
and is it possible to also retrieve the id of the table in relation to the value passed by the form (the "name" column)?

thank


问:
is it optimal to create class instance of iterable using __iter__ and __next__ compared using a list instance attribute?
Intuitively, using __iter__ and __next__ seems likely to be significantly for efficient, but I curious of the technical specifics of why, and how one maybe go about benchmarking to measure and compare the space and runtime of these?

A common case I can think of is a Linked List,

The following is an implementation illustration the use of __iter__ and __next__:

I have tried various benchmarking tools without much success being able to generate data to more closely analyze they're internals; specifically, how exactly the magic methods function, and if they're truly as significantly more efficient as I surmise they are.

class Node(object):
    def __init__(self, value: int, next_node):
        self.value = value
        self.next = next_node

    def __repr__(self):
        return str(self.value)

class LinkedList(object):
    def __init__(self, head=None):
        self.head = None
        self._current = None

    def __repr__(self):
        return '<{} {}>'.format(type(self).__name__, self.head)

    def __iter__(self):
        self._current = self.head
        return self

    def __next__(self):
        if self._current is None:
            raise StopIteration
        current, self._current = self._current, self._current.next
        return current

    @property
    def is_empty(self):
        return self.head is None

    def prepend_node(self, valuetoadd: int):
        self.head = IntNode(valuetoadd, self.head)
```
<p>Compared to the following:</p>
<pre class="lang-py prettyprint-override"><code>class ListNode:
    """
    A node in a singly-linked list.
    """
    def __init__(self, data=None, next=None):
        self.data = data
        self.next = next

    def __repr__(self):
        return repr(self.data)

class SinglyLinkedList:
    def __init__(self):
        """
        Create a new singly-linked list.
        Takes O(1) time.
        """
        self.head = None

    def prepend(self, data):
        """
        Insert a new element at the beginning of the list.
        Takes O(1) time.
        """
        self.head = ListNode(data=data, next=self.head)

def find(self, key):
        """
        Search for the first element with `data` matching
        `key`. Return the element or `None` if not found.
        Takes O(n) time.
        """
        curr = self.head
        while curr and curr.data != key:
            curr = curr.next
        return curr  # Will be None if not found

    def remove(self, key):
        """
        Remove the first occurrence of `key` in the list.
        Takes O(n) time.
        """
        # Find the element and keep a
        # reference to the element preceding it
        curr = self.head
        prev = None
        while curr and curr.data != key:
            prev = curr
            curr = curr.next
        # Unlink it from the list
        if prev is None:
            self.head = curr.next
        elif curr:
            prev.next = curr.next
            curr.next = None
</code>```

Body:
Intuitively, using __iter__ and __next__ seems likely to be significantly for efficient, but I curious of the technical specifics of why, and how one maybe go about benchmarking to measure and compare the space and runtime of these?

A common case I can think of is a Linked List,

The following is an implementation illustration the use of __iter__ and __next__:

I have tried various benchmarking tools without much success being able to generate data to more closely analyze they're internals; specifically, how exactly the magic methods function, and if they're truly as significantly more efficient as I surmise they are.

class Node(object):
    def __init__(self, value: int, next_node):
        self.value = value
        self.next = next_node

    def __repr__(self):
        return str(self.value)

class LinkedList(object):
    def __init__(self, head=None):
        self.head = None
        self._current = None

    def __repr__(self):
        return '<{} {}>'.format(type(self).__name__, self.head)

    def __iter__(self):
        self._current = self.head
        return self

    def __next__(self):
        if self._current is None:
            raise StopIteration
        current, self._current = self._current, self._current.next
        return current

    @property
    def is_empty(self):
        return self.head is None

    def prepend_node(self, valuetoadd: int):
        self.head = IntNode(valuetoadd, self.head)

Compared to the following:

class ListNode:
    """
    A node in a singly-linked list.
    """
    def __init__(self, data=None, next=None):
        self.data = data
        self.next = next

    def __repr__(self):
        return repr(self.data)

class SinglyLinkedList:
    def __init__(self):
        """
        Create a new singly-linked list.
        Takes O(1) time.
        """
        self.head = None

    def prepend(self, data):
        """
        Insert a new element at the beginning of the list.
        Takes O(1) time.
        """
        self.head = ListNode(data=data, next=self.head)

def find(self, key):
        """
        Search for the first element with `data` matching
        `key`. Return the element or `None` if not found.
        Takes O(n) time.
        """
        curr = self.head
        while curr and curr.data != key:
            curr = curr.next
        return curr  # Will be None if not found

    def remove(self, key):
        """
        Remove the first occurrence of `key` in the list.
        Takes O(n) time.
        """
        # Find the element and keep a
        # reference to the element preceding it
        curr = self.head
        prev = None
        while curr and curr.data != key:
            prev = curr
            curr = curr.next
        # Unlink it from the list
        if prev is None:
            self.head = curr.next
        elif curr:
            prev.next = curr.next
            curr.next = None


问:
Django does not find the Urls.py in the app
I've been working with Django for 3 months but I haven't had anything like that until now. my thoughts are by '' at the beginning of the urlspattern to make the home template the main template

main urls.py

```<code>from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('inventory.urls')),
</code>```

app urls.py

```<code>from . import views
from django.urls import path

urlpatterns = [
    path('', views.home, name='home'),
    path('base/', views.BaseTemplateView.as_view(), name='base'),

    # Menu Item URLs
    path('menu/', views.MenuItemListView.as_view(), name='menu_item_list'),
    path('menu/<int:pk>/', views.MenuItemDetailView.as_view(), name='menu_item_detail'),
</code>```

views.py

```<code>def home(request):
    return render(request, 'home.html')

class BaseTemplateView(TemplateView):
    template_name = 'base.html'

class MenuItemListView(ListView):
    model = MenuItem
    template_name = 'menu_item_list.html'
    context_object_name = 'menu_items'

class MenuItemDetailView(DetailView):
    model = MenuItem
    template_name = 'menu_item_detail.html'
</code>```

settings.py

```<code>ROOT_URLCONF = 'djangodelights.urls'
TEMPLATE_DIR = os.path.join(BASE_DIR,"templates")

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'inventory.apps.InventoryConfig',
</code>```

I was expecting ,when a start the server e get the home.html template.no matter which path I enter manually, I always get the same message

```<code>Using the URLconf defined in djangodelights.urls, Django tried these URL patterns, in this order:

admin/
The current path, home, didn’t match any of these.
</code>```

Body:
I've been working with Django for 3 months but I haven't had anything like that until now. my thoughts are by '' at the beginning of the urlspattern to make the home template the main template

main urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('inventory.urls')),

app urls.py

from . import views
from django.urls import path

urlpatterns = [
    path('', views.home, name='home'),
    path('base/', views.BaseTemplateView.as_view(), name='base'),

    # Menu Item URLs
    path('menu/', views.MenuItemListView.as_view(), name='menu_item_list'),
    path('menu/<int:pk>/', views.MenuItemDetailView.as_view(), name='menu_item_detail'),

views.py

def home(request):
    return render(request, 'home.html')

class BaseTemplateView(TemplateView):
    template_name = 'base.html'

class MenuItemListView(ListView):
    model = MenuItem
    template_name = 'menu_item_list.html'
    context_object_name = 'menu_items'

class MenuItemDetailView(DetailView):
    model = MenuItem
    template_name = 'menu_item_detail.html'

settings.py

ROOT_URLCONF = 'djangodelights.urls'
TEMPLATE_DIR = os.path.join(BASE_DIR,"templates")

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'inventory.apps.InventoryConfig',

I was expecting ,when a start the server e get the home.html template.no matter which path I enter manually, I always get the same message

Using the URLconf defined in djangodelights.urls, Django tried these URL patterns, in this order:

admin/
The current path, home, didn’t match any of these.


问:
Django product count per category
Have below models

```<code>class TreatmentCategory(models.Model):
    name = models.CharField(max_length=255, unique=True)

    def __str__(self):
        return self.name

class Treatment(models.Model):
    unique_id = models.UUIDField('Unique Record ID', default=uuid.uuid4, editable=False)
    name = models.CharField('Treatment Name', max_length=255, db_index=True, unique=True)
    category = models.ForeignKey(TreatmentCategory, on_delete=models.PROTECT)
    duration = models.PositiveSmallIntegerField('Treatment Duration (min)')
    price = models.DecimalField('Treatment Cost', max_digits=9, decimal_places=2)
    description = models.TextField(null=True, blank=True)
    active = models.BooleanField(default=True)

    def __str__(self):
        return self.name

class Therapist(models.Model):
    day_options = [
        ("Off Day", "Off Day"),
        ("On Leave", "On Leave"),
        ("On Duty", "On Duty"),
    ]

    unique_id = models.UUIDField('Unique Record ID', default=uuid.uuid4, editable=False)
    name = models.CharField('Therapist Name', max_length=255)
    contact = models.CharField('Phone Number', max_length=12, blank=True, null=True)
    day_status = models.CharField(
        'Duty Status',
        max_length=255,
        choices=day_options,
        default='On Duty'
    )

    status = models.BooleanField(
        'Status of Therapist',
        default=True,
    )
    treatments = models.ManyToManyField(Treatment, related_name='therapists')

    def __str__(self):
        return self.name
</code>```

Would like to output all therapists and a total count of treatments per category they have records i.e each therapist may have different treatments per category thus they wont have same number of treatments

```<code>therapist1 | treatmentcategory1 (number of treatments)
           | treatmentcategory2 (number of treatments)
           | treatmentcategory3 (number of treatments)
therapist2 | treatmentcategory1 (number of treatments)
</code>```

My current code as below, its displaying therapists however, instead of treatmentcategories, it showing treatments

```<code>    category = (TreatmentCategory.objects.filter(treatment__active=True)
        .prefetch_related('treatment_set')
        .annotate(treatment_count=Count('treatment__name'))
    )
    queryset = (Therapist.objects.filter(status=True)
            .prefetch_related(
                Prefetch('mytreatments', queryset=category, to_attr='treatment_details')
            )
        )
</code>```

Testing category alone gives the list of treatmentcategories, treatment count and all treatments in each treatmentcategory.

Queryset returns the therapists and treatments only, no categories nor treatment count per category.

Kindly assist in refining/rewriting the queries to extract the data as per sample above.

Thanks in advance.

Title: Django product count per category

Body:
Have below models

class TreatmentCategory(models.Model):
    name = models.CharField(max_length=255, unique=True)

    def __str__(self):
        return self.name

class Treatment(models.Model):
    unique_id = models.UUIDField('Unique Record ID', default=uuid.uuid4, editable=False)
    name = models.CharField('Treatment Name', max_length=255, db_index=True, unique=True)
    category = models.ForeignKey(TreatmentCategory, on_delete=models.PROTECT)
    duration = models.PositiveSmallIntegerField('Treatment Duration (min)')
    price = models.DecimalField('Treatment Cost', max_digits=9, decimal_places=2)
    description = models.TextField(null=True, blank=True)
    active = models.BooleanField(default=True)

    def __str__(self):
        return self.name

class Therapist(models.Model):
    day_options = [
        ("Off Day", "Off Day"),
        ("On Leave", "On Leave"),
        ("On Duty", "On Duty"),
    ]

    unique_id = models.UUIDField('Unique Record ID', default=uuid.uuid4, editable=False)
    name = models.CharField('Therapist Name', max_length=255)
    contact = models.CharField('Phone Number', max_length=12, blank=True, null=True)
    day_status = models.CharField(
        'Duty Status',
        max_length=255,
        choices=day_options,
        default='On Duty'
    )

    status = models.BooleanField(
        'Status of Therapist',
        default=True,
    )
    treatments = models.ManyToManyField(Treatment, related_name='therapists')

    def __str__(self):
        return self.name

Would like to output all therapists and a total count of treatments per category they have records i.e each therapist may have different treatments per category thus they wont have same number of treatments

therapist1 | treatmentcategory1 (number of treatments)
           | treatmentcategory2 (number of treatments)
           | treatmentcategory3 (number of treatments)
therapist2 | treatmentcategory1 (number of treatments)

My current code as below, its displaying therapists however, instead of treatmentcategories, it showing treatments

    category = (TreatmentCategory.objects.filter(treatment__active=True)
        .prefetch_related('treatment_set')
        .annotate(treatment_count=Count('treatment__name'))
    )
    queryset = (Therapist.objects.filter(status=True)
            .prefetch_related(
                Prefetch('mytreatments', queryset=category, to_attr='treatment_details')
            )
        )

Testing category alone gives the list of treatmentcategories, treatment count and all treatments in each treatmentcategory.

Queryset returns the therapists and treatments only, no categories nor treatment count per category.

Kindly assist in refining/rewriting the queries to extract the data as per sample above.

Thanks in advance.


问:
Loop through pyshark's FileCapture object stops working
I am reading a pcap file I have acquired with tcpdump. The pcap file is ~500MB. I read the file with FileCapture() and then I want to loop through each packet to extract the TLS payload. When I create the FileCapture object I also use override_prefs={'tls.keylog_file': os.path.abspath('tlsKey') where tlsKey is the file with the master keys to decrypt the file. The decryption works just fine, I can extract all the information from each single packet. However, if I want to loop through each packet and extract some information, the loop stops working at the packet for which packet.number = 258. My file contains more than 258 packets. What is going on?

My code

```<code>import pyshark
import os
cap = pyshark.FileCapture('traffic.pcap')
for packet in cap:
    print(packet.number)
    if "IP" in packet:
        print(packet)
print('Finished')
</code>```

the last output I get is here. As you can see, the layer TLS does not get printed. Why?

Expected behavior

I would expect my script to print Finished at the end, but it doesn't. The for loop looks stuck. Since the pcap file is large I cannot attach it. Any explanation of what's happening?

Versions (please complete the following information):

OS: MacOS 13.1

pyshark version:  0.5.3

tshark version: TShark (Wireshark) 4.0.2 (v4.0.2-0-g415456d13370)

Body:
I am reading a pcap file I have acquired with tcpdump. The pcap file is ~500MB. I read the file with FileCapture() and then I want to loop through each packet to extract the TLS payload. When I create the FileCapture object I also use override_prefs={'tls.keylog_file': os.path.abspath('tlsKey') where tlsKey is the file with the master keys to decrypt the file. The decryption works just fine, I can extract all the information from each single packet. However, if I want to loop through each packet and extract some information, the loop stops working at the packet for which packet.number = 258. My file contains more than 258 packets. What is going on?

My code

import pyshark
import os
cap = pyshark.FileCapture('traffic.pcap')
for packet in cap:
    print(packet.number)
    if "IP" in packet:
        print(packet)
print('Finished')

the last output I get is here. As you can see, the layer TLS does not get printed. Why?

Expected behavior

I would expect my script to print Finished at the end, but it doesn't. The for loop looks stuck. Since the pcap file is large I cannot attach it. Any explanation of what's happening?

Versions (please complete the following information):

OS: MacOS 13.1

pyshark version:  0.5.3

tshark version: TShark (Wireshark) 4.0.2 (v4.0.2-0-g415456d13370)


问:
Trouble Deploying Grails Application After Upgrading to Ver. 5.1.2 in Tomcat Server
Not sure why I'm  getting this error while i deploy on tomcat server and i see its trying to find some yml file but i dont see any file on my code

I'm confused where to start trying various scenarios and still could not able to replicate the issue and solve it

```<code>ERROR --- [   NO_USER] [           main] org.apache.catalina.startup.HostConfig   : Error deploying web application archive [E:\Tomcat\webapps\smp##build-533.war]
java.lang.IllegalStateException: Error starting child
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1023)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1910)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:824)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1617)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:318)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
    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:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/smp##build-533]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
    ... 37 common frames omitted
Caused by: org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource 'file [E:\smp-config.yml]' via location 'E:\smp-config.yml' cannot be found
    at org.springframework.boot.context.config.ConfigDataResourceNotFoundException.withLocation(ConfigDataResourceNotFoundException.java:97)
    at org.springframework.boot.context.config.ConfigDataImporter.handle(ConfigDataImporter.java:145)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:136)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:240)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:227)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 38 common frames omitted

</code>```

I'm having trouble deploying application after upgrading to grails 5 from 3 made all the necessary config changes. I dont see any issue while running application locally but i see the error as above while deploying not sure what am missing.

Please help me in this

Body:
Not sure why I'm  getting this error while i deploy on tomcat server and i see its trying to find some yml file but i dont see any file on my code

I'm confused where to start trying various scenarios and still could not able to replicate the issue and solve it

ERROR --- [   NO_USER] [           main] org.apache.catalina.startup.HostConfig   : Error deploying web application archive [E:\Tomcat\webapps\smp##build-533.war]
java.lang.IllegalStateException: Error starting child
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1023)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1910)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:824)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1617)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:318)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
    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:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/smp##build-533]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
    ... 37 common frames omitted
Caused by: org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource 'file [E:\smp-config.yml]' via location 'E:\smp-config.yml' cannot be found
    at org.springframework.boot.context.config.ConfigDataResourceNotFoundException.withLocation(ConfigDataResourceNotFoundException.java:97)
    at org.springframework.boot.context.config.ConfigDataImporter.handle(ConfigDataImporter.java:145)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:136)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:240)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:227)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 38 common frames omitted

I'm having trouble deploying application after upgrading to grails 5 from 3 made all the necessary config changes. I dont see any issue while running application locally but i see the error as above while deploying not sure what am missing.

Please help me in this


问:
Extending a code completion (CompletionSourceProvider) for SQL Server Management Studio
Following this I was able to extend a tool menu with a command to SQL Server Management Studio 18 with Visual Studio 2022 and downgrading Microsoft.Visual Studio.SDK to version 15.

But the standard sample provided by Microsoft for to display statement completion does not work. No errors in debugging and also the SSMS error log seems to have no related errors.

My code is exactly the same as the walk-through just downgraded the default SDK package to version 15 (It worked in VS2022) and changed the solution to work with SSMS, and didn't do the job there, although the command extension steal works!

Even the simpler one to customize text view does not work either in SSMS.

I have seen samples and opensource projects that do different things in SSMS 18 but no one is about text completion. Can anyone help?


问:
Do all tests have to pass to get code coverage in Go?
I am using the -cover to collect coverage in my Go project. However, it seems that the tests have to be 100% success rate in order to get the coverage report. Is there any way I can get the coverage despite the failed tests?


问:
Creating a view that combines permissiongroups together to show which permissions a user has
I have a quistion regarding making a view.

I have 3 tables

users:

id

name

email

password

permissiongroups:

id

name

viewUsers (tiny int, 1 or 0)

updateUsers (tiny int, 1 or 0)

createUsers (tiny int, 1 or 0)

deleteUsers (tiny int, 1 or 0)

(many other perms) (tiny int, 1 or 0)

user_has_permissiongroups:

id

userId

permissiongroupId

userIdCreator

active

Now what I want is to make a single view that shows what permissions a user has. Say they have a group that can delete users (and all else as 0 (or false)), and another group that can create them (and all else as 0 (or false)), I want a combined row that shows both being a 1 (true) and everything else 0 (false).

Now what I need help with is the creation of the select statement as I have no idea where to begin. I will need to make something that groups by user.

```<code>SELECT *
FROM user_has_permissiongroups
LEFT JOIN permissiongroups
ON user_has_permissiongroups.permissiongroupId = permissiongroups.id
WHERE user_has_permissiongroups.active = 1
GROUP BY userId
</code>```

Now this gets me almost where I need to be, but it doesn't group the permissions together correctly yet. Does anyone know how I can best do this? Or is this not possible within sql, meaning I have to keep it in the software?

Desired output:

userId
viewUsers
updateUsers
createUsers
deleteUsers

1
1
1
1
1

2
1
0
0
0

With tables:
permissiongroups:

id
name
viewUsers
updateUsers
createUsers
deleteUsers

1
test1
1
0
0
0

2
test2
0
1
0
1

3
test3
0
1
1
0

user_has_permissiongroups:

id
userId
permissiongroupId
userIdCreator
active

1
1
1
3(not relevant)
1

2
1
2
3(not relevant)
1

3
1
3
3(not relevant)
1

4
2
1
3(not relevant)
1

Please note that there are many more permissions, it would be best if it were possible that it automatically takes all of them.

Regards
Dany

Body:
I have a quistion regarding making a view.

I have 3 tables

users:

id

name

email

password

permissiongroups:

id

name

viewUsers (tiny int, 1 or 0)

updateUsers (tiny int, 1 or 0)

createUsers (tiny int, 1 or 0)

deleteUsers (tiny int, 1 or 0)

(many other perms) (tiny int, 1 or 0)

user_has_permissiongroups:

id

userId

permissiongroupId

userIdCreator

active

Now what I want is to make a single view that shows what permissions a user has. Say they have a group that can delete users (and all else as 0 (or false)), and another group that can create them (and all else as 0 (or false)), I want a combined row that shows both being a 1 (true) and everything else 0 (false).

Now what I need help with is the creation of the select statement as I have no idea where to begin. I will need to make something that groups by user.

SELECT *
FROM user_has_permissiongroups
LEFT JOIN permissiongroups
ON user_has_permissiongroups.permissiongroupId = permissiongroups.id
WHERE user_has_permissiongroups.active = 1
GROUP BY userId

Now this gets me almost where I need to be, but it doesn't group the permissions together correctly yet. Does anyone know how I can best do this? Or is this not possible within sql, meaning I have to keep it in the software?

Desired output:

userId
viewUsers
updateUsers
createUsers
deleteUsers

1
1
1
1
1

2
1
0
0
0

With tables:
permissiongroups:

id
name
viewUsers
updateUsers
createUsers
deleteUsers

1
test1
1
0
0
0

2
test2
0
1
0
1

3
test3
0
1
1
0

user_has_permissiongroups:

id
userId
permissiongroupId
userIdCreator
active

1
1
1
3(not relevant)
1

2
1
2
3(not relevant)
1

3
1
3
3(not relevant)
1

4
2
1
3(not relevant)
1

Please note that there are many more permissions, it would be best if it were possible that it automatically takes all of them.

Regards
Dany


问:
I am creating react app from scratch with backpack react scripts. But it cannot create it
In the documentation it says.

The currently supported version of CRA by backpack-react-scripts is up to v3.4.1. Versions above this will not work.

As I am a beginner in it, I tried to see if it will work, but it stops in the middle of installing NPM modules finds errors and deletes the installed modules.

Here is the output of the errors in the terminal:

```<code>npm ERR! code 1` `npm ERR! path
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass` `npm ERR!
command failed` `npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node
scripts/build.js` `npm ERR! Building: C:\Program Files\nodejs\node.exe
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js
rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags=
--libsass_library=` `npm ERR! gyp info it worked if it ends with ok` `npm ERR!
gyp verb cli [` `npm ERR! gyp verb cli 'C:\Program Files\nodejs\node.exe',` `npm
ERR! gyp verb cli
'C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js',`
`npm ERR! gyp verb cli 'rebuild',` `npm ERR! gyp verb cli '--verbose',` `npm
ERR! gyp verb cli '--libsass_ext=',` `npm ERR! gyp verb cli
'--libsass_cflags=',` `npm ERR! gyp verb cli '--libsass_ldflags=',` `npm ERR!
gyp verb cli '--libsass_library='` `npm ERR! gyp verb cli ]` `npm ERR! gyp info
using node-gyp@8.4.1` `npm ERR! gyp info using node@18.0.0 | win32 | x64` `npm
ERR! gyp verb command rebuild []` `npm ERR! gyp verb command clean []` `npm ERR!
gyp verb clean removing "build" directory` `npm ERR! gyp verb command configure
[]` `npm ERR! gyp verb find Python Python is not set from command line or npm
configuration` `npm ERR! gyp verb find Python Python is not set from environment
variable PYTHON` `npm ERR! gyp verb find Python checking if "python3" can be
used` `npm ERR! gyp verb find Python - executing "python3" to get executable
path` `npm ERR! gyp verb find Python - "python3" is not in PATH or produced an
error` `npm ERR! gyp verb find Python checking if "python" can be used` `npm
ERR! gyp verb find Python - executing "python" to get executable path` `npm ERR!
gyp verb find Python - executable path is
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe"` `npm ERR!
gyp verb find Python - executing
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe" to get
version` `npm ERR! gyp verb find Python - version is "3.11.1"` `npm ERR! gyp
info find Python using Python version 3.11.1 found at
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe"` `npm ERR!
gyp verb get node dir no --target version specified, falling back to host node
version: 18.0.0` `npm ERR! gyp verb command install [ '18.0.0' ]` `npm ERR! gyp
verb install input version string "18.0.0"` `npm ERR! gyp verb install
installing version: 18.0.0` `npm ERR! gyp verb install --ensure was passed, so
won't reinstall if already installed` `npm ERR! gyp verb install version is
already installed, need to check "installVersion"` `npm ERR! gyp verb got
"installVersion" 9` `npm ERR! gyp verb needs "installVersion" 9` `npm ERR! gyp
verb install version is good` `npm ERR! gyp verb get node dir target node
version installed: 18.0.0` `npm ERR! gyp verb build dir attempting to create
"build" dir:
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass\build` `npm ERR!
gyp verb build dir "build" dir needed to be created? Yes` `npm ERR! gyp verb
find VS msvs_version not set from command line or npm config` `npm ERR! gyp verb
find VS VCINSTALLDIR not set, not running in VS Command Prompt` `npm ERR! gyp
verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try
re-running with '--loglevel silly' for more details` `npm ERR! gyp verb find VS
looking for Visual Studio 2015` `npm ERR! gyp verb find VS - not found` `npm
ERR! gyp verb find VS not looking for VS2013 as it is only supported up to
Node.js 8` `npm ERR! gyp ERR! find VS` `npm ERR! gyp ERR! find VS msvs_version
not set from command line or npm config` `npm ERR! gyp ERR! find VS VCINSTALLDIR
not set, not running in VS Command Prompt` `npm ERR! gyp ERR! find VS could not
use PowerShell to find Visual Studio 2017 or newer, try re-running with
'--loglevel silly' for more details` `npm ERR! gyp ERR! find VS looking for
Visual Studio 2015` `npm ERR! gyp ERR! find VS - not found` `npm ERR! gyp ERR!
find VS not looking for VS2013 as it is only supported up to Node.js 8` `npm
ERR! gyp ERR! find VS` `npm ERR! gyp ERR! find VS
**************************************************************` `npm ERR! gyp
ERR! find VS You need to install the latest version of Visual Studio` `npm ERR!
gyp ERR! find VS including the "Desktop development with C++" workload.` `npm
ERR! gyp ERR! find VS For more information consult the documentation at:` `npm
ERR! gyp ERR! find VS ``https://github.com/nodejs/node-gyp#on-windows` `npm ERR!
gyp ERR! find VS **************************************************************`
`npm ERR! gyp ERR! find VS` `npm ERR! gyp ERR! configure error` `npm ERR! gyp
ERR! stack Error: Could not find any Visual Studio installation to use` `npm
ERR! gyp ERR! stack at VisualStudioFinder.fail
(C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:122:47)`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:75:16`
`npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013
(C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:363:14)`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:71:14`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:384:16`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\util.js:54:7`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\util.js:33:16`
`npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:395:5)`
`npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)` `npm ERR!
gyp ERR! stack at maybeClose (node:internal/child_process:1090:16)` `npm ERR!
gyp ERR! stack at ChildProcess._handle.onexit
(node:internal/child_process:302:5)` `npm ERR! gyp ERR! System Windows_NT
10.0.19045` `npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe"
"C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js"
"rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags="
"--libsass_library="` `npm ERR! gyp ERR! cwd
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass` `npm ERR! gyp
ERR! node -v v18.0.0` `npm ERR! gyp ERR! node-gyp -v v8.4.1` `npm ERR! gyp ERR!
not ok` `` npm ERR! Build failed with error code: 1` `` `I am using this command
in the VScode terminal ` npx create-react-app@3.4.1 my-app
--scripts-version=@skyscanner/backpack-react-scripts --template
@skyscanner/backpack --use-npm
</code>```

Should I downgrade the version of CRA to v3.4.1? If so, how can I do it, as there is no package.json file that does not exist yet?

Body:
In the documentation it says.

The currently supported version of CRA by backpack-react-scripts is up to v3.4.1. Versions above this will not work.

As I am a beginner in it, I tried to see if it will work, but it stops in the middle of installing NPM modules finds errors and deletes the installed modules.

Here is the output of the errors in the terminal:

npm ERR! code 1` `npm ERR! path
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass` `npm ERR!
command failed` `npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node
scripts/build.js` `npm ERR! Building: C:\Program Files\nodejs\node.exe
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js
rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags=
--libsass_library=` `npm ERR! gyp info it worked if it ends with ok` `npm ERR!
gyp verb cli [` `npm ERR! gyp verb cli 'C:\Program Files\nodejs\node.exe',` `npm
ERR! gyp verb cli
'C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js',`
`npm ERR! gyp verb cli 'rebuild',` `npm ERR! gyp verb cli '--verbose',` `npm
ERR! gyp verb cli '--libsass_ext=',` `npm ERR! gyp verb cli
'--libsass_cflags=',` `npm ERR! gyp verb cli '--libsass_ldflags=',` `npm ERR!
gyp verb cli '--libsass_library='` `npm ERR! gyp verb cli ]` `npm ERR! gyp info
using node-gyp@8.4.1` `npm ERR! gyp info using node@18.0.0 | win32 | x64` `npm
ERR! gyp verb command rebuild []` `npm ERR! gyp verb command clean []` `npm ERR!
gyp verb clean removing "build" directory` `npm ERR! gyp verb command configure
[]` `npm ERR! gyp verb find Python Python is not set from command line or npm
configuration` `npm ERR! gyp verb find Python Python is not set from environment
variable PYTHON` `npm ERR! gyp verb find Python checking if "python3" can be
used` `npm ERR! gyp verb find Python - executing "python3" to get executable
path` `npm ERR! gyp verb find Python - "python3" is not in PATH or produced an
error` `npm ERR! gyp verb find Python checking if "python" can be used` `npm
ERR! gyp verb find Python - executing "python" to get executable path` `npm ERR!
gyp verb find Python - executable path is
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe"` `npm ERR!
gyp verb find Python - executing
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe" to get
version` `npm ERR! gyp verb find Python - version is "3.11.1"` `npm ERR! gyp
info find Python using Python version 3.11.1 found at
"C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe"` `npm ERR!
gyp verb get node dir no --target version specified, falling back to host node
version: 18.0.0` `npm ERR! gyp verb command install [ '18.0.0' ]` `npm ERR! gyp
verb install input version string "18.0.0"` `npm ERR! gyp verb install
installing version: 18.0.0` `npm ERR! gyp verb install --ensure was passed, so
won't reinstall if already installed` `npm ERR! gyp verb install version is
already installed, need to check "installVersion"` `npm ERR! gyp verb got
"installVersion" 9` `npm ERR! gyp verb needs "installVersion" 9` `npm ERR! gyp
verb install version is good` `npm ERR! gyp verb get node dir target node
version installed: 18.0.0` `npm ERR! gyp verb build dir attempting to create
"build" dir:
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass\build` `npm ERR!
gyp verb build dir "build" dir needed to be created? Yes` `npm ERR! gyp verb
find VS msvs_version not set from command line or npm config` `npm ERR! gyp verb
find VS VCINSTALLDIR not set, not running in VS Command Prompt` `npm ERR! gyp
verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try
re-running with '--loglevel silly' for more details` `npm ERR! gyp verb find VS
looking for Visual Studio 2015` `npm ERR! gyp verb find VS - not found` `npm
ERR! gyp verb find VS not looking for VS2013 as it is only supported up to
Node.js 8` `npm ERR! gyp ERR! find VS` `npm ERR! gyp ERR! find VS msvs_version
not set from command line or npm config` `npm ERR! gyp ERR! find VS VCINSTALLDIR
not set, not running in VS Command Prompt` `npm ERR! gyp ERR! find VS could not
use PowerShell to find Visual Studio 2017 or newer, try re-running with
'--loglevel silly' for more details` `npm ERR! gyp ERR! find VS looking for
Visual Studio 2015` `npm ERR! gyp ERR! find VS - not found` `npm ERR! gyp ERR!
find VS not looking for VS2013 as it is only supported up to Node.js 8` `npm
ERR! gyp ERR! find VS` `npm ERR! gyp ERR! find VS
**************************************************************` `npm ERR! gyp
ERR! find VS You need to install the latest version of Visual Studio` `npm ERR!
gyp ERR! find VS including the "Desktop development with C++" workload.` `npm
ERR! gyp ERR! find VS For more information consult the documentation at:` `npm
ERR! gyp ERR! find VS ``https://github.com/nodejs/node-gyp#on-windows` `npm ERR!
gyp ERR! find VS **************************************************************`
`npm ERR! gyp ERR! find VS` `npm ERR! gyp ERR! configure error` `npm ERR! gyp
ERR! stack Error: Could not find any Visual Studio installation to use` `npm
ERR! gyp ERR! stack at VisualStudioFinder.fail
(C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:122:47)`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:75:16`
`npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013
(C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:363:14)`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:71:14`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\find-visualstudio.js:384:16`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\util.js:54:7`
`npm ERR! gyp ERR! stack at
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\lib\util.js:33:16`
`npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:395:5)`
`npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)` `npm ERR!
gyp ERR! stack at maybeClose (node:internal/child_process:1090:16)` `npm ERR!
gyp ERR! stack at ChildProcess._handle.onexit
(node:internal/child_process:302:5)` `npm ERR! gyp ERR! System Windows_NT
10.0.19045` `npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe"
"C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-gyp\bin\node-gyp.js"
"rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags="
"--libsass_library="` `npm ERR! gyp ERR! cwd
C:\Users\user\Desktop\DEV\Forage\my-app\node_modules\node-sass` `npm ERR! gyp
ERR! node -v v18.0.0` `npm ERR! gyp ERR! node-gyp -v v8.4.1` `npm ERR! gyp ERR!
not ok` `` npm ERR! Build failed with error code: 1` `` `I am using this command
in the VScode terminal ` npx create-react-app@3.4.1 my-app
--scripts-version=@skyscanner/backpack-react-scripts --template
@skyscanner/backpack --use-npm

Should I downgrade the version of CRA to v3.4.1? If so, how can I do it, as there is no package.json file that does not exist yet?