检索承载访问令牌时出现JPA错误

时间:2019-01-18 08:22:11

标签: apache oauth cxf openjpa

我正在使用Apache CXF实现对OAuth2.0的支持。我还使用OpenJPA来保留客户端和令牌。访问令牌已正确生成并存储。但是,当它们经过验证并且服务器尝试从数据库中检索令牌时,出现以下异常。我已经检查过,并且查询中设置的令牌值正确。令牌记录存在于表中。 JPA代码由CXF随附的JPA数据提供程序JPACodeDataProvider生成

有人知道是什么问题吗?

 <openjpa-3.0.0-r422266:1833209 nonfatal general error> org.apache.openjpa.pers
stence.PersistenceException: null
FailedObject: SELECT t FROM BearerAccessToken t WHERE t.tokenKey = :tokenKey [j
va.lang.String]
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:1029)
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:928)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManage
.java:1035)
        at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:
79)
        at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.
ava:2382)
        at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:
73)
        at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResul
Object(InstanceResultObjectProvider.java:59)
        at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.ja
a:35)
        at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1262)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1015)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:871)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:802)
        at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.ja
a:541)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:274)
        at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.jav
:290)
        at com.awaresoft.oauthcxf.services.AwareIMDataProvider$1.execute(AwareI
DataProvider.java:31)
        at com.awaresoft.oauthcxf.services.AwareIMDataProvider$1.execute(AwareI
DataProvider.java:1)
        at org.apache.cxf.rs.security.oauth2.provider.JPAOAuthDataProvider.exec
te(JPAOAuthDataProvider.java:76)
        at com.awaresoft.oauthcxf.services.AwareIMDataProvider.getAccessToken(A
areIMDataProvider.java:22)
        at org.apache.cxf.rs.security.oauth2.services.AbstractAccessTokenValida
or.getAccessTokenValidation(AbstractAccessTokenValidator.java:138)
        at org.apache.cxf.rs.security.oauth2.filters.OAuthRequestFilter.validat
Request(OAuthRequestFilter.java:106)
        at org.apache.cxf.rs.security.oauth2.filters.OAuthRequestFilter.filter(
AuthRequestFilter.java:87)
        at org.apache.cxf.jaxrs.utils.JAXRSUtils.runContainerRequestFilters(JAX
SUtils.java:1688)
        at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(J
XRSInInterceptor.java:109)
        at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JA
RSInInterceptor.java:78)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
orChain.java:308)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
ationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstrac
HTTPDestination.java:267)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination
ServletController.java:234)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCon
roller.java:208)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCon
roller.java:160)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSp
ingServlet.java:216)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(A
stractHTTPServlet.java:301)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractH
TPServlet.java:225)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstrac
HTTPServlet.java:276)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
icationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
ilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:5
)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
icationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
ilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
alve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContext
alve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentic
torBase.java:504)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.
ava:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.
ava:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAcc
ssLogValve.java:650)

1 个答案:

答案 0 :(得分:0)

崩溃在以下代码的setInverseRelation方法中的JDBCStoreManager中发生:

               ClassMapping cm =
                    (ClassMapping) _conf.getMetaDataRepositoryInstance().getCachedMetaData(pc.getClass());
                FieldMapping[] fmd = cm.getFieldMappings();

cm为null,因此cm.getFieldMappings()崩溃。 ClassMapping不在元数据缓存中。由于某种原因,缓存仅具有原始类,但是pc.getClass返回一个ENHANCED类。看起来非常像Open JPA中的错误。有人可以确认吗?