当前位置: 首页 > 知识库问答 >
问题:

JAVA朗。反思。示例Struts2 spring4中的InvocationTargetException。1 jpa/hibernate3。1.6

吕飞翼
2023-03-14

我正试图开发一个具有教学目的的基本应用程序,使用Struts 2 Spring 4.1 JPA/Hibernate 3.6和Netbeans 8作为IDE。我成功地创建和更新了用户,但当我尝试登录时,我得到了java。朗。反思。InvocationTargetException,特别是在本说明中:

Query query = entityManager.createQuery(
           "from User where username = :username")
           .setParameter("username", username); 

将创建数据库,并在每个表中包含两条记录。

我将非常感谢任何关于为什么这会发生在我身上的帮助。

以下是我正在使用的库的列表:

  • Struts2 2.3.16-asm-3.3.jar
  • Struts2 2.3.16-asm-commons-3.3.jar
  • Struts2 2.3.16-asm-tree-3.3.jar
  • Struts2 2.3.16-commons-fileupload-1.3.1.jar
  • Struts2 2.3.16-commons-io-2.2.jar
  • Struts2 2.3.16-commons-lang3-3.1.jar
  • Struts2 2.3.16-freemarker-2.3.19.jar
  • Struts2 2.3.16-jav辅助-3.11.0。GA. jar
  • Struts2 2.3.16-ognl-3.0.6.jar
  • Struts2 2.3.16-struts2-core-2.3.16.3.jar
  • Struts2 2.3.16-xwork-core-2.3.16.3.jar
  • Struts2 2.3.16-antlr-2.7.2.jar
  • Struts2 2.3.16-commons-collections-3.1.jar
  • Struts2 2.3.16-commons-logging-1.1.3.jar
  • Struts2 2.3.16-commons-logging-api.1.1.jar
  • Struts2 2.3.16-json-lib-2.3-jdk15.jar
  • Struts2 2.3.16-aopalliance-1.0.jar
  • Struts2 2.3.16-struts2-spring-plugin-2.3.16.3.jar
  • Spring 4.1-sping-aop-4.1.0。发布. jar
  • Spring 4.1-Spring方面4.1.0。发布. jar
  • Spring4.1-Spring豆子-4.1.0。发布. jar
  • Spring 4.1-Spring上下文4.1.0。发布. jar
  • Spring 4.1-Spring上下文支持4.1.0。发布. jar
  • Spring4.1-Spring核心4.1.0。发布. jar
  • Spring 4.1-Spring表达式4.1.0。发布. jar
  • Spring4.1-Spring-仪器-4.1.0。发布. jar
  • Spring4.1-Spring-仪器-tomcat-4.1.0。发布. jar
  • Spring 4.1-Spring-jdbc-4.1.0。发布. jar
  • Spring 4.1-Spring jms-4.1.0。发布. jar
  • Spring 4.1-Spring消息传递-4.1.0。发布. jar
  • Spring 4.1-sping-orm-4.1.0。发布. jar
  • Spring 4.1-Spring-oxm-4.1.0。发布. jar
  • Spring 4.1-Spring test-4.1.0。发布. jar
  • Spring 4.1-Spring-tx-4.1.0。发布. jar
  • Spring 4.1-Spring web 4.1.0。发布. jar
  • Spring 4.1-Spring-webmvc-4.1.0。发布. jar
  • Spring 4.1-Spring-webmvc-portlet-4.1.0。发布. jar
  • Spring 4.1-Spring-webSocket-4.1.0。发布. jar
  • Spring4.1-org-apache-commons-logging.jar
  • Spring4.1-cglib-2.2.jar
  • MySQL JDBC驱动-mysql-connector-java-5.1.23-bin.jar
  • Hibernate 4.3.6-antlr-2.7.7. jar
  • Hibernate 4.3.6-dom4j-1.6.1. jar
  • Hibernate4.3.6-Hibernate核心4.3.6。最终. jar
  • hibernate 4.3.6-hibernate-jpa-2.1-api-1.0.0。最终. jar
  • Hibernate4.3.6-jandex-1.1.0。最终. jar
  • Hibernate 4.3.6-jav辅助-3.18.1-GA. jar
  • Hibernate 4.3.6-jboss日志记录-3.1.3。GA. jar
  • Hibernate 4.3.6-jboss日志记录注释-1.2.0。bt. jar
  • Hibernate 4.3.6-jboss-transaction-ap_12_spec-1.0.0。最终. jar
  • Hibernate4.3.6-Hibernate实体管理器4.3.6。最终. jar

