- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 EJB 时收到 java.lang.ClassNotFoundException
错误。
工具和技术:
eclipse 开普勒
EJB 3.0
Oracle 11g
Jboss 7.1.0
<小时/>我遇到了一些解决方案,添加 ojdbc14.jar/ojdbc6.jar 就可以了。
我已将 jar 文件添加到类路径中,但它仍然给出相同的异常“java.lang.ClassNotFoundException”。
Jboss服务器日志如下:
<小时/>17:27:07,275 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver from [Module "deployment.NewEJB.jar:main" from Service Module Loader]
17:27:07,278 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
17:27:07,279 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
17:27:07,281 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
17:27:07,282 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
17:27:07,284 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
17:27:07,286 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at java.lang.Class.forName0(Native Method)
17:27:07,287 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at java.lang.Class.forName(Class.java:190)
17:27:07,289 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at com.session.LibraryPersistentBean.getList(LibraryPersistentBean.java:39)
17:27:07,291 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:27:07,293 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
17:27:07,295 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17:27:07,298 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at java.lang.reflect.Method.invoke(Method.java:606)
17:27:07,300 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
17:27:07,304 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,307 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
17:27:07,311 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
17:27:07,313 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,314 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
17:27:07,316 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,317 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
17:27:07,319 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,320 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
17:27:07,322 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
17:27:07,324 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,327 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
17:27:07,330 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,333 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
17:27:07,336 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
17:27:07,338 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
17:27:07,340 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,342 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropogatingInterceptor.processInvocation(EJBRemoteTransactionPropogatingInterceptor.java:80)
17:27:07,344 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,345 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
17:27:07,347 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,349 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
17:27:07,350 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,353 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
17:27:07,355 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,357 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
17:27:07,359 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
17:27:07,361 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
17:27:07,364 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
17:27:07,365 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)
17:27:07,367 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:173)
17:27:07,369 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
17:27:07,371 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175)
17:27:07,372 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:92)
17:27:07,374 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175)
17:27:07,375 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
17:27:07,377 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
17:27:07,379 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
17:27:07,380 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at com.sun.proxy.$Proxy12.getList(Unknown Source)
17:27:07,381 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at com.login.action.LoginAction.execute(LoginAction.java:48)
17:27:07,383 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
17:27:07,384 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
17:27:07,386 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
17:27:07,387 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
17:27:07,388 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
17:27:07,390 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
17:27:07,391 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
17:27:07,393 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
17:27:07,394 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
17:27:07,395 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
17:27:07,398 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
17:27:07,400 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
17:27:07,402 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
17:27:07,404 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
17:27:07,405 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
17:27:07,407 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)
17:27:07,410 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
17:27:07,416 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
17:27:07,418 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
17:27:07,419 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
17:27:07,421 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
17:27:07,424 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
17:27:07,427 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
17:27:07,430 ERROR [stderr] (http-localhost-127.0.0.1-8081-1) at java.lang.Thread.run(Thread.java:724)
<小时/>
这是我的代码:
package com.session;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import com.entity.Book;
/**
* Session Bean implementation class LibraryPersistentBean
*/
@Stateless
public class LibraryPersistentBean implements LibraryPersistentBeanRemote {
/**
* Default constructor.
*/
public LibraryPersistentBean() {
// TODO Auto-generated constructor stub
}
@Override
public List<Book> getList() {
Connection con = null;
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String driver = "oracle.jdbc.driver.OracleDriver";
String userName = "NL";
String password = "NL";
List<Book> books = new ArrayList<Book>();
try {
Class.forName(driver);
con = DriverManager.getConnection(url , userName, password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM LOGIN");
Book book;
while (rs.next()) {
book = new Book();
book.setId(rs.getInt(1));
book.setUsername(rs.getString(2));
books.add(book);
}
} catch (SQLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return books;
}
}
提前致谢...!
最佳答案
您应该在 JBoss 7.1.0 中为 Oracle 数据源创建一个新模块。应用服务器。
为此,您需要执行以下操作:
在1.中提到的目录中创建一个名为module.xml的文件:
<module xmlns="urn:jboss:module:1.0" name="com.oracle.db">
<resources>
<resource-root path="ojdbc.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
修改您的standalone.xml文件以适应新创建的模块:
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
(...)
</datasources>
<drivers>
<driver name="oracle" module="com.oracle.db">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
</subsystem>
最后,您只需根据需要配置数据源即可。
更多信息可以在以下链接中找到:
关于java - 我在使用 EJB 时收到错误 `java.lang.ClassNotFoundException`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37460486/
我的应用在尝试访问外部依赖项时遇到 NoClassDefFoundError,但仅限于作为 jar 运行时。 使用 Intellij,我有一个带有主类的简单应用程序,其中包含一些对外部依赖项(例如 s
我收到以下异常: java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.server.servlet.ResteasyBootstr
我正在尝试使用eclipse和tomcat调试solr4.6源代码。我收到错误消息:HTTP 状态 500 - {msg=SolrCore 'collection1' 由于初始化失败而不可用:[sch
我是新来的,很抱歉我的英语不好;)。 我尝试使用以下代码在 java 中加载插件 jar: package testprogramm; import java.io.File; import java
我重新安装了 ADT Bundle,因为我在更新 eclipse 后遇到了一些问题。 现在,当我想测试我的应用程序时,出现以下异常: 06-05 10:33:35.770: E/AndroidRunt
我浏览过现有的帖子,这些帖子处理在 Eclipse 中的 Tomcat 下运行 Java Web 应用程序的 ClassNotFoundException。 我无法提供源代码和配置 Artifact
我忙于我的应用一个多星期,突然: 11-12 07:59:17.860 1653-1653/nl.test.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: ma
我的应用程序有问题,昨天一切正常,但今天我更新了 sdk,现在当我尝试运行我的应用程序时,出现这样的错误 05-21 00:14:19.285: W/dalvikvm(7061): Unable t
我正在阅读 JPA docs在 Spring ,我正在尝试重组我的代码。 我现在所拥有的: BrewerRepository @Repository public class BrewerReposi
我想像 BalusC's example 一样实现 fileUpload . 不幸的是,我已经在努力声明 servlet。 Extensions Filter javax.faces
在某些机器上运行这个小程序不起作用,但在其他机器上它工作得很好。在所有情况下看起来都安装了 JRE 1.6.0_26。 var attributes = {codebase:'http://kas
我将跟随这个非常简单的教程(http://www.tutorialspoint.com/hadoop/hadoop_mapreduce.htm)一起学习,直到我尝试运行Java文件为止,一切运行良好。
我看到了帖子,并按照流程进行了操作。但这没有用。 ClassNotFoundException, while running example job of Hadoop 请帮助我。 创建的 mapre
我尝试在cloudera quickstart vm上为hadoop运行Mahout Kmeans示例。我在这里读link to clouudera block和这里stack overflow po
我有一个mapreduce程序,其中我使用Hcatalog从Hive表'A'中获取带有HcatInputFormat的详细信息,对其进行处理,然后使用HcatOutput格式将其写回到Hive表'B'
我是激发应用程序编程的新手,因此在这里为这个基本的编程而苦苦挣扎。 我有 scala ide 并附加了来自最新 hadoop 和 spark 发行版的相关 jar 文件。我正在使用的只有一个基本的 s
我正在尝试在本地模式下运行Spark示例,但是正在获取以下堆栈跟踪: Exception in thread "main" java.lang.NoClassDefFoundError: org/ap
我有以下代码: // Test TODO remove try { System.out.println(System.getProperties().getPrope
我有以下文件: src/my_proj/myns.clj: (ns my-proj.myns) (defrecord MyRecord [a b c]) 测试/my_proj/myns_test.c
我试图让应用程序动态加载某些类,然后调用启动方法,但问题是,由于 ClassLoader 不同,一个类无法调用另一个类的方法,但是正如我已经用 google 搜索的那样,我用父类创建了两个类加载器。这
我是一名优秀的程序员,十分优秀!