当尝试使用简单的LDAP应用程序连接到LDAP服务器时,我收到一条错误,其中显示"简单绑定失败".我假设这与某种BIND有关.我在其中一个属性文件中有一个绑定属性用于不同的应用程序,但我不知道如何将该属性传递给该程序.
我是否需要添加更多详细信息?
码
import javax.naming.directory.*;
import javax.naming.*;
import java.util.Vector;
import java.util.Enumeration;
import java.util.Properties;
public class SearchLDAP {
public static void main(String[] args) {
String base = "";
String filter = "(objectclass=*)";
Properties env = new Properties();
env.put(DirContext.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(DirContext.PROVIDER_URL,"ldaps://misguided.com.au:343");
try {
System.out.println("11");
DirContext dc = new InitialDirContext(env);
System.out.println("22");
SearchControls sc = new SearchControls();
sc.setSearchScope(SearchControls.OBJECT_SCOPE);
NamingEnumeration ne = null;
ne = dc.search(base, filter, sc);
while (ne.hasMore()) {
SearchResult sr = (SearchResult) ne.next();
System.out.println(sr.toString()+"\n");
}
dc.close();
} catch (NamingException nex) {
System.err.println("Error: " …Run Code Online (Sandbox Code Playgroud) 我从4.1.1升级到似鲭水狼牙鱼和4.1.2.181打电话给我验证终点时,现在我就在401.我的auth端点返回200(ok)但调用应用程序从Payara获得401(据我所知)
父pom.xml:
...
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-all</artifactId>
<version>4.1.2.181</version>
<scope>provided</scope>
</dependency>
...
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>2.25</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
子项目pom.xml
...
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.27</version>
<scope>provided</scope>
</dependency>
...
Run Code Online (Sandbox Code Playgroud)
当我切换回4.1.1版时,问题就消失了
请协助我如何在日志文件中提供更多信息或解决此问题.
更新
<jaxrs-roles-allowed-enabled>false</jaxrs-roles-allowed-enabled>到glassfisf-web.xml仅在日志文件中发出警告我在日志文件中看到以下内容:
无法加载服务类fish.payara.appserver.roles.api.extension.RolesCDIExtension org.osgi.framework.BundleException:bundle fish.payara.appserver.cdi-auth-roles中未解决的约束[374]:无法解析374.0:缺少要求[374.0] osgi.wiring.package; (osgi.wiring.package = fish.payara.cdi.auth.roles)
我设法打开Jersey的跟踪日志记录,并将以下内容作为日志文件中的最后一条跟踪:
[2018-07-17T14:41:02.968 + 0200] [Payara 4.1] [FINE] [] [org.glassfish.jersey.tracing.general] [tid:_ThreadID = 28 _ThreadName = http-thread-pool :: http- listener-1(2)] [timeMillis:1531831262968] [levelValue:500] [CLASSNAME:org.glassfish.jersey.message.internal.TracingLogger $ TracingLoggerImpl] [METHODNAME:logImpl] [[FINISHED响应状态:200/SUCCESSFUL | OK [ - - 女士]]]
降级到Payara 4.1.2.174有效,但目标服务器可能不支持 …
我什至都去了Google第5页,但没有答案...我包括以下内容(我已经检查过战争,而且也在那里):
commons-collections4-4.0.jar
commons-io-2.4.jar
commons-lang3-3.3.2.jar
commons-logging-1.2.jar
commons-net-3.3.jar
commons-vfs2-2.0.jar
jackrabbit-standalone-2.8.0.jar
javax.mail-1.4.4.jar
jcifs-1.3.18.jar
jsch-0.1.51.jar
primefaces-5.0.jar
Run Code Online (Sandbox Code Playgroud)
我想1)创建一个本地文件,2)通过sftp将文件复制到我的服务器。使用正确的数据在正确的目录中本地创建文件。
我的代码被删除:
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystem;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.Selectors;
import org.apache.commons.vfs2.UserAuthenticator;
import org.apache.commons.vfs2.auth.StaticUserAuthenticator;
import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder;
import org.apache.commons.vfs2.impl.StandardFileSystemManager;
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
...
public void dosftp(String data) throws FileSystemException
{
String username = "username";
String password = "password";
String fileName = "test.txt";
String localPath = "C:\\Temp\\";
String fullPath = "sftp://xxx.xxx.xxx.xxx:22/~/temp/" + fileName; …Run Code Online (Sandbox Code Playgroud) 我坚持这个问题.答案可能是直截了当的,但对于我的生活,我无法弄清楚.
这是我非常简单的jsp文件:
<%@page contentType="text/plain"
import="java.util.*"
import="subscriberapi.SubscriberAPI"
pageEncoding="UTF-8"%>
<%!private String Check(String jsonText)
{
SubscriberAPI subscriberAPI = new SubscriberAPI();
return subscriberAPI.Check(jsonText);
}%>
<%response.setContentType("text/plain");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("pragma","no-cache");%>
<%=Check(request.getParameter("jsonText"))%>
Run Code Online (Sandbox Code Playgroud)
我希望输出为:
{"Status":true,"Message":"All good"}
Run Code Online (Sandbox Code Playgroud)
但我得到的输出是:
<html>
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">{"Status":true,"Message":"All good"}</pre>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它在浏览器中看起来是正确的,但实际响应转到另一个不需要html的进程.
如何绕过响应摆脱html构建?这是由Glassfish设定的吗?
我查看了其他问题this和this等,问题是我的转换被调用,但 selectOneMenu 的值没有改变。我的实体类已生成,并且具有 equals 和 hashCode,我不想更改其中的任何内容 - 如果它重新生成,那么所有更改都将丢失(解决方法是更改实体类的 toString)。
XHTML 代码被剪断:
<p:selectOneMenu id="defid"
value="#{abcController.selected.defid}"
converter="defConverter">
Run Code Online (Sandbox Code Playgroud)
转换器:
@FacesConverter("defConverter")
public class DefConverter implements Converter
{
private static final Logger LOG = Logger.getLogger(DefConverter.class.getName());
@EJB
private DefFacade defFacade;
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String string)
{
LOG.info("getAsObject: " + string);
try
{
return defFacade.findWithNFieldsWithValue("name", string, "=").get(0);
}
catch (Exception ex)
{
LOG.log(Level.SEVERE, "Error while fetching Def for " + string, ex);
}
return null;
}
@Override …Run Code Online (Sandbox Code Playgroud) 问题是FETCH INTO(在循环中)没有将值放入变量中.我看过MYSQL | SP | CURSOR - 将游标提取到变量返回null 但该表已经填充.
事务表如下所示:
CREATE TABLE `transactionentry` (
`transactionid` bigint(20) NOT NULL AUTO_INCREMENT,
...
PRIMARY KEY (`transactionid`),
...
) ENGINE=InnoDB AUTO_INCREMENT=651 DEFAULT CHARSET=utf8;
Run Code Online (Sandbox Code Playgroud)
存储过程:
PROCEDURE `doTxnHouseKeeping`()
BEGIN
-- Loop invariant
DECLARE noEntries INTEGER DEFAULT FALSE;
-- Error codes
DECLARE code CHAR(5) DEFAULT '00000';
DECLARE msg TEXT;
-- Txn vars
DECLARE transactionId BIGINT(20);
DECLARE lastTransactionId BIGINT(20) DEFAULT 0;
-- testing
DECLARE counter INT(11) DEFAULT 0;
DEClARE txnEntryCur CURSOR FOR
SELECT
`transactionid`
FROM
`transactionentry`
LIMIT …Run Code Online (Sandbox Code Playgroud) 我试图找出所有ForkJoinPool线程何时完成其任务。我写了这个测试应用程序(我使用System.out是因为它只是一个快速的测试应用程序,并且没有错误检查/处理):
public class TestForkJoinPoolEnd {
private static final Queue<String> queue = new LinkedList<>();
private static final int MAX_SIZE = 5000;
private static final int SPEED_UP = 100;
public static void main(String[] args) {
ForkJoinPool customThreadPool = new ForkJoinPool(12);
customThreadPool.submit(
() -> makeList()
.parallelStream()
.forEach(TestForkJoinPoolEnd::process));
enqueue("Theard pool started up");
int counter = MAX_SIZE + 1;
while (!customThreadPool.isTerminating()) {
String s = dequeue();
if (s != null) {
System.out.println(s);
counter--;
}
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) {
}
}
System.out.println("counter …Run Code Online (Sandbox Code Playgroud) java ×4
converters ×1
glassfish ×1
java-8 ×1
java-stream ×1
jndi ×1
jsf-2 ×1
jsp ×1
ldap ×1
mysql ×1
payara ×1
plaintext ×1
primefaces ×1
response ×1