网状物xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <filter>
        <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

应用程序上下文。xml

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

    <bean id="portfolioService" class="portfolio.utils.PortfolioServiceJPAImpl"></bean>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="database" value="MYSQL" />
                <property name="showSql" value="true" />
            </bean>
        </property>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.gjt.mm.mysql.Driver" />
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/portfolio" />
        <property name="username" value="root" />
        <property name="password" value="" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />
</beans>

struts.xml

<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN""http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    <package name="default" extends="struts-default">
        <action name="Login" class="portfolio.Login">
            <result type="redirectAction">
                <param name="actionName">AdminPortfolio</param>
            </result>
            <result name="input">index.jsp</result>
        </action>
        <action name="AdminPortfolio">
            <result>admin.jsp</result>
        </action>
    </package>
</struts>

登录。JAVA

package portfolio;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import portfolio.utils.PortfolioServiceInterface;
import portfolio.utils.User;

public class Login extends ActionSupport {

    public Login() {
    }

    @Override
    public String execute() throws Exception {
        User user = getPortfolioService().authenticateUser(getUsername(), getPassword());
        if (user == null) {
            /* User not valid, return to input page. */
            return INPUT;
        } else {
            session.put("user", user);
        }

        return SUCCESS;
    }

    private String username;
    private String password;
    private Map session;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public void validate() {
        /* Check that fields are not empty */
        if (getPassword().length() == 0) {
            addFieldError("password", getText("password.required"));
        }
        if (getUsername().length() == 0) {
            addFieldError("username", getText("username.required"));
        }
    }

    /*
     * Field with getter and setter for PortfolioService object, which will be injected
     * via Spring.  
     */
    PortfolioServiceInterface portfolioService;

    public PortfolioServiceInterface getPortfolioService() {
        return portfolioService;
    }

    public void setPortfolioService(PortfolioServiceInterface portfolioService) {
        this.portfolioService = portfolioService;
    }

    public void setSession(Map session) {
        this.session = session;

    }
}

使用者JAVA

package portfolio.utils;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class User {
    private String username;
    private String password;
    private String firstName;
    private String lastName;
    private String email;

    @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "owner")
    private Set<Portfolio> portfolios = new HashSet<Portfolio>();

    @Id
    @GeneratedValue
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Set getPortfolios() {
        return portfolios;
    }

    public void setPortfolios(Set portfolios) {
        this.portfolios = portfolios;
    }

    public void addPortfolio(Portfolio portfolio) {
        portfolio.setOwner(this);
        portfolios.add(portfolio);
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}

文件夹JAVA

package portfolio.utils;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;

@Entity
public class Portfolio {
    private String name;

    @ManyToOne(targetEntity = portfolio.utils.User.class, optional = false)
    private User owner;

    @Id
    @GeneratedValue
    private Long id;

    @ElementCollection
    @JoinTable(name = "portfolio_image", joinColumns = @JoinColumn(name = "portfolio_id"))
    private Set<String> pics = new HashSet<String>();

    public Set getPics() {
        return pics;
    }

    public void setPics(Set pics) {
        this.pics = pics;
    }

    public void addPic(String pic) {
        pics.add(pic);
    }

    public Long getId() {
        return id;
    }

