擴展一個類,這不是我想要寫一個custom authentication類xwiki。如何在我的項目
我有了寫有一個認證機制的一個項目,如果有人改掉訪問XWiki實現,我希望它通過使用XWiki實現自定義身份驗證重定向到我的項目的登錄頁面。
我試圖單獨從我的項目中編寫一個類,並將它與xwiki分開,將它打包爲一個jar,並將其放在xwiki項目的xwiki WEB-INF/lib文件夾中,因爲這就是說明爲xwiki定製認證。
的問題是,類我需要寫一些進口的XWiki實現類。如果我正在用這些導入編寫一個單獨的類,它將無法正確編譯。
我應該怎樣創建一個擴展一些XWiki實現類的類,如果它是需要進入XWiki實現的WEB-INF/lib文件夾一個單獨的類?
下面是有人張貼https://www.box.com/shared/9kamt5d9c5一個例子。
簡單的例子
package my.xwiki.custom.authentication;
import java.io.*;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.user.api.XWikiUser;
import com.xpn.xwiki.user.impl.xiki.XWikiAuthServiceImpl;
public class XWikiSSOImpl extends XWikiAuthServiceImpl {
@Override
public XWikiUser checkAuth(XWikiContext context) throws XWikiException {
System.out.println("we actually in checkAuth?");
}
}
當我將jar文件添加到我的XWiki實現並運行它,我得到以下錯誤:
Detailed information:
Error number 0 in 11: Uncaught exception
Wrapped Exception: Unresolved compilation problems:
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
XWikiAuthServiceImpl cannot be resolved to a type
XWikiUser cannot be resolved to a type
XWikiContext cannot be resolved to a type
XWikiException cannot be resolved to a type
com.xpn.xwiki.XWikiException: Error number 0 in 11: Uncaught exception
Wrapped Exception: Unresolved compilation problems:
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
XWikiAuthServiceImpl cannot be resolved to a type
XWikiUser cannot be resolved to a type
XWikiContext cannot be resolved to a type
XWikiException cannot be resolved to a type
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:254)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:116)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:120)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:144)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.Error: Unresolved compilation problems:
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
The import com.xpn cannot be resolved
XWikiAuthServiceImpl cannot be resolved to a type
XWikiUser cannot be resolved to a type
XWikiContext cannot be resolved to a type
XWikiException cannot be resolved to a type
at my.xwiki.custom.authentication.XWikiSSOImpl <init>(XWikiSSOImpl.java:4)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.xpn.xwiki.XWiki.getAuthService(XWiki.java:5288)
at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:4090)
at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:205)
at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:4103)
at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:5128)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:179)
... 34 more
顯示編譯錯誤請 –
是你擴展的基類,並且要導入的類,它們都是在classpath /編譯路徑?如果他們不是,我希望他們失敗。 – corsiKa
請添加代碼片段,突出顯示錯誤 – Chris