    private void setId(Long id) {
        this.id = id;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

PortfolioServiceJPAImpl。JAVA

package portfolio.utils;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

public class PortfolioServiceJPAImpl implements PortfolioServiceInterface {

    private EntityManager entityManager;

    @PersistenceContext
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    @Override
    public User authenticateUser(String username, String password) {
        System.out.println("Authenticating: username = " + username);
        User validUser = null;
        Query query = entityManager.createQuery("from User where username = :username").setParameter("username", username);
        List result = query.getResultList();
        if (!result.isEmpty()) {
            User user = (User) result.get(0);
            /* If the username mapped to a real user, check password */
            if (user != null && user.getPassword().equals(password)) {
                validUser = user;
            }
        }

        return validUser;
    }
}

Persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
    <persistence-unit name="punit">
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="none"/>
        </properties>
    </persistence-unit>
</persistence>

例外情况:

SEVERE [http-nio-8084-exec-6] org.apache.struts2.dispatcher.Dispatcher.error Exception occurred during processing request: null
 java.lang.reflect.InvocationTargetException
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:483)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:177)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Caused by: java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I
at org.hibernate.hql.internal.ast.HqlSqlWalker.generateNamedParameter(HqlSqlWalker.java:1023)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.parameter(HqlSqlBaseWalker.java:3396)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1351)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4686)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4159)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2104)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:796)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:597)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
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:483)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
at com.sun.proxy.$Proxy23.createQuery(Unknown Source)
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:483)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:289)
at com.sun.proxy.$Proxy23.createQuery(Unknown Source)
at portfolio.utils.PortfolioServiceJPAImpl.authenticateUser(PortfolioServiceJPAImpl.java:22)
at portfolio.Login.execute(Login.java:16)
... 77 more

共有1个答案

韩嘉祯
2023-03-14

已解决

多亏了安德里亚·利吉奥斯的评论,我才更好地理解了真正的例外,并在另一个问题上得到了解决。对不起,我把问题重复了一遍。我有两个版本的库“antlr”,只是删除了struts antlr库,只使用hibernate的antlr。

感谢所有用户的评论。

 类似资料:
  • 我想在我的javafx项目中尝试webview的功能,但我一直使用java。朗。反思。InvocationTargetException,所以我甚至尝试了jenkov的WebView示例代码。com,我仍然无法运行该应用程序。我的配置有什么问题吗?还是其他问题? 这是我得到的结果:

  • 在java8中,可以访问java类的字段。朗。反思。使用例如。 在java12(从java9开始?)这只返回一个空数组。这不会改变,即使 设置。 有什么办法可以做到这一点吗?(显然,这可能不是一个好主意,我希望在junit测试期间通过反射更改代码中的“static final”字段 )

  • 在运行测试时,我得到了错误,我无法理解为什么我会得到这个错误,这段代码在java 8中使用fine,而在java 17中运行它时,它给出了错误。谷歌搜索了这个错误,但没有发现任何有用的东西。请帮我理解这个错误。提前感谢:) 例外情况:

  • 问题内容: 谁能解释Java反射和自省的用法?什么时候需要同时使用? 问题答案: 反射(摘自[Oracle Java教程](http://docs.oracle.com/javase/tutorial/reflect/index.html)) 反射通常由需要检查或修改Java虚拟机中运行的应用程序的运行时行为的程序使用。这是一个相对高级的功能,只应由对语言基础有很深了解的开发人员使用。考虑到这一警

  • 我正在从事JavaFX项目,我创建了两个FXML文件,我想将另一个窗格加载到主窗格,即边框窗格。我想将另一个窗格加载到边框窗格中心区域! 这是我的项目的切入点,这是一个Java文件 之后,将显示显示“我的边框”窗格的主FXML文件 我设置了一个按钮,将特定窗格显示到边框窗格中心区域。 这是我的控制器类的边界窗格包含类 这是我想显示在边界窗格中心区域的FXML文件。 但是当我点击按钮,给我一堆错误!

  • 我试图理解TopCoder上的问题: 它特别指定 数组的长度为n. 每个元素都是介于1和k之间的整数,包括整数。 每当A和B是数组的两个连续元素(按此顺序)时,我们有(A 我的问题是关于第一个示例的第三个约束: 答案不应该是4吗?数组{2,1}发生了什么?有3个数组可以按照上述约束生成,但是thre也是可以生成的第四个数组,即{2,1}。问题的任何地方都写着,我们只能有唯一的数字组合。为什么我